Package com.fizzed.rocker.processor
Class WhitespaceRemovalProcessor
java.lang.Object
com.fizzed.rocker.processor.WhitespaceRemovalProcessor
- All Implemented Interfaces:
TemplateModelPostProcessor
This post-processor reduces the amount of whitespace in static strings.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringFor whitespace removals: matching more than one horizontal whitespace in a single line.private static final StringFor whitespace removals: matching one or more new-lines after horizontal spaces (e.g.private static final StringFor whitespace removals: matching one or more horizontal space (e.g. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprocess(TemplateModel templateModel, int ppIndex) Performs any post-processing on the givenTemplateModelas defined by the implementing class.private StringreduceWhitespace(String text) Replace a given string with a whitespace-reduced variant of itself.
-
Field Details
-
LINE_END
For whitespace removals: matching one or more new-lines after horizontal spaces (e.g. space, tab), i.e. at the end of a line. Will be replaced by a single \n.- See Also:
-
IN_LINE
For whitespace removals: matching more than one horizontal whitespace in a single line. Will be replaced by a single space.- See Also:
-
LINE_START
For whitespace removals: matching one or more horizontal space (e.g. space, tab) after one or more new-lines (i.e. at the beginning of a line). Will be replaced by a single new line.- See Also:
-
-
Constructor Details
-
WhitespaceRemovalProcessor
public WhitespaceRemovalProcessor()
-
-
Method Details
-
process
public TemplateModel process(TemplateModel templateModel, int ppIndex) throws PostProcessorException Description copied from interface:TemplateModelPostProcessorPerforms any post-processing on the givenTemplateModelas defined by the implementing class. Only the returned instance shall be used further by the caller. Implementing classes may choose to return the provided instance, or create a completely new instance for further processing.- Specified by:
processin interfaceTemplateModelPostProcessor- Parameters:
templateModel- the original template model (which might have already been processed by previousTemplateModelPostProcessors.ppIndex- the index (starting from 0) of the post-processor as it appears in the list of given post-processor class names.- Returns:
- the resulting
TemplateModelwhich shall be used for further processing by following post-processors, or finally by theJavaGenerator. - Throws:
PostProcessorException- See Also:
-
reduceWhitespace
Replace a given string with a whitespace-reduced variant of itself.- Parameters:
text- original string with whitespaces.- Returns:
- the string with multiple occurences of whitespaces reduced to single occurences.
-