Package com.iizix.js.build.compressors
Class XmlCompressor
- java.lang.Object
- com.iizix.js.build.compressors.XmlCompressor
 
- All Implemented Interfaces:
- Compressor
 - public class XmlCompressor extends java.lang.Object implements 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 Summary- Fields - Modifier and Type - Field - Description - protected static java.util.regex.Pattern- cdataPattern- protected static java.util.regex.Pattern- commentPattern- protected static java.util.regex.Pattern- intertagPattern- protected static java.util.regex.Pattern- multispacePattern- protected static java.util.regex.Pattern- tagEndSpacePattern- protected static java.util.regex.Pattern- tagPropertyPattern- protected static java.lang.String- tempCdataBlock- protected static java.util.regex.Pattern- tempCdataPattern
 - Constructor Summary- Constructors - Constructor - Description - XmlCompressor()
 - Method Summary- All Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - java.lang.String- compress(java.lang.String xml)The main method that compresses given XML source and returns compressed result.- boolean- isEnabled()Returns- trueif compression is enabled.- boolean- isRemoveComments()Returns- trueif all XML comments will be removed.- boolean- isRemoveIntertagSpaces()Returns- trueif all inter-tag whitespace characters will be removed.- protected java.lang.String- preserveBlocks(java.lang.String xml, java.util.List<java.lang.String> cdataBlocks)- protected java.lang.String- processXml(java.lang.String xml)- protected java.lang.String- removeComments(java.lang.String xml)- protected java.lang.String- removeIntertagSpaces(java.lang.String xml)- protected java.lang.String- removeSpacesInsideTags(java.lang.String xml)- protected java.lang.String- returnBlocks(java.lang.String xml, java.util.List<java.lang.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 Detail- tempCdataBlock- protected static final java.lang.String tempCdataBlock - See Also:
- Constant Field Values
 
 - cdataPattern- protected static final java.util.regex.Pattern cdataPattern 
 - commentPattern- protected static final java.util.regex.Pattern commentPattern 
 - intertagPattern- protected static final java.util.regex.Pattern intertagPattern 
 - tagEndSpacePattern- protected static final java.util.regex.Pattern tagEndSpacePattern 
 - multispacePattern- protected static final java.util.regex.Pattern multispacePattern 
 - tagPropertyPattern- protected static final java.util.regex.Pattern tagPropertyPattern 
 - tempCdataPattern- protected static final java.util.regex.Pattern tempCdataPattern 
 
 - Method Detail- compress- public java.lang.String compress(java.lang.String xml) The 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- protected java.lang.String preserveBlocks(java.lang.String xml, java.util.List<java.lang.String> cdataBlocks)
 - returnBlocks- protected java.lang.String returnBlocks(java.lang.String xml, java.util.List<java.lang.String> cdataBlocks)
 - processXml- protected java.lang.String processXml(java.lang.String xml) 
 - removeSpacesInsideTags- protected java.lang.String removeSpacesInsideTags(java.lang.String xml) 
 - removeIntertagSpaces- protected java.lang.String removeIntertagSpaces(java.lang.String xml) 
 - removeComments- protected java.lang.String removeComments(java.lang.String xml) 
 - isEnabled- public boolean isEnabled() Returns- trueif compression is enabled.- Returns:
- trueif compression is enabled.
 
 - setEnabled- public 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
 
 - isRemoveComments- public boolean isRemoveComments() Returns- trueif all XML comments will be removed.- Returns:
- trueif all XML comments will be removed
 
 - setRemoveComments- public void setRemoveComments(boolean removeComments) If set to- trueall XML comments will be removed. Default is- true.- Parameters:
- removeComments- set- trueto remove all XML comments
 
 - isRemoveIntertagSpaces- public boolean isRemoveIntertagSpaces() Returns- trueif all inter-tag whitespace characters will be removed.- Returns:
- trueif all inter-tag whitespace characters will be removed.
 
 - setRemoveIntertagSpaces- public 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