Class CharSequenceDownloadableResource
java.lang.Object
com.atlassian.plugin.webresource.transformer.AbstractTransformedDownloadableResource
com.atlassian.plugin.webresource.transformer.CharSequenceDownloadableResource
- All Implemented Interfaces:
com.atlassian.plugin.servlet.DownloadableResource
public abstract class CharSequenceDownloadableResource
extends AbstractTransformedDownloadableResource
Abstract class that makes it easy to create transforms that go from string to string. Override
encoding() 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
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCharSequenceDownloadableResource(com.atlassian.plugin.servlet.DownloadableResource originalResource) -
Method Summary
Modifier and TypeMethodDescriptionprotected Charsetencoding()voidprotected abstract CharSequencetransform(CharSequence originalContent) Override this method to transform the original content into a new format.Methods inherited from class com.atlassian.plugin.webresource.transformer.AbstractTransformedDownloadableResource
getContentType, getOriginalResource, isResourceModified, serveResource, toString
-
Constructor Details
-
CharSequenceDownloadableResource
protected CharSequenceDownloadableResource(com.atlassian.plugin.servlet.DownloadableResource originalResource)
-
-
Method Details
-
streamResource
- Throws:
com.atlassian.plugin.servlet.DownloadException
-
encoding
-
transform
Override this method to transform the original content into a new format.- Parameters:
originalContent- The content from the original resource.- Returns:
- transformed content
-