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
Constructor Summary
Method Summary
Modifier and TypeMethodDescriptionThe main method that compresses given XML source and returns compressed result.boolean
Returnstrue
if compression is enabled.boolean
Returnstrue
if all XML comments will be removed.boolean
Returnstrue
if 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 tofalse
all compression will be bypassed.void
setRemoveComments
(boolean removeComments) If set totrue
all XML comments will be removed.void
setRemoveIntertagSpaces
(boolean removeIntertagSpaces) If set totrue
all 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:
compress
in interfaceCompressor
- Parameters:
xml
- XML content to compress- Returns:
- compressed content.
preserveBlocks
returnBlocks
processXml
removeSpacesInsideTags
removeIntertagSpaces
removeComments
isEnabled
public boolean isEnabled()Returnstrue
if compression is enabled.- Returns:
true
if compression is enabled.
setEnabled
public void setEnabled(boolean enabled) If set tofalse
all compression will be bypassed. Might be useful for testing purposes. Default istrue
.- Parameters:
enabled
- setfalse
to bypass all compression
isRemoveComments
public boolean isRemoveComments()Returnstrue
if all XML comments will be removed.- Returns:
true
if all XML comments will be removed
setRemoveComments
public void setRemoveComments(boolean removeComments) If set totrue
all XML comments will be removed. Default istrue
.- Parameters:
removeComments
- settrue
to remove all XML comments
isRemoveIntertagSpaces
public boolean isRemoveIntertagSpaces()Returnstrue
if all inter-tag whitespace characters will be removed.- Returns:
true
if all inter-tag whitespace characters will be removed.
setRemoveIntertagSpaces
public void setRemoveIntertagSpaces(boolean removeIntertagSpaces) If set totrue
all inter-tag whitespace characters will be removed. Default istrue
.- Parameters:
removeIntertagSpaces
- settrue
to remove all inter-tag whitespace characters