Package com.fizzed.rocker.processor
Class WhitespaceRemovalProcessor
- java.lang.Object
-
- com.fizzed.rocker.processor.WhitespaceRemovalProcessor
-
- All Implemented Interfaces:
TemplateModelPostProcessor
public class WhitespaceRemovalProcessor extends java.lang.Object implements TemplateModelPostProcessor
This post-processor reduces the amount of whitespace in static strings.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringIN_LINEFor whitespace removals: matching more than one horizontal whitespace in a single line.private static java.lang.StringLINE_ENDFor whitespace removals: matching one or more new-lines after horizontal spaces (e.g.private static java.lang.StringLINE_STARTFor whitespace removals: matching one or more horizontal space (e.g.
-
Constructor Summary
Constructors Constructor Description WhitespaceRemovalProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TemplateModelprocess(TemplateModel templateModel, int ppIndex)Performs any post-processing on the givenTemplateModelas defined by the implementing class.private java.lang.StringreduceWhitespace(java.lang.String text)Replace a given string with a whitespace-reduced variant of itself.
-
-
-
Field Detail
-
LINE_END
private static final java.lang.String 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:
- Constant Field Values
-
IN_LINE
private static final java.lang.String IN_LINE
For whitespace removals: matching more than one horizontal whitespace in a single line. Will be replaced by a single space.- See Also:
- Constant Field Values
-
LINE_START
private static final java.lang.String 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:
- Constant Field Values
-
-
Method Detail
-
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:
TemplateModelPostProcessor.process(com.fizzed.rocker.model.TemplateModel, int)
-
reduceWhitespace
private java.lang.String reduceWhitespace(java.lang.String text)
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.
-
-