public abstract class

AbstractStringTransformedDownloadableResource

extends AbstractTransformedDownloadableResource
java.lang.Object
   ↳ com.atlassian.plugin.webresource.transformer.AbstractTransformedDownloadableResource
     ↳ com.atlassian.plugin.webresource.transformer.AbstractStringTransformedDownloadableResource

Class Overview

Abstract class that makes it easy to create transforms that go from string to string. Override getEncoding() to customize the character encoding of the underlying content and transformed content.

For example, here is a minimal transformer that prepends text to the underlying resource:

 public class PrefixTransformer implements WebResourceTransformer
   {
       public DownloadableResource transform(Element configElement, ResourceLocation location, String filePath, DownloadableResource nextResource)
       {
           return new AbstractStringTransformedDownloadableResource(nextResource)
           {
               protected String transform(String originalContent)
               {
                   return "Prefix: "  + originalContent;
               }
           };
       }
    }
 

Summary

Public Constructors
AbstractStringTransformedDownloadableResource(DownloadableResource originalResource)
Public Methods
void streamResource(OutputStream out)
Protected Methods
String getEncoding()
abstract String transform(String originalContent)
Override this method to transform the original content into a new format.
[Expand]
Inherited Methods
From class com.atlassian.plugin.webresource.transformer.AbstractTransformedDownloadableResource
From class java.lang.Object
From interface com.atlassian.plugin.servlet.DownloadableResource

Public Constructors

public AbstractStringTransformedDownloadableResource (DownloadableResource originalResource)

Public Methods

public void streamResource (OutputStream out)

Protected Methods

protected String getEncoding ()

Returns
  • the encoding used to read the original resource and encode the transformed string

protected abstract String transform (String originalContent)

Override this method to transform the original content into a new format.

Parameters
originalContent The original content from the original downloadable resource.
Returns
  • The transformed content you want returned