Package com.iizix.js.build.compressors
Class XmlCompressor
java.lang.Object
com.iizix.js.build.compressors.XmlCompressor
- All Implemented Interfaces:
- Compressor
Class that compresses given XML source by removing comments, extra spaces and line breaks while preserving content within CDATA blocks.
- Author:
- Sergiy Kovalchuk
- Field SummaryFields
- Constructor SummaryConstructors
- Method SummaryModifier and TypeMethodDescriptionThe main method that compresses given XML source and returns compressed result.- booleanReturns- trueif compression is enabled.- booleanReturns- trueif all XML comments will be removed.- booleanReturns- trueif all inter-tag whitespace characters will be removed.- protected String- preserveBlocks- (String xml, List<String> cdataBlocks) - protected String- processXml- (String xml) - protected String- removeComments- (String xml) - protected String- protected String- protected String- returnBlocks- (String xml, List<String> cdataBlocks) - void- setEnabled- (boolean enabled) If set to- falseall compression will be bypassed.- void- setRemoveComments- (boolean removeComments) If set to- trueall XML comments will be removed.- void- setRemoveIntertagSpaces- (boolean removeIntertagSpaces) If set to- trueall inter-tag whitespace characters will be removed.
- Field Details- tempCdataBlock- See Also:
 
- cdataPattern
- commentPattern
- intertagPattern
- tagEndSpacePattern
- multispacePattern
- tagPropertyPattern
- tempCdataPattern
 
- Constructor Details- XmlCompressorpublic XmlCompressor()
 
- Method Details- compressThe main method that compresses given XML source and returns compressed result.- Specified by:
- compressin interface- Compressor
- Parameters:
- xml- XML content to compress
- Returns:
- compressed content.
 
- preserveBlocks
- returnBlocks
- processXml
- removeSpacesInsideTags
- removeIntertagSpaces
- removeComments
- isEnabledpublic boolean isEnabled()Returns- trueif compression is enabled.- Returns:
- trueif compression is enabled.
 
- setEnabledpublic void setEnabled- (boolean enabled) If set to- falseall compression will be bypassed. Might be useful for testing purposes. Default is- true.- Parameters:
- enabled- set- falseto bypass all compression
 
- isRemoveCommentspublic boolean isRemoveComments()Returns- trueif all XML comments will be removed.- Returns:
- trueif all XML comments will be removed
 
- setRemoveCommentspublic void setRemoveComments- (boolean removeComments) If set to- trueall XML comments will be removed. Default is- true.- Parameters:
- removeComments- set- trueto remove all XML comments
 
- isRemoveIntertagSpacespublic boolean isRemoveIntertagSpaces()Returns- trueif all inter-tag whitespace characters will be removed.- Returns:
- trueif all inter-tag whitespace characters will be removed.
 
- setRemoveIntertagSpacespublic void setRemoveIntertagSpaces- (boolean removeIntertagSpaces) If set to- trueall inter-tag whitespace characters will be removed. Default is- true.- Parameters:
- removeIntertagSpaces- set- trueto remove all inter-tag whitespace characters