com.atlassian.plugin.webresource.transformer
Class AbstractStringTransformedDownloadableResource
java.lang.Object
com.atlassian.plugin.webresource.transformer.AbstractTransformedDownloadableResource
com.atlassian.plugin.webresource.transformer.AbstractStringTransformedDownloadableResource
- All Implemented Interfaces:
- DownloadableResource
public abstract class AbstractStringTransformedDownloadableResource
- extends AbstractTransformedDownloadableResource
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;
}
};
}
}
- Since:
- 2.5.0
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractStringTransformedDownloadableResource
public AbstractStringTransformedDownloadableResource(DownloadableResource originalResource)
streamResource
public void streamResource(OutputStream out)
throws DownloadException
- Description copied from interface:
DownloadableResource
- Write the resource to the supplied OutputStream. Note that the OutputStream will not be closed by this method.
- Parameters:
out
- the stream to write to
- Throws:
DownloadException
- if there were errors writing to the response. Since 2.3.
getEncoding
protected String getEncoding()
- Returns:
- the encoding used to read the original resource and encode the transformed string
transform
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
Copyright © 2010 Atlassian. All Rights Reserved.