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 Summary
FieldsConstructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionThe main method that compresses given XML source and returns compressed result.booleanReturnstrueif compression is enabled.booleanReturnstrueif all XML comments will be removed.booleanReturnstrueif all inter-tag whitespace characters will be removed.protected StringpreserveBlocks(String xml, List<String> cdataBlocks) protected StringprocessXml(String xml) protected StringremoveComments(String xml) protected Stringprotected Stringprotected StringreturnBlocks(String xml, List<String> cdataBlocks) voidsetEnabled(boolean enabled) If set tofalseall compression will be bypassed.voidsetRemoveComments(boolean removeComments) If set totrueall XML comments will be removed.voidsetRemoveIntertagSpaces(boolean removeIntertagSpaces) If set totrueall inter-tag whitespace characters will be removed.
Field Details
tempCdataBlock
- See Also:
cdataPattern
commentPattern
intertagPattern
tagEndSpacePattern
multispacePattern
tagPropertyPattern
tempCdataPattern
Constructor Details
XmlCompressor
public XmlCompressor()
Method Details
compress
The main method that compresses given XML source and returns compressed result.- Specified by:
compressin interfaceCompressor- Parameters:
xml- XML content to compress- Returns:
- compressed content.
preserveBlocks
returnBlocks
processXml
removeSpacesInsideTags
removeIntertagSpaces
removeComments
isEnabled
public boolean isEnabled()Returnstrueif compression is enabled.- Returns:
trueif compression is enabled.
setEnabled
public void setEnabled(boolean enabled) If set tofalseall compression will be bypassed. Might be useful for testing purposes. Default istrue.- Parameters:
enabled- setfalseto bypass all compression
isRemoveComments
public boolean isRemoveComments()Returnstrueif all XML comments will be removed.- Returns:
trueif all XML comments will be removed
setRemoveComments
public void setRemoveComments(boolean removeComments) If set totrueall XML comments will be removed. Default istrue.- Parameters:
removeComments- settrueto remove all XML comments
isRemoveIntertagSpaces
public boolean isRemoveIntertagSpaces()Returnstrueif 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 totrueall inter-tag whitespace characters will be removed. Default istrue.- Parameters:
removeIntertagSpaces- settrueto remove all inter-tag whitespace characters