com.atlassian.plugin.webresource.transformer
Class CharSequenceDownloadableResource
java.lang.Object
com.atlassian.plugin.webresource.transformer.AbstractTransformedDownloadableResource
com.atlassian.plugin.webresource.transformer.CharSequenceDownloadableResource
- All Implemented Interfaces:
- DownloadableResource
public abstract class CharSequenceDownloadableResource
- 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 CharSequenceDownloadableResource(nextResource)
{
protected CharSequence transform(CharSequence originalContent)
{
return "Prefix: " + originalContent;
}
};
}
}
- Since:
- 2.9.0
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CharSequenceDownloadableResource
protected CharSequenceDownloadableResource(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.
encoding
protected Charset encoding()
transform
protected abstract CharSequence transform(CharSequence original)
- Override this method to transform the original content into a new format.
- Parameters:
original - The content from the original resource.
- Returns:
- transformed content
Copyright © 2013 Atlassian. All Rights Reserved.