diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..3efbea3 --- /dev/null +++ b/README.txt @@ -0,0 +1,35 @@ +HtmlCompressor v.${project.version} +http://code.google.com/p/htmlcompressor/ + +Small, fast and very easy to use Java library that minifies given HTML or XML source by removing extra whitespaces, comments and other unneeded characters without breaking the content structure. As a result pages become smaller in size and load faster. A command-line version of the compressor is also available. + + +PACKAGE CONTENT: + /bin - contains main ${project.artifactId}-${project.version}.jar binary, + as well as several extra jars (could be useful for IDE integration) + /doc - javadocs + /src - sources + /lib - dependencies (for using with a command line compressor or non-Maven projects) + pom.xml - Maven POM file + build.bat - Maven build launcher for Win + build.sh - Maven build launcher for *nix + + +USAGE: + For java projects add ${project.artifactId}-${project.version}.jar library to your project's classpath + For a command line usage run: + java -jar ${project.artifactId}-${project.version}.jar -h + to get a brief description of available parameters. + + Please refer to http://code.google.com/p/htmlcompressor/ for the detailed documentation. + + +PROJECT BUILD: + - Install JDK v.5+ (http://www.oracle.com/technetwork/java/javase/downloads/index.html) + - Install Maven v.2+ (http://maven.apache.org/download.html) + - Run build.bat or build.sh + - Compiled binaries will be placed in /target subdirectory + + +CHANGELOG: + http://code.google.com/p/htmlcompressor/wiki/Changelog diff --git a/build-local.bat b/build-local.bat new file mode 100644 index 0000000..97b653f --- /dev/null +++ b/build-local.bat @@ -0,0 +1 @@ +mvn clean package javadoc:jar javadoc:test-jar source:jar source:test-jar site:jar assembly:single install \ No newline at end of file diff --git a/build-local.sh b/build-local.sh new file mode 100644 index 0000000..de14f01 --- /dev/null +++ b/build-local.sh @@ -0,0 +1,2 @@ +#!/bin/sh +mvn clean package javadoc:jar javadoc:test-jar source:jar source:test-jar site:jar assembly:single install \ No newline at end of file diff --git a/build-release.bat b/build-release.bat new file mode 100644 index 0000000..070dac3 --- /dev/null +++ b/build-release.bat @@ -0,0 +1 @@ +mvn clean package javadoc:jar javadoc:test-jar source:jar source:test-jar site:jar assembly:single release:clean release:prepare release:perform \ No newline at end of file diff --git a/build-release.sh b/build-release.sh new file mode 100644 index 0000000..7ff7db9 --- /dev/null +++ b/build-release.sh @@ -0,0 +1,2 @@ +#!/bin/sh +mvn clean package javadoc:jar javadoc:test-jar source:jar source:test-jar site:jar assembly:single release:clean release:prepare release:perform \ No newline at end of file diff --git a/build-snapshot.bat b/build-snapshot.bat new file mode 100644 index 0000000..d9ca6f3 --- /dev/null +++ b/build-snapshot.bat @@ -0,0 +1 @@ +mvn clean package javadoc:jar javadoc:test-jar source:jar source:test-jar site:jar assembly:single deploy \ No newline at end of file diff --git a/build-snapshot.sh b/build-snapshot.sh new file mode 100644 index 0000000..3a3ed01 --- /dev/null +++ b/build-snapshot.sh @@ -0,0 +1,2 @@ +#!/bin/sh +mvn clean package javadoc:jar javadoc:test-jar source:jar source:test-jar site:jar assembly:single deploy \ No newline at end of file diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..814205f --- /dev/null +++ b/build.bat @@ -0,0 +1 @@ +mvn clean package javadoc:jar javadoc:test-jar source:jar source:test-jar site:jar assembly:single -P doc-folder-generation \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..4a0ec5d --- /dev/null +++ b/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +mvn clean package javadoc:jar javadoc:test-jar source:jar source:test-jar site:jar assembly:single -P doc-folder-generation \ No newline at end of file diff --git a/doc/allclasses-frame.html b/doc/allclasses-frame.html new file mode 100644 index 0000000..a178690 --- /dev/null +++ b/doc/allclasses-frame.html @@ -0,0 +1,66 @@ + + + + + + +All Classes (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + +All Classes +
+ + + + + +
ClosureJavaScriptCompressor +
+CmdLineCompressor +
+Compressor +
+CssCompressorDirective +
+CssCompressorTag +
+HtmlAnalyzer +
+HtmlCompressor +
+HtmlCompressorDirective +
+HtmlCompressorStatistics +
+HtmlCompressorTag +
+HtmlMetrics +
+JavaScriptCompressorDirective +
+JavaScriptCompressorTag +
+XmlCompressor +
+XmlCompressorDirective +
+XmlCompressorTag +
+YuiCssCompressor +
+YuiJavaScriptCompressor +
+YuiJavaScriptCompressor.DefaultErrorReporter +
+
+ + + diff --git a/doc/allclasses-noframe.html b/doc/allclasses-noframe.html new file mode 100644 index 0000000..48692ec --- /dev/null +++ b/doc/allclasses-noframe.html @@ -0,0 +1,66 @@ + + + + + + +All Classes (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + +All Classes +
+ + + + + +
ClosureJavaScriptCompressor +
+CmdLineCompressor +
+Compressor +
+CssCompressorDirective +
+CssCompressorTag +
+HtmlAnalyzer +
+HtmlCompressor +
+HtmlCompressorDirective +
+HtmlCompressorStatistics +
+HtmlCompressorTag +
+HtmlMetrics +
+JavaScriptCompressorDirective +
+JavaScriptCompressorTag +
+XmlCompressor +
+XmlCompressorDirective +
+XmlCompressorTag +
+YuiCssCompressor +
+YuiJavaScriptCompressor +
+YuiJavaScriptCompressor.DefaultErrorReporter +
+
+ + + diff --git a/doc/com/googlecode/htmlcompressor/CmdLineCompressor.html b/doc/com/googlecode/htmlcompressor/CmdLineCompressor.html new file mode 100644 index 0000000..13b3c70 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/CmdLineCompressor.html @@ -0,0 +1,282 @@ + + + + + + +CmdLineCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor +
+Class CmdLineCompressor

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.CmdLineCompressor
+
+
+
+
public class CmdLineCompressor
extends Object
+ + +

+Wrapper for HTML and XML compressor classes that allows using them from a command line. + +

Usage: java -jar htmlcompressor.jar [options] [input] +

To view a list of all available parameters please run with -? option: +

java -jar htmlcompressor.jar -? +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
CmdLineCompressor(String[] args) + +
+           
+  + + + + + + + + + + + + + + + +
+Method Summary
+static voidmain(String[] args) + +
+           
+ voidprocess(String[] args) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+CmdLineCompressor

+
+public CmdLineCompressor(String[] args)
+
+
+ + + + + + + + +
+Method Detail
+ +

+main

+
+public static void main(String[] args)
+
+
+
+
+
+
+ +

+process

+
+public void process(String[] args)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/DefaultErrorReporter.html b/doc/com/googlecode/htmlcompressor/DefaultErrorReporter.html new file mode 100644 index 0000000..2fc65a2 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/DefaultErrorReporter.html @@ -0,0 +1,337 @@ + + + + + + +DefaultErrorReporter + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor +
+Class DefaultErrorReporter

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.DefaultErrorReporter
+
+
+
All Implemented Interfaces:
org.mozilla.javascript.ErrorReporter
+
+
+Deprecated. As of release 1.0 replaced by YuiJavaScriptCompressor.DefaultErrorReporter +

+

+
@Deprecated
+public class DefaultErrorReporter
extends java.lang.Object
implements org.mozilla.javascript.ErrorReporter
+ + +

+Default ErrorReporter implementation that uses System.err + stream for error reporting. Used by YUI Compressor to log errors during JavaScript compression. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
Yahoo YUI Compressor, +ErrorReporter Interface
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
DefaultErrorReporter() + +
+          Deprecated.  
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voiderror(java.lang.String message, + java.lang.String sourceName, + int line, + java.lang.String lineSource, + int lineOffset) + +
+          Deprecated.  
+ org.mozilla.javascript.EvaluatorExceptionruntimeError(java.lang.String message, + java.lang.String sourceName, + int line, + java.lang.String lineSource, + int lineOffset) + +
+          Deprecated.  
+ voidwarning(java.lang.String message, + java.lang.String sourceName, + int line, + java.lang.String lineSource, + int lineOffset) + +
+          Deprecated.  
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+DefaultErrorReporter

+
+public DefaultErrorReporter()
+
+
Deprecated. 
+ + + + + + + + +
+Method Detail
+ +

+warning

+
+public void warning(java.lang.String message,
+                    java.lang.String sourceName,
+                    int line,
+                    java.lang.String lineSource,
+                    int lineOffset)
+
+
Deprecated. 
+
Specified by:
warning in interface org.mozilla.javascript.ErrorReporter
+
+
+
+
+
+
+ +

+error

+
+public void error(java.lang.String message,
+                  java.lang.String sourceName,
+                  int line,
+                  java.lang.String lineSource,
+                  int lineOffset)
+
+
Deprecated. 
+
Specified by:
error in interface org.mozilla.javascript.ErrorReporter
+
+
+
+
+
+
+ +

+runtimeError

+
+public org.mozilla.javascript.EvaluatorException runtimeError(java.lang.String message,
+                                                              java.lang.String sourceName,
+                                                              int line,
+                                                              java.lang.String lineSource,
+                                                              int lineOffset)
+
+
Deprecated. 
+
Specified by:
runtimeError in interface org.mozilla.javascript.ErrorReporter
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + diff --git a/doc/com/googlecode/htmlcompressor/analyzer/HtmlAnalyzer.html b/doc/com/googlecode/htmlcompressor/analyzer/HtmlAnalyzer.html new file mode 100644 index 0000000..5a4b10c --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/analyzer/HtmlAnalyzer.html @@ -0,0 +1,274 @@ + + + + + + +HtmlAnalyzer (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.analyzer +
+Class HtmlAnalyzer

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.analyzer.HtmlAnalyzer
+
+
+
+
public class HtmlAnalyzer
extends Object
+ + +

+Class that compresses provided source with different compression + settings and displays page size gains in a report +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
+
+ +

+ + + + + + + + + + + + + + +
+Constructor Summary
HtmlAnalyzer() + +
+           
HtmlAnalyzer(String jsCompressor) + +
+           
+  + + + + + + + + + + + +
+Method Summary
+ voidanalyze(String source) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+HtmlAnalyzer

+
+public HtmlAnalyzer()
+
+
+
+ +

+HtmlAnalyzer

+
+public HtmlAnalyzer(String jsCompressor)
+
+
+ + + + + + + + +
+Method Detail
+ +

+analyze

+
+public void analyze(String source)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/analyzer/class-use/HtmlAnalyzer.html b/doc/com/googlecode/htmlcompressor/analyzer/class-use/HtmlAnalyzer.html new file mode 100644 index 0000000..b4e4e4a --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/analyzer/class-use/HtmlAnalyzer.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.analyzer.HtmlAnalyzer (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.analyzer.HtmlAnalyzer

+
+No usage of com.googlecode.htmlcompressor.analyzer.HtmlAnalyzer +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/analyzer/package-frame.html b/doc/com/googlecode/htmlcompressor/analyzer/package-frame.html new file mode 100644 index 0000000..edeef54 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/analyzer/package-frame.html @@ -0,0 +1,31 @@ + + + + + + +com.googlecode.htmlcompressor.analyzer (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + +com.googlecode.htmlcompressor.analyzer + + + + +
+Classes  + +
+HtmlAnalyzer
+ + + + diff --git a/doc/com/googlecode/htmlcompressor/analyzer/package-summary.html b/doc/com/googlecode/htmlcompressor/analyzer/package-summary.html new file mode 100644 index 0000000..b2e05c9 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/analyzer/package-summary.html @@ -0,0 +1,157 @@ + + + + + + +com.googlecode.htmlcompressor.analyzer (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.googlecode.htmlcompressor.analyzer +

+ + + + + + + + + +
+Class Summary
HtmlAnalyzerClass that compresses provided source with different compression + settings and displays page size gains in a report
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/analyzer/package-tree.html b/doc/com/googlecode/htmlcompressor/analyzer/package-tree.html new file mode 100644 index 0000000..ac1c9ca --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/analyzer/package-tree.html @@ -0,0 +1,152 @@ + + + + + + +com.googlecode.htmlcompressor.analyzer Class Hierarchy (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.googlecode.htmlcompressor.analyzer +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/analyzer/package-use.html b/doc/com/googlecode/htmlcompressor/analyzer/package-use.html new file mode 100644 index 0000000..4711ec8 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/analyzer/package-use.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Package com.googlecode.htmlcompressor.analyzer (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Package
com.googlecode.htmlcompressor.analyzer

+
+No usage of com.googlecode.htmlcompressor.analyzer +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/class-use/CmdLineCompressor.html b/doc/com/googlecode/htmlcompressor/class-use/CmdLineCompressor.html new file mode 100644 index 0000000..d0a87e0 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/class-use/CmdLineCompressor.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.CmdLineCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.CmdLineCompressor

+
+No usage of com.googlecode.htmlcompressor.CmdLineCompressor +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/ClosureJavaScriptCompressor.html b/doc/com/googlecode/htmlcompressor/compressor/ClosureJavaScriptCompressor.html new file mode 100644 index 0000000..d983bfb --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/ClosureJavaScriptCompressor.html @@ -0,0 +1,677 @@ + + + + + + +ClosureJavaScriptCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.compressor +
+Class ClosureJavaScriptCompressor

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor
+
+
+
All Implemented Interfaces:
Compressor
+
+
+
+
public class ClosureJavaScriptCompressor
extends Object
implements Compressor
+ + +

+Basic JavaScript compressor implementation using Google Closure Compiler + that could be used by HtmlCompressor for inline JavaScript compression. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
HtmlCompressor.setJavaScriptCompressor(Compressor), +Google Closure Compiler
+
+ +

+ + + + + + + + + + + + + + + + + + + +
+Field Summary
+static StringCOMPILATION_LEVEL_ADVANCED + +
+           
+static StringCOMPILATION_LEVEL_SIMPLE + +
+           
+static StringCOMPILATION_LEVEL_WHITESPACE + +
+           
+  + + + + + + + + + + + + + +
+Constructor Summary
ClosureJavaScriptCompressor() + +
+           
ClosureJavaScriptCompressor(com.google.javascript.jscomp.CompilationLevel compilationLevel) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Stringcompress(String source) + +
+          The main method that compresses the given source and returns a compressed result.
+ com.google.javascript.jscomp.CompilationLevelgetCompilationLevel() + +
+          Returns level of optimization that is applied when compiling JavaScript code.
+ com.google.javascript.jscomp.CompilerOptionsgetCompilerOptions() + +
+          Returns options that are used by the Closure compiler.
+ List<com.google.javascript.jscomp.JSSourceFile>getExterns() + +
+          Returns JSSourceFile used as a reference during the compression + at CompilationLevel.ADVANCED_OPTIMIZATIONS level.
+ LevelgetLoggingLevel() + +
+          Returns logging level used by the Closure compiler.
+ com.google.javascript.jscomp.WarningLevelgetWarningLevel() + +
+          Returns WarningLevel used by the Closure compiler
+ booleanisCustomExternsOnly() + +
+          Returns true if default externs defined inside Closure's jar are ignored + and only user defined ones are used.
+ voidsetCompilationLevel(com.google.javascript.jscomp.CompilationLevel compilationLevel) + +
+          Sets level of optimization that should be applied when compiling JavaScript code.
+ voidsetCompilerOptions(com.google.javascript.jscomp.CompilerOptions compilerOptions) + +
+          Sets options that will be used by the Closure compiler.
+ voidsetCustomExternsOnly(boolean customExternsOnly) + +
+          If set to true, default externs defined inside Closure's jar will be ignored + and only user defined ones will be used.
+ voidsetExterns(List<com.google.javascript.jscomp.JSSourceFile> externs) + +
+          Sets external JavaScript files that are used as a reference for function declarations if + CompilationLevel.ADVANCED_OPTIMIZATIONS compression level is used.
+ voidsetLoggingLevel(Level loggingLevel) + +
+          Sets logging level for the Closure compiler.
+ voidsetWarningLevel(com.google.javascript.jscomp.WarningLevel warningLevel) + +
+          Indicates the amount of information you want from the compiler about possible problems in your code.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+COMPILATION_LEVEL_SIMPLE

+
+public static final String COMPILATION_LEVEL_SIMPLE
+
+
+
See Also:
Constant Field Values
+
+
+ +

+COMPILATION_LEVEL_ADVANCED

+
+public static final String COMPILATION_LEVEL_ADVANCED
+
+
+
See Also:
Constant Field Values
+
+
+ +

+COMPILATION_LEVEL_WHITESPACE

+
+public static final String COMPILATION_LEVEL_WHITESPACE
+
+
+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+ClosureJavaScriptCompressor

+
+public ClosureJavaScriptCompressor()
+
+
+
+ +

+ClosureJavaScriptCompressor

+
+public ClosureJavaScriptCompressor(com.google.javascript.jscomp.CompilationLevel compilationLevel)
+
+
+ + + + + + + + +
+Method Detail
+ +

+compress

+
+public String compress(String source)
+
+
Description copied from interface: Compressor
+
The main method that compresses the given source and returns a compressed result. +

+

+
Specified by:
compress in interface Compressor
+
+
+
Parameters:
source - The source to compress. +
Returns:
Compressed result.
+
+
+
+ +

+getCompilationLevel

+
+public com.google.javascript.jscomp.CompilationLevel getCompilationLevel()
+
+
Returns level of optimization that is applied when compiling JavaScript code. +

+

+
+
+
+ +
Returns:
CompilationLevel that is applied when compiling JavaScript code.
See Also:
CompilationLevel
+
+
+
+ +

+setCompilationLevel

+
+public void setCompilationLevel(com.google.javascript.jscomp.CompilationLevel compilationLevel)
+
+
Sets level of optimization that should be applied when compiling JavaScript code. + If none is provided, CompilationLevel.SIMPLE_OPTIMIZATIONS will be used by default. + +

Warning: Using CompilationLevel.ADVANCED_OPTIMIZATIONS could + break inline JavaScript if externs are not set properly. +

+

+
+
+
+
Parameters:
compilationLevel - Optimization level to use, could be set to CompilationLevel.ADVANCED_OPTIMIZATIONS, CompilationLevel.SIMPLE_OPTIMIZATIONS, CompilationLevel.WHITESPACE_ONLY
See Also:
Advanced Compilation and Externs, +Closure Compiler Compilation Levels, +CompilationLevel
+
+
+
+ +

+getCompilerOptions

+
+public com.google.javascript.jscomp.CompilerOptions getCompilerOptions()
+
+
Returns options that are used by the Closure compiler. +

+

+
+
+
+ +
Returns:
CompilerOptions that are used by the compiler
See Also:
CompilerOptions
+
+
+
+ +

+setCompilerOptions

+
+public void setCompilerOptions(com.google.javascript.jscomp.CompilerOptions compilerOptions)
+
+
Sets options that will be used by the Closure compiler. + If none is provided, default options constructor will be used: new CompilerOptions(). +

+

+
+
+
+
Parameters:
compilerOptions - CompilerOptions that will be used by the compiler
See Also:
CompilerOptions
+
+
+
+ +

+getLoggingLevel

+
+public Level getLoggingLevel()
+
+
Returns logging level used by the Closure compiler. +

+

+
+
+
+ +
Returns:
Level of logging used by the Closure compiler
+
+
+
+ +

+setLoggingLevel

+
+public void setLoggingLevel(Level loggingLevel)
+
+
Sets logging level for the Closure compiler. +

+

+
+
+
+
Parameters:
loggingLevel - logging level for the Closure compiler.
See Also:
Level
+
+
+
+ +

+getExterns

+
+public List<com.google.javascript.jscomp.JSSourceFile> getExterns()
+
+
Returns JSSourceFile used as a reference during the compression + at CompilationLevel.ADVANCED_OPTIMIZATIONS level. +

+

+
+
+
+ +
Returns:
JSSourceFile used as a reference during compression
+
+
+
+ +

+setExterns

+
+public void setExterns(List<com.google.javascript.jscomp.JSSourceFile> externs)
+
+
Sets external JavaScript files that are used as a reference for function declarations if + CompilationLevel.ADVANCED_OPTIMIZATIONS compression level is used. + +

A number of default externs defined inside Closure's jar will be used besides user defined ones, + to use only user defined externs set setCustomExternsOnly(true) + +

Warning: Using CompilationLevel.ADVANCED_OPTIMIZATIONS could + break inline JavaScript if externs are not set properly. +

+

+
+
+
+
Parameters:
externs - JSSourceFile to use as a reference during compression
See Also:
setCompilationLevel(CompilationLevel), +setCustomExternsOnly(boolean), +Advanced Compilation and Externs, +JSSourceFile
+
+
+
+ +

+getWarningLevel

+
+public com.google.javascript.jscomp.WarningLevel getWarningLevel()
+
+
Returns WarningLevel used by the Closure compiler +

+

+
+
+
+ +
Returns:
WarningLevel used by the Closure compiler
+
+
+
+ +

+setWarningLevel

+
+public void setWarningLevel(com.google.javascript.jscomp.WarningLevel warningLevel)
+
+
Indicates the amount of information you want from the compiler about possible problems in your code. +

+

+
+
+
+
Parameters:
warningLevel - WarningLevel to use
See Also:
+
+
+
+ +

+isCustomExternsOnly

+
+public boolean isCustomExternsOnly()
+
+
Returns true if default externs defined inside Closure's jar are ignored + and only user defined ones are used. +

+

+
+
+
+ +
Returns:
true if default externs defined inside Closure's jar are ignored + and only user defined ones are used
+
+
+
+ +

+setCustomExternsOnly

+
+public void setCustomExternsOnly(boolean customExternsOnly)
+
+
If set to true, default externs defined inside Closure's jar will be ignored + and only user defined ones will be used. +

+

+
+
+
+
Parameters:
customExternsOnly - true to skip default externs and use only user defined ones
See Also:
setExterns(List), +setCompilationLevel(CompilationLevel)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/Compressor.html b/doc/com/googlecode/htmlcompressor/compressor/Compressor.html new file mode 100644 index 0000000..54db72f --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/Compressor.html @@ -0,0 +1,219 @@ + + + + + + +Compressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.compressor +
+Interface Compressor

+
+
All Known Implementing Classes:
ClosureJavaScriptCompressor, HtmlCompressor, XmlCompressor, YuiCssCompressor, YuiJavaScriptCompressor
+
+
+
+
public interface Compressor
+ + +

+Interface describing compressor classes. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
+
+ +

+ + + + + + + + + + + + +
+Method Summary
+ Stringcompress(String source) + +
+          The main method that compresses the given source and returns a compressed result.
+  +

+ + + + + + + + +
+Method Detail
+ +

+compress

+
+String compress(String source)
+
+
The main method that compresses the given source and returns a compressed result. +

+

+
Parameters:
source - The source to compress. +
Returns:
Compressed result.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/HtmlCompressor.html b/doc/com/googlecode/htmlcompressor/compressor/HtmlCompressor.html new file mode 100644 index 0000000..36d0b50 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/HtmlCompressor.html @@ -0,0 +1,2114 @@ + + + + + + +HtmlCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.compressor +
+Class HtmlCompressor

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.compressor.HtmlCompressor
+
+
+
All Implemented Interfaces:
Compressor
+
+
+
+
public class HtmlCompressor
extends Object
implements Compressor
+ + +

+Class that compresses given HTML source by removing comments, extra spaces and + line breaks while preserving content within <pre>, <textarea>, <script> + and <style> tags. +

Blocks that should be additionally preserved could be marked with: +
<!-- {{{ --> +
    ... +
<!-- }}} -->
+
or any number of user defined patterns. +

Content inside <script> or <style> tags could be optionally compressed using + Yahoo YUI Compressor or Google Closure Compiler + libraries. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static StringALL_TAGS + +
+          Could be passed to setRemoveSurroundingSpaces method + to remove all surrounding spaces (not recommended).
+static StringBLOCK_TAGS_MAX + +
+          Predefined list of tags that are block-level by default, excluding <div> and <li> tags.
+static StringBLOCK_TAGS_MIN + +
+          Predefined list of tags that are very likely to be block-level.
+static StringJS_COMPRESSOR_CLOSURE + +
+           
+static StringJS_COMPRESSOR_YUI + +
+           
+static PatternPHP_TAG_PATTERN + +
+          Predefined pattern that matches <?php ...
+static PatternSERVER_SCRIPT_TAG_PATTERN + +
+          Predefined pattern that matches <% ...
+static PatternSERVER_SIDE_INCLUDE_PATTERN + +
+          Predefined pattern that matches <--# ...
+  + + + + + + + + + + +
+Constructor Summary
HtmlCompressor() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Stringcompress(String html) + +
+          The main method that compresses given HTML source and returns compressed + result.
+ CompressorgetCssCompressor() + +
+          Returns CSS compressor implementation that will be used + to compress inline CSS in HTML.
+ CompressorgetJavaScriptCompressor() + +
+          Returns JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML.
+ List<Pattern>getPreservePatterns() + +
+          Returns a list of Patterns defining custom preserving block rules
+ StringgetRemoveSurroundingSpaces() + +
+          Returns a comma separated list of tags around which spaces will be removed.
+ HtmlCompressorStatisticsgetStatistics() + +
+          Returns HtmlCompressorStatistics object containing statistics of the last HTML compression, if enabled.
+ intgetYuiCssLineBreak() + +
+          Returns number of symbols per line Yahoo YUI Compressor + will use during CSS compression.
+ org.mozilla.javascript.ErrorReportergetYuiErrorReporter() + +
+          Returns ErrorReporter used by YUI Compressor to log error messages + during JavasSript compression
+ intgetYuiJsLineBreak() + +
+          Returns number of symbols per line Yahoo YUI Compressor + will use during JavaScript compression.
+ booleanisCompressCss() + +
+          Returns true if CSS compression is enabled.
+ booleanisCompressJavaScript() + +
+          Returns true if JavaScript compression is enabled.
+ booleanisEnabled() + +
+          Returns true if compression is enabled.
+ booleanisGenerateStatistics() + +
+          Returns true if HTML compression statistics is generated
+ booleanisPreserveLineBreaks() + +
+          Returns true if line breaks will be preserved.
+ booleanisRemoveComments() + +
+          Returns true if all HTML comments will be removed.
+ booleanisRemoveFormAttributes() + +
+          Returns true if method="get" attributes will be removed from <form> tags
+ booleanisRemoveHttpProtocol() + +
+          Returns true if HTTP protocol will be removed from href, src, cite, and action tag attributes.
+ booleanisRemoveHttpsProtocol() + +
+          Returns true if HTTPS protocol will be removed from href, src, cite, and action tag attributes.
+ booleanisRemoveInputAttributes() + +
+          Returns true if type="text" attributes will be removed from <input> tags
+ booleanisRemoveIntertagSpaces() + +
+          Returns true if all inter-tag whitespace characters will be removed.
+ booleanisRemoveJavaScriptProtocol() + +
+          Returns true if javascript: pseudo-protocol will be removed from inline event handlers.
+ booleanisRemoveLinkAttributes() + +
+          Returns true if unnecessary attributes will be removed from <link> tags
+ booleanisRemoveMultiSpaces() + +
+          Returns true if all multiple whitespace characters will be replaced with single spaces.
+ booleanisRemoveQuotes() + +
+          Returns true if all unnecessary quotes will be removed + from tag attributes.
+ booleanisRemoveScriptAttributes() + +
+          Returns true if unnecessary attributes wil be removed from <script> tags
+ booleanisRemoveStyleAttributes() + +
+          Returns true if type="text/style" attributes will be removed from <style> tags
+ booleanisSimpleBooleanAttributes() + +
+          Returns true if boolean attributes will be simplified
+ booleanisSimpleDoctype() + +
+          Returns true if existing DOCTYPE declaration will be replaced with simple declaration.
+ booleanisYuiJsDisableOptimizations() + +
+          Returns true if Yahoo YUI Compressor + will disable all the built-in micro optimizations during JavaScript compression.
+ booleanisYuiJsNoMunge() + +
+          Returns true if Yahoo YUI Compressor + will only minify javascript without obfuscating local symbols.
+ booleanisYuiJsPreserveAllSemiColons() + +
+          Returns true if Yahoo YUI Compressor + will preserve unnecessary semicolons during JavaScript compression.
+ voidsetCompressCss(boolean compressCss) + +
+          Enables CSS compression within <style> tags using + Yahoo YUI Compressor + if set to true.
+ voidsetCompressJavaScript(boolean compressJavaScript) + +
+          Enables JavaScript compression within <script> tags using + Yahoo YUI Compressor + if set to true.
+ voidsetCssCompressor(Compressor cssCompressor) + +
+          Sets CSS compressor implementation that will be used + to compress inline CSS in HTML.
+ voidsetEnabled(boolean enabled) + +
+          If set to false all compression will be bypassed.
+ voidsetGenerateStatistics(boolean generateStatistics) + +
+          If set to true, HTML compression statistics will be generated.
+ voidsetJavaScriptCompressor(Compressor javaScriptCompressor) + +
+          Sets JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML.
+ voidsetPreserveLineBreaks(boolean preserveLineBreaks) + +
+          If set to true, line breaks will be preserved.
+ voidsetPreservePatterns(List<Pattern> preservePatterns) + +
+          This method allows setting custom block preservation rules defined by regular + expression patterns.
+ voidsetRemoveComments(boolean removeComments) + +
+          If set to true all HTML comments will be removed.
+ voidsetRemoveFormAttributes(boolean removeFormAttributes) + +
+          If set to true, method="get" attributes will be removed from <form> tags.
+ voidsetRemoveHttpProtocol(boolean removeHttpProtocol) + +
+          If set to true, HTTP protocol will be removed from href, src, cite, and action tag attributes.
+ voidsetRemoveHttpsProtocol(boolean removeHttpsProtocol) + +
+          If set to true, HTTPS protocol will be removed from href, src, cite, and action tag attributes.
+ voidsetRemoveInputAttributes(boolean removeInputAttributes) + +
+          If set to true, type="text" attributes will be removed from <input> tags.
+ voidsetRemoveIntertagSpaces(boolean removeIntertagSpaces) + +
+          If set to true all inter-tag whitespace characters will be removed.
+ voidsetRemoveJavaScriptProtocol(boolean removeJavaScriptProtocol) + +
+          If set to true, javascript: pseudo-protocol will be removed from inline event handlers.
+ voidsetRemoveLinkAttributes(boolean removeLinkAttributes) + +
+          If set to true, following attributes will be removed from <link rel="stylesheet"> and <link rel="alternate stylesheet"> tags: + + type="text/css" + type="text/plain" +
+ voidsetRemoveMultiSpaces(boolean removeMultiSpaces) + +
+          If set to true all multiple whitespace characters will be replaced with single spaces.
+ voidsetRemoveQuotes(boolean removeQuotes) + +
+          If set to true all unnecessary quotes will be removed + from tag attributes.
+ voidsetRemoveScriptAttributes(boolean removeScriptAttributes) + +
+          If set to true, following attributes will be removed from <script> tags: + + type="text/javascript" + type="application/javascript" + language="javascript" +
+ voidsetRemoveStyleAttributes(boolean removeStyleAttributes) + +
+          If set to true, type="text/style" attributes will be removed from <style> tags.
+ voidsetRemoveSurroundingSpaces(String tagList) + +
+          Enables surrounding spaces removal around provided comma separated list of tags.
+ voidsetSimpleBooleanAttributes(boolean simpleBooleanAttributes) + +
+          If set to true, any values of following boolean attributes will be removed: + + checked + selected + disabled + readonly +
+ voidsetSimpleDoctype(boolean simpleDoctype) + +
+          If set to true, existing DOCTYPE declaration will be replaced with simple <!DOCTYPE html> declaration.
+ voidsetYuiCssLineBreak(int yuiCssLineBreak) + +
+          Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during CSS compression.
+ voidsetYuiErrorReporter(org.mozilla.javascript.ErrorReporter yuiErrorReporter) + +
+          Sets ErrorReporter that YUI Compressor will use for reporting errors during + JavaScript compression.
+ voidsetYuiJsDisableOptimizations(boolean yuiJsDisableOptimizations) + +
+          Tells Yahoo YUI Compressor to disable all the built-in micro optimizations + during JavaScript compression.
+ voidsetYuiJsLineBreak(int yuiJsLineBreak) + +
+          Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during JavaScript compression.
+ voidsetYuiJsNoMunge(boolean yuiJsNoMunge) + +
+          Tells Yahoo YUI Compressor to only minify javascript without obfuscating + local symbols.
+ voidsetYuiJsPreserveAllSemiColons(boolean yuiJsPreserveAllSemiColons) + +
+          Tells Yahoo YUI Compressor to preserve unnecessary semicolons + during JavaScript compression.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+JS_COMPRESSOR_YUI

+
+public static final String JS_COMPRESSOR_YUI
+
+
+
See Also:
Constant Field Values
+
+
+ +

+JS_COMPRESSOR_CLOSURE

+
+public static final String JS_COMPRESSOR_CLOSURE
+
+
+
See Also:
Constant Field Values
+
+
+ +

+PHP_TAG_PATTERN

+
+public static final Pattern PHP_TAG_PATTERN
+
+
Predefined pattern that matches <?php ... ?> tags. + Could be passed inside a list to setPreservePatterns method. +

+

+
+
+
+ +

+SERVER_SCRIPT_TAG_PATTERN

+
+public static final Pattern SERVER_SCRIPT_TAG_PATTERN
+
+
Predefined pattern that matches <% ... %> tags. + Could be passed inside a list to setPreservePatterns method. +

+

+
+
+
+ +

+SERVER_SIDE_INCLUDE_PATTERN

+
+public static final Pattern SERVER_SIDE_INCLUDE_PATTERN
+
+
Predefined pattern that matches <--# ... --> tags. + Could be passed inside a list to setPreservePatterns method. +

+

+
+
+
+ +

+BLOCK_TAGS_MIN

+
+public static final String BLOCK_TAGS_MIN
+
+
Predefined list of tags that are very likely to be block-level. + Could be passed to setRemoveSurroundingSpaces method. +

+

+
See Also:
Constant Field Values
+
+
+ +

+BLOCK_TAGS_MAX

+
+public static final String BLOCK_TAGS_MAX
+
+
Predefined list of tags that are block-level by default, excluding <div> and <li> tags. + Table tags are also included. + Could be passed to setRemoveSurroundingSpaces method. +

+

+
See Also:
Constant Field Values
+
+
+ +

+ALL_TAGS

+
+public static final String ALL_TAGS
+
+
Could be passed to setRemoveSurroundingSpaces method + to remove all surrounding spaces (not recommended). +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+HtmlCompressor

+
+public HtmlCompressor()
+
+
+ + + + + + + + +
+Method Detail
+ +

+compress

+
+public String compress(String html)
+
+
The main method that compresses given HTML source and returns compressed + result. +

+

+
Specified by:
compress in interface Compressor
+
+
+
Parameters:
html - HTML content to compress +
Returns:
compressed content.
+
+
+
+ +

+isCompressJavaScript

+
+public boolean isCompressJavaScript()
+
+
Returns true if JavaScript compression is enabled. +

+

+
+
+
+ +
Returns:
current state of JavaScript compression.
+
+
+
+ +

+setCompressJavaScript

+
+public void setCompressJavaScript(boolean compressJavaScript)
+
+
Enables JavaScript compression within <script> tags using + Yahoo YUI Compressor + if set to true. Default is false for performance reasons. + +

Note: Compressing JavaScript is not recommended if pages are + compressed dynamically on-the-fly because of performance impact. + You should consider putting JavaScript into a separate file and + compressing it using standalone YUICompressor for example.

+

+

+
+
+
+
Parameters:
compressJavaScript - set true to enable JavaScript compression. + Default is false
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+isCompressCss

+
+public boolean isCompressCss()
+
+
Returns true if CSS compression is enabled. +

+

+
+
+
+ +
Returns:
current state of CSS compression.
+
+
+
+ +

+setCompressCss

+
+public void setCompressCss(boolean compressCss)
+
+
Enables CSS compression within <style> tags using + Yahoo YUI Compressor + if set to true. Default is false for performance reasons. + +

Note: Compressing CSS is not recommended if pages are + compressed dynamically on-the-fly because of performance impact. + You should consider putting CSS into a separate file and + compressing it using standalone YUICompressor for example.

+

+

+
+
+
+
Parameters:
compressCss - set true to enable CSS compression. + Default is false
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+isYuiJsNoMunge

+
+public boolean isYuiJsNoMunge()
+
+
Returns true if Yahoo YUI Compressor + will only minify javascript without obfuscating local symbols. + This corresponds to --nomunge command line option. +

+

+
+
+
+ +
Returns:
nomunge parameter value used for JavaScript compression.
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+setYuiJsNoMunge

+
+public void setYuiJsNoMunge(boolean yuiJsNoMunge)
+
+
Tells Yahoo YUI Compressor to only minify javascript without obfuscating + local symbols. This corresponds to --nomunge command line option. + This option has effect only if JavaScript compression is enabled. + Default is false. +

+

+
+
+
+
Parameters:
yuiJsNoMunge - set true to enable nomunge mode
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+isYuiJsPreserveAllSemiColons

+
+public boolean isYuiJsPreserveAllSemiColons()
+
+
Returns true if Yahoo YUI Compressor + will preserve unnecessary semicolons during JavaScript compression. + This corresponds to --preserve-semi command line option. +

+

+
+
+
+ +
Returns:
preserve-semi parameter value used for JavaScript compression.
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+setYuiJsPreserveAllSemiColons

+
+public void setYuiJsPreserveAllSemiColons(boolean yuiJsPreserveAllSemiColons)
+
+
Tells Yahoo YUI Compressor to preserve unnecessary semicolons + during JavaScript compression. This corresponds to + --preserve-semi command line option. + This option has effect only if JavaScript compression is enabled. + Default is false. +

+

+
+
+
+
Parameters:
yuiJsPreserveAllSemiColons - set true to enable preserve-semi mode
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+isYuiJsDisableOptimizations

+
+public boolean isYuiJsDisableOptimizations()
+
+
Returns true if Yahoo YUI Compressor + will disable all the built-in micro optimizations during JavaScript compression. + This corresponds to --disable-optimizations command line option. +

+

+
+
+
+ +
Returns:
disable-optimizations parameter value used for JavaScript compression.
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+setYuiJsDisableOptimizations

+
+public void setYuiJsDisableOptimizations(boolean yuiJsDisableOptimizations)
+
+
Tells Yahoo YUI Compressor to disable all the built-in micro optimizations + during JavaScript compression. This corresponds to + --disable-optimizations command line option. + This option has effect only if JavaScript compression is enabled. + Default is false. +

+

+
+
+
+
Parameters:
yuiJsDisableOptimizations - set true to enable + disable-optimizations mode
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+getYuiJsLineBreak

+
+public int getYuiJsLineBreak()
+
+
Returns number of symbols per line Yahoo YUI Compressor + will use during JavaScript compression. + This corresponds to --line-break command line option. +

+

+
+
+
+ +
Returns:
line-break parameter value used for JavaScript compression.
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+setYuiJsLineBreak

+
+public void setYuiJsLineBreak(int yuiJsLineBreak)
+
+
Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during JavaScript compression. This corresponds to + --line-break command line option. + This option has effect only if JavaScript compression is enabled. + Default is -1 to disable line breaks. +

+

+
+
+
+
Parameters:
yuiJsLineBreak - set number of symbols per line
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+getYuiCssLineBreak

+
+public int getYuiCssLineBreak()
+
+
Returns number of symbols per line Yahoo YUI Compressor + will use during CSS compression. + This corresponds to --line-break command line option. +

+

+
+
+
+ +
Returns:
line-break parameter value used for CSS compression.
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+setYuiCssLineBreak

+
+public void setYuiCssLineBreak(int yuiCssLineBreak)
+
+
Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during CSS compression. This corresponds to + --line-break command line option. + This option has effect only if CSS compression is enabled. + Default is -1 to disable line breaks. +

+

+
+
+
+
Parameters:
yuiCssLineBreak - set number of symbols per line
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+isRemoveQuotes

+
+public boolean isRemoveQuotes()
+
+
Returns true if all unnecessary quotes will be removed + from tag attributes. +

+

+
+
+
+
+
+
+
+ +

+setRemoveQuotes

+
+public void setRemoveQuotes(boolean removeQuotes)
+
+
If set to true all unnecessary quotes will be removed + from tag attributes. Default is false. + +

Note: Even though quotes are removed only when it is safe to do so, + it still might break strict HTML validation. Turn this option on only if + a page validation is not very important or to squeeze the most out of the compression. + This option has no performance impact. +

+

+
+
+
+
Parameters:
removeQuotes - set true to remove unnecessary quotes from tag attributes
+
+
+
+ +

+isEnabled

+
+public boolean isEnabled()
+
+
Returns true if compression is enabled. +

+

+
+
+
+ +
Returns:
true if compression is enabled.
+
+
+
+ +

+setEnabled

+
+public void setEnabled(boolean enabled)
+
+
If set to false all compression will be bypassed. Might be useful for testing purposes. + Default is true. +

+

+
+
+
+
Parameters:
enabled - set false to bypass all compression
+
+
+
+ +

+isRemoveComments

+
+public boolean isRemoveComments()
+
+
Returns true if all HTML comments will be removed. +

+

+
+
+
+ +
Returns:
true if all HTML comments will be removed
+
+
+
+ +

+setRemoveComments

+
+public void setRemoveComments(boolean removeComments)
+
+
If set to true all HTML comments will be removed. + Default is true. +

+

+
+
+
+
Parameters:
removeComments - set true to remove all HTML comments
+
+
+
+ +

+isRemoveMultiSpaces

+
+public boolean isRemoveMultiSpaces()
+
+
Returns true if all multiple whitespace characters will be replaced with single spaces. +

+

+
+
+
+ +
Returns:
true if all multiple whitespace characters will be replaced with single spaces.
+
+
+
+ +

+setRemoveMultiSpaces

+
+public void setRemoveMultiSpaces(boolean removeMultiSpaces)
+
+
If set to true all multiple whitespace characters will be replaced with single spaces. + Default is true. +

+

+
+
+
+
Parameters:
removeMultiSpaces - set true to replace all multiple whitespace characters + will single spaces.
+
+
+
+ +

+isRemoveIntertagSpaces

+
+public boolean isRemoveIntertagSpaces()
+
+
Returns true 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 to true all inter-tag whitespace characters will be removed. + Default is false. + +

Note: It is fairly safe to turn this option on unless you + rely on spaces for page formatting. Even if you do, you can always preserve + required spaces with &nbsp;. This option has no performance impact. +

+

+
+
+
+
Parameters:
removeIntertagSpaces - set true to remove all inter-tag whitespace characters
+
+
+
+ +

+getPreservePatterns

+
+public List<Pattern> getPreservePatterns()
+
+
Returns a list of Patterns defining custom preserving block rules +

+

+
+
+
+ +
Returns:
list of Pattern objects defining rules for preserving block rules
+
+
+
+ +

+setPreservePatterns

+
+public void setPreservePatterns(List<Pattern> preservePatterns)
+
+
This method allows setting custom block preservation rules defined by regular + expression patterns. Blocks that match provided patterns will be skipped during HTML compression. + +

Custom preservation rules have higher priority than default rules. + Priority between custom rules are defined by their position in a list + (beginning of a list has higher priority). + +

Besides custom patterns, you can use 3 predefined patterns: + PHP_TAG_PATTERN, + SERVER_SCRIPT_TAG_PATTERN, + SERVER_SIDE_INCLUDE_PATTERN. +

+

+
+
+
+
Parameters:
preservePatterns - List of Pattern objects that will be + used to skip matched blocks during compression
+
+
+
+ +

+getYuiErrorReporter

+
+public org.mozilla.javascript.ErrorReporter getYuiErrorReporter()
+
+
Returns ErrorReporter used by YUI Compressor to log error messages + during JavasSript compression +

+

+
+
+
+ +
Returns:
ErrorReporter used by YUI Compressor to log error messages + during JavasSript compression
See Also:
Yahoo YUI Compressor, +Error Reporter Interface
+
+
+
+ +

+setYuiErrorReporter

+
+public void setYuiErrorReporter(org.mozilla.javascript.ErrorReporter yuiErrorReporter)
+
+
Sets ErrorReporter that YUI Compressor will use for reporting errors during + JavaScript compression. If no ErrorReporter was provided + YuiJavaScriptCompressor.DefaultErrorReporter will be used + which reports errors to System.err stream. +

+

+
+
+
+
Parameters:
yuiErrorReporter - ErrorReporter that will be used by YUI Compressor
See Also:
YuiJavaScriptCompressor.DefaultErrorReporter, +Yahoo YUI Compressor, +ErrorReporter Interface
+
+
+
+ +

+getJavaScriptCompressor

+
+public Compressor getJavaScriptCompressor()
+
+
Returns JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML. +

+

+
+
+
+ +
Returns:
Compressor implementation that will be used + to compress inline JavaScript in HTML.
See Also:
YuiJavaScriptCompressor, +ClosureJavaScriptCompressor, +Yahoo YUI Compressor, +Google Closure Compiler
+
+
+
+ +

+setJavaScriptCompressor

+
+public void setJavaScriptCompressor(Compressor javaScriptCompressor)
+
+
Sets JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML. + +

HtmlCompressor currently + comes with basic implementations for Yahoo YUI Compressor (called YuiJavaScriptCompressor) + and Google Closure Compiler (called ClosureJavaScriptCompressor) that should be enough for most cases, + but users can also create their own JavaScript compressors for custom needs. + +

If no compressor is set YuiJavaScriptCompressor will be used by default. +

+

+
+
+
+
Parameters:
javaScriptCompressor - Compressor implementation that will be used for inline JavaScript compression
See Also:
YuiJavaScriptCompressor, +ClosureJavaScriptCompressor, +Yahoo YUI Compressor, +Google Closure Compiler
+
+
+
+ +

+getCssCompressor

+
+public Compressor getCssCompressor()
+
+
Returns CSS compressor implementation that will be used + to compress inline CSS in HTML. +

+

+
+
+
+ +
Returns:
Compressor implementation that will be used + to compress inline CSS in HTML.
See Also:
YuiCssCompressor, +Yahoo YUI Compressor
+
+
+
+ +

+setCssCompressor

+
+public void setCssCompressor(Compressor cssCompressor)
+
+
Sets CSS compressor implementation that will be used + to compress inline CSS in HTML. + +

HtmlCompressor currently + comes with basic implementation for Yahoo YUI Compressor (called YuiCssCompressor), + but users can also create their own CSS compressors for custom needs. + +

If no compressor is set YuiCssCompressor will be used by default. +

+

+
+
+
+
Parameters:
cssCompressor - Compressor implementation that will be used for inline CSS compression
See Also:
YuiCssCompressor, +Yahoo YUI Compressor
+
+
+
+ +

+isSimpleDoctype

+
+public boolean isSimpleDoctype()
+
+
Returns true if existing DOCTYPE declaration will be replaced with simple declaration. +

+

+
+
+
+ +
Returns:
true if existing DOCTYPE declaration will be replaced with simple declaration.
+
+
+
+ +

+setSimpleDoctype

+
+public void setSimpleDoctype(boolean simpleDoctype)
+
+
If set to true, existing DOCTYPE declaration will be replaced with simple <!DOCTYPE html> declaration. + Default is false. +

+

+
+
+
+
Parameters:
simpleDoctype - set true to replace existing DOCTYPE declaration with <!DOCTYPE html>
+
+
+
+ +

+isRemoveScriptAttributes

+
+public boolean isRemoveScriptAttributes()
+
+
Returns true if unnecessary attributes wil be removed from <script> tags +

+

+
+
+
+ +
Returns:
true if unnecessary attributes wil be removed from <script> tags
+
+
+
+ +

+setRemoveScriptAttributes

+
+public void setRemoveScriptAttributes(boolean removeScriptAttributes)
+
+
If set to true, following attributes will be removed from <script> tags: +
    +
  • type="text/javascript"
  • +
  • type="application/javascript"
  • +
  • language="javascript"
  • +
+ +

Default is false. +

+

+
+
+
+
Parameters:
removeScriptAttributes - set true to remove unnecessary attributes from <script> tags
+
+
+
+ +

+isRemoveStyleAttributes

+
+public boolean isRemoveStyleAttributes()
+
+
Returns true if type="text/style" attributes will be removed from <style> tags +

+

+
+
+
+ +
Returns:
true if type="text/style" attributes will be removed from <style> tags
+
+
+
+ +

+setRemoveStyleAttributes

+
+public void setRemoveStyleAttributes(boolean removeStyleAttributes)
+
+
If set to true, type="text/style" attributes will be removed from <style> tags. Default is false. +

+

+
+
+
+
Parameters:
removeStyleAttributes - set true to remove type="text/style" attributes from <style> tags
+
+
+
+ +

+isRemoveLinkAttributes

+
+public boolean isRemoveLinkAttributes()
+
+
Returns true if unnecessary attributes will be removed from <link> tags +

+

+
+
+
+ +
Returns:
true if unnecessary attributes will be removed from <link> tags
+
+
+
+ +

+setRemoveLinkAttributes

+
+public void setRemoveLinkAttributes(boolean removeLinkAttributes)
+
+
If set to true, following attributes will be removed from <link rel="stylesheet"> and <link rel="alternate stylesheet"> tags: +
    +
  • type="text/css"
  • +
  • type="text/plain"
  • +
+ +

Default is false. +

+

+
+
+
+
Parameters:
removeLinkAttributes - set true to remove unnecessary attributes from <link> tags
+
+
+
+ +

+isRemoveFormAttributes

+
+public boolean isRemoveFormAttributes()
+
+
Returns true if method="get" attributes will be removed from <form> tags +

+

+
+
+
+ +
Returns:
true if method="get" attributes will be removed from <form> tags
+
+
+
+ +

+setRemoveFormAttributes

+
+public void setRemoveFormAttributes(boolean removeFormAttributes)
+
+
If set to true, method="get" attributes will be removed from <form> tags. Default is false. +

+

+
+
+
+
Parameters:
removeFormAttributes - set true to remove method="get" attributes from <form> tags
+
+
+
+ +

+isRemoveInputAttributes

+
+public boolean isRemoveInputAttributes()
+
+
Returns true if type="text" attributes will be removed from <input> tags +

+

+
+
+
+ +
Returns:
true if type="text" attributes will be removed from <input> tags
+
+
+
+ +

+setRemoveInputAttributes

+
+public void setRemoveInputAttributes(boolean removeInputAttributes)
+
+
If set to true, type="text" attributes will be removed from <input> tags. Default is false. +

+

+
+
+
+
Parameters:
removeInputAttributes - set true to remove type="text" attributes from <input> tags
+
+
+
+ +

+isSimpleBooleanAttributes

+
+public boolean isSimpleBooleanAttributes()
+
+
Returns true if boolean attributes will be simplified +

+

+
+
+
+ +
Returns:
true if boolean attributes will be simplified
+
+
+
+ +

+setSimpleBooleanAttributes

+
+public void setSimpleBooleanAttributes(boolean simpleBooleanAttributes)
+
+
If set to true, any values of following boolean attributes will be removed: +
    +
  • checked
  • +
  • selected
  • +
  • disabled
  • +
  • readonly
  • +
+ +

For example, <input readonly="readonly"> would become <input readonly> + +

Default is false. +

+

+
+
+
+
Parameters:
simpleBooleanAttributes - set true to simplify boolean attributes
+
+
+
+ +

+isRemoveJavaScriptProtocol

+
+public boolean isRemoveJavaScriptProtocol()
+
+
Returns true if javascript: pseudo-protocol will be removed from inline event handlers. +

+

+
+
+
+ +
Returns:
true if javascript: pseudo-protocol will be removed from inline event handlers.
+
+
+
+ +

+setRemoveJavaScriptProtocol

+
+public void setRemoveJavaScriptProtocol(boolean removeJavaScriptProtocol)
+
+
If set to true, javascript: pseudo-protocol will be removed from inline event handlers. + +

For example, <a onclick="javascript:alert()"> would become <a onclick="alert()"> + +

Default is false. +

+

+
+
+
+
Parameters:
removeJavaScriptProtocol - set true to remove javascript: pseudo-protocol from inline event handlers.
+
+
+
+ +

+isRemoveHttpProtocol

+
+public boolean isRemoveHttpProtocol()
+
+
Returns true if HTTP protocol will be removed from href, src, cite, and action tag attributes. +

+

+
+
+
+ +
Returns:
true if HTTP protocol will be removed from href, src, cite, and action tag attributes.
+
+
+
+ +

+setRemoveHttpProtocol

+
+public void setRemoveHttpProtocol(boolean removeHttpProtocol)
+
+
If set to true, HTTP protocol will be removed from href, src, cite, and action tag attributes. + URL without a protocol would make a browser use document's current protocol instead. + +

Tags marked with rel="external" will be skipped. + +

For example: +

<a href="http://example.com"> <script src="http://google.com/js.js" rel="external"> +

would become: +

<a href="//example.com"> <script src="http://google.com/js.js" rel="external"> + +

Default is false. +

+

+
+
+
+
Parameters:
removeHttpProtocol - set true to remove HTTP protocol from tag attributes
+
+
+
+ +

+isRemoveHttpsProtocol

+
+public boolean isRemoveHttpsProtocol()
+
+
Returns true if HTTPS protocol will be removed from href, src, cite, and action tag attributes. +

+

+
+
+
+ +
Returns:
true if HTTPS protocol will be removed from href, src, cite, and action tag attributes.
+
+
+
+ +

+setRemoveHttpsProtocol

+
+public void setRemoveHttpsProtocol(boolean removeHttpsProtocol)
+
+
If set to true, HTTPS protocol will be removed from href, src, cite, and action tag attributes. + URL without a protocol would make a browser use document's current protocol instead. + +

Tags marked with rel="external" will be skipped. + +

For example: +

<a href="https://example.com"> <script src="https://google.com/js.js" rel="external"> +

would become: +

<a href="//example.com"> <script src="https://google.com/js.js" rel="external"> + +

Default is false. +

+

+
+
+
+
Parameters:
removeHttpsProtocol - set true to remove HTTP protocol from tag attributes
+
+
+
+ +

+isGenerateStatistics

+
+public boolean isGenerateStatistics()
+
+
Returns true if HTML compression statistics is generated +

+

+
+
+
+ +
Returns:
true if HTML compression statistics is generated
+
+
+
+ +

+setGenerateStatistics

+
+public void setGenerateStatistics(boolean generateStatistics)
+
+
If set to true, HTML compression statistics will be generated. + +

Important: Enabling statistics makes HTML compressor not thread safe. + +

Default is false. +

+

+
+
+
+
Parameters:
generateStatistics - set true to generate HTML compression statistics
See Also:
getStatistics()
+
+
+
+ +

+getStatistics

+
+public HtmlCompressorStatistics getStatistics()
+
+
Returns HtmlCompressorStatistics object containing statistics of the last HTML compression, if enabled. + Should be called after compress(String) +

+

+
+
+
+ +
Returns:
HtmlCompressorStatistics object containing last HTML compression statistics
See Also:
HtmlCompressorStatistics, +setGenerateStatistics(boolean)
+
+
+
+ +

+isPreserveLineBreaks

+
+public boolean isPreserveLineBreaks()
+
+
Returns true if line breaks will be preserved. +

+

+
+
+
+ +
Returns:
true if line breaks will be preserved.
+
+
+
+ +

+setPreserveLineBreaks

+
+public void setPreserveLineBreaks(boolean preserveLineBreaks)
+
+
If set to true, line breaks will be preserved. + +

Default is false. +

+

+
+
+
+
Parameters:
preserveLineBreaks - set true to preserve line breaks
+
+
+
+ +

+getRemoveSurroundingSpaces

+
+public String getRemoveSurroundingSpaces()
+
+
Returns a comma separated list of tags around which spaces will be removed. +

+

+
+
+
+ +
Returns:
a comma separated list of tags around which spaces will be removed.
+
+
+
+ +

+setRemoveSurroundingSpaces

+
+public void setRemoveSurroundingSpaces(String tagList)
+
+
Enables surrounding spaces removal around provided comma separated list of tags. + +

Besides custom defined lists, you can pass one of 3 predefined lists of tags: + BLOCK_TAGS_MIN, + BLOCK_TAGS_MAX, + ALL_TAGS. +

+

+
+
+
+
Parameters:
tagList - a comma separated list of tags around which spaces will be removed
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/HtmlCompressorStatistics.html b/doc/com/googlecode/htmlcompressor/compressor/HtmlCompressorStatistics.html new file mode 100644 index 0000000..d9a38f9 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/HtmlCompressorStatistics.html @@ -0,0 +1,434 @@ + + + + + + +HtmlCompressorStatistics (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.compressor +
+Class HtmlCompressorStatistics

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics
+
+
+
+
public class HtmlCompressorStatistics
extends Object
+ + +

+Class that stores HTML compression statistics +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
HtmlCompressor.getStatistics()
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
HtmlCompressorStatistics() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ HtmlMetricsgetCompressedMetrics() + +
+          Returns metrics of a compressed document
+ HtmlMetricsgetOriginalMetrics() + +
+          Returns metrics of an uncompressed document
+ intgetPreservedSize() + +
+          Returns total size of blocks that were skipped by the compressor + (for example content inside <pre> tags or inside + <script> tags with disabled javascript compression)
+ longgetTime() + +
+          Returns total compression time.
+ voidsetCompressedMetrics(HtmlMetrics compressedMetrics) + +
+           
+ voidsetOriginalMetrics(HtmlMetrics originalMetrics) + +
+           
+ voidsetPreservedSize(int preservedSize) + +
+           
+ voidsetTime(long time) + +
+           
+ StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+HtmlCompressorStatistics

+
+public HtmlCompressorStatistics()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getOriginalMetrics

+
+public HtmlMetrics getOriginalMetrics()
+
+
Returns metrics of an uncompressed document +

+

+ +
Returns:
metrics of an uncompressed document
See Also:
HtmlMetrics
+
+
+
+ +

+setOriginalMetrics

+
+public void setOriginalMetrics(HtmlMetrics originalMetrics)
+
+
+
Parameters:
originalMetrics - the originalMetrics to set
+
+
+
+ +

+getCompressedMetrics

+
+public HtmlMetrics getCompressedMetrics()
+
+
Returns metrics of a compressed document +

+

+ +
Returns:
metrics of a compressed document
See Also:
HtmlMetrics
+
+
+
+ +

+setCompressedMetrics

+
+public void setCompressedMetrics(HtmlMetrics compressedMetrics)
+
+
+
Parameters:
compressedMetrics - the compressedMetrics to set
+
+
+
+ +

+getTime

+
+public long getTime()
+
+
Returns total compression time. + +

Please note that compression performance varies very significantly depending on whether it was + a cold run or not (specifics of Java VM), so for accurate real world results it is recommended + to take measurements accordingly. +

+

+ +
Returns:
the compression time, in milliseconds
+
+
+
+ +

+setTime

+
+public void setTime(long time)
+
+
+
Parameters:
time - the time to set
+
+
+
+ +

+getPreservedSize

+
+public int getPreservedSize()
+
+
Returns total size of blocks that were skipped by the compressor + (for example content inside <pre> tags or inside + <script> tags with disabled javascript compression) +

+

+ +
Returns:
the total size of blocks that were skipped by the compressor, in bytes
+
+
+
+ +

+setPreservedSize

+
+public void setPreservedSize(int preservedSize)
+
+
+
Parameters:
preservedSize - the preservedSize to set
+
+
+
+ +

+toString

+
+public String toString()
+
+
+
Overrides:
toString in class Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/HtmlMetrics.html b/doc/com/googlecode/htmlcompressor/compressor/HtmlMetrics.html new file mode 100644 index 0000000..85f4720 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/HtmlMetrics.html @@ -0,0 +1,467 @@ + + + + + + +HtmlMetrics (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.compressor +
+Class HtmlMetrics

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.compressor.HtmlMetrics
+
+
+
+
public class HtmlMetrics
extends Object
+ + +

+Class that stores metrics about HTML documents. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
HtmlMetrics() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intgetEmptyChars() + +
+          Returns number of empty characters (spaces, tabs, end of lines) in a document
+ intgetFilesize() + +
+          Returns total filesize of a document
+ intgetInlineEventSize() + +
+          Returns total size of inline event handlers (onclick, etc)
+ intgetInlineScriptSize() + +
+          Returns total size of inline <script> tags
+ intgetInlineStyleSize() + +
+          Returns total size of inline <style> tags
+ voidsetEmptyChars(int emptyChars) + +
+           
+ voidsetFilesize(int filesize) + +
+           
+ voidsetInlineEventSize(int inlineEventSize) + +
+           
+ voidsetInlineScriptSize(int inlineScriptSize) + +
+           
+ voidsetInlineStyleSize(int inlineStyleSize) + +
+           
+ StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+HtmlMetrics

+
+public HtmlMetrics()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getFilesize

+
+public int getFilesize()
+
+
Returns total filesize of a document +

+

+ +
Returns:
total filesize of a document, in bytes
+
+
+
+ +

+setFilesize

+
+public void setFilesize(int filesize)
+
+
+
Parameters:
filesize - the filesize to set
+
+
+
+ +

+getEmptyChars

+
+public int getEmptyChars()
+
+
Returns number of empty characters (spaces, tabs, end of lines) in a document +

+

+ +
Returns:
number of empty characters in a document
+
+
+
+ +

+setEmptyChars

+
+public void setEmptyChars(int emptyChars)
+
+
+
Parameters:
emptyChars - the emptyChars to set
+
+
+
+ +

+getInlineScriptSize

+
+public int getInlineScriptSize()
+
+
Returns total size of inline <script> tags +

+

+ +
Returns:
total size of inline <script> tags, in bytes
+
+
+
+ +

+setInlineScriptSize

+
+public void setInlineScriptSize(int inlineScriptSize)
+
+
+
Parameters:
inlineScriptSize - the inlineScriptSize to set
+
+
+
+ +

+getInlineStyleSize

+
+public int getInlineStyleSize()
+
+
Returns total size of inline <style> tags +

+

+ +
Returns:
total size of inline <style> tags, in bytes
+
+
+
+ +

+setInlineStyleSize

+
+public void setInlineStyleSize(int inlineStyleSize)
+
+
+
Parameters:
inlineStyleSize - the inlineStyleSize to set
+
+
+
+ +

+getInlineEventSize

+
+public int getInlineEventSize()
+
+
Returns total size of inline event handlers (onclick, etc) +

+

+ +
Returns:
total size of inline event handlers, in bytes
+
+
+
+ +

+setInlineEventSize

+
+public void setInlineEventSize(int inlineEventSize)
+
+
+
Parameters:
inlineEventSize - the inlineEventSize to set
+
+
+
+ +

+toString

+
+public String toString()
+
+
+
Overrides:
toString in class Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/XmlCompressor.html b/doc/com/googlecode/htmlcompressor/compressor/XmlCompressor.html new file mode 100644 index 0000000..6fe4f83 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/XmlCompressor.html @@ -0,0 +1,419 @@ + + + + + + +XmlCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.compressor +
+Class XmlCompressor

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.compressor.XmlCompressor
+
+
+
All Implemented Interfaces:
Compressor
+
+
+
+
public class XmlCompressor
extends 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
+
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
XmlCompressor() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Stringcompress(String xml) + +
+          The main method that compresses given XML source and returns compressed result.
+ booleanisEnabled() + +
+          Returns true if compression is enabled.
+ booleanisRemoveComments() + +
+          Returns true if all XML comments will be removed.
+ booleanisRemoveIntertagSpaces() + +
+          Returns true if all inter-tag whitespace characters will be removed.
+ voidsetEnabled(boolean enabled) + +
+          If set to false all compression will be bypassed.
+ voidsetRemoveComments(boolean removeComments) + +
+          If set to true all XML comments will be removed.
+ voidsetRemoveIntertagSpaces(boolean removeIntertagSpaces) + +
+          If set to true all inter-tag whitespace characters will be removed.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+XmlCompressor

+
+public XmlCompressor()
+
+
+ + + + + + + + +
+Method Detail
+ +

+compress

+
+public String compress(String xml)
+
+
The main method that compresses given XML source and returns compressed result. +

+

+
Specified by:
compress in interface Compressor
+
+
+
Parameters:
xml - XML content to compress +
Returns:
compressed content.
+
+
+
+ +

+isEnabled

+
+public boolean isEnabled()
+
+
Returns true if compression is enabled. +

+

+
+
+
+ +
Returns:
true if compression is enabled.
+
+
+
+ +

+setEnabled

+
+public void setEnabled(boolean enabled)
+
+
If set to false all compression will be bypassed. Might be useful for testing purposes. + Default is true. +

+

+
+
+
+
Parameters:
enabled - set false to bypass all compression
+
+
+
+ +

+isRemoveComments

+
+public boolean isRemoveComments()
+
+
Returns true if all XML comments will be removed. +

+

+
+
+
+ +
Returns:
true if all XML comments will be removed
+
+
+
+ +

+setRemoveComments

+
+public void setRemoveComments(boolean removeComments)
+
+
If set to true all XML comments will be removed. + Default is true. +

+

+
+
+
+
Parameters:
removeComments - set true to remove all XML comments
+
+
+
+ +

+isRemoveIntertagSpaces

+
+public boolean isRemoveIntertagSpaces()
+
+
Returns true 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 to true all inter-tag whitespace characters will be removed. + Default is true. +

+

+
+
+
+
Parameters:
removeIntertagSpaces - set true to remove all inter-tag whitespace characters
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/YuiCssCompressor.html b/doc/com/googlecode/htmlcompressor/compressor/YuiCssCompressor.html new file mode 100644 index 0000000..6f3c261 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/YuiCssCompressor.html @@ -0,0 +1,328 @@ + + + + + + +YuiCssCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.compressor +
+Class YuiCssCompressor

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.compressor.YuiCssCompressor
+
+
+
All Implemented Interfaces:
Compressor
+
+
+
+
public class YuiCssCompressor
extends Object
implements Compressor
+ + +

+Basic CSS compressor implementation using Yahoo YUI Compressor + that could be used by HtmlCompressor for inline CSS compression. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
HtmlCompressor.setCssCompressor(Compressor), +Yahoo YUI Compressor
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
YuiCssCompressor() + +
+           
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Stringcompress(String source) + +
+          The main method that compresses the given source and returns a compressed result.
+ intgetLineBreak() + +
+          Returns number of symbols per line Yahoo YUI Compressor + will use during CSS compression.
+ voidsetLineBreak(int lineBreak) + +
+          Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during CSS compression.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+YuiCssCompressor

+
+public YuiCssCompressor()
+
+
+ + + + + + + + +
+Method Detail
+ +

+compress

+
+public String compress(String source)
+
+
Description copied from interface: Compressor
+
The main method that compresses the given source and returns a compressed result. +

+

+
Specified by:
compress in interface Compressor
+
+
+
Parameters:
source - The source to compress. +
Returns:
Compressed result.
+
+
+
+ +

+getLineBreak

+
+public int getLineBreak()
+
+
Returns number of symbols per line Yahoo YUI Compressor + will use during CSS compression. + This corresponds to --line-break command line option. +

+

+
+
+
+ +
Returns:
line-break parameter value used for CSS compression.
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+setLineBreak

+
+public void setLineBreak(int lineBreak)
+
+
Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during CSS compression. This corresponds to + --line-break command line option. + This option has effect only if CSS compression is enabled. + Default is -1 to disable line breaks. +

+

+
+
+
+
Parameters:
lineBreak - set number of symbols per line
See Also:
Yahoo YUI Compressor
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/YuiJavaScriptCompressor.DefaultErrorReporter.html b/doc/com/googlecode/htmlcompressor/compressor/YuiJavaScriptCompressor.DefaultErrorReporter.html new file mode 100644 index 0000000..e6ff489 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/YuiJavaScriptCompressor.DefaultErrorReporter.html @@ -0,0 +1,338 @@ + + + + + + +YuiJavaScriptCompressor.DefaultErrorReporter (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.compressor +
+Class YuiJavaScriptCompressor.DefaultErrorReporter

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.DefaultErrorReporter
+
+
+
All Implemented Interfaces:
org.mozilla.javascript.ErrorReporter
+
+
+
Enclosing class:
YuiJavaScriptCompressor
+
+
+
+
public static class YuiJavaScriptCompressor.DefaultErrorReporter
extends Object
implements org.mozilla.javascript.ErrorReporter
+ + +

+Default ErrorReporter implementation that uses System.err + stream for error reporting. Used by YUI Compressor to log errors during JavaScript compression. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
Yahoo YUI Compressor, +ErrorReporter Interface
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
YuiJavaScriptCompressor.DefaultErrorReporter() + +
+           
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voiderror(String message, + String sourceName, + int line, + String lineSource, + int lineOffset) + +
+           
+ org.mozilla.javascript.EvaluatorExceptionruntimeError(String message, + String sourceName, + int line, + String lineSource, + int lineOffset) + +
+           
+ voidwarning(String message, + String sourceName, + int line, + String lineSource, + int lineOffset) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+YuiJavaScriptCompressor.DefaultErrorReporter

+
+public YuiJavaScriptCompressor.DefaultErrorReporter()
+
+
+ + + + + + + + +
+Method Detail
+ +

+warning

+
+public void warning(String message,
+                    String sourceName,
+                    int line,
+                    String lineSource,
+                    int lineOffset)
+
+
+
Specified by:
warning in interface org.mozilla.javascript.ErrorReporter
+
+
+
+
+
+
+ +

+error

+
+public void error(String message,
+                  String sourceName,
+                  int line,
+                  String lineSource,
+                  int lineOffset)
+
+
+
Specified by:
error in interface org.mozilla.javascript.ErrorReporter
+
+
+
+
+
+
+ +

+runtimeError

+
+public org.mozilla.javascript.EvaluatorException runtimeError(String message,
+                                                              String sourceName,
+                                                              int line,
+                                                              String lineSource,
+                                                              int lineOffset)
+
+
+
Specified by:
runtimeError in interface org.mozilla.javascript.ErrorReporter
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/YuiJavaScriptCompressor.html b/doc/com/googlecode/htmlcompressor/compressor/YuiJavaScriptCompressor.html new file mode 100644 index 0000000..486a5e0 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/YuiJavaScriptCompressor.html @@ -0,0 +1,576 @@ + + + + + + +YuiJavaScriptCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.compressor +
+Class YuiJavaScriptCompressor

+
+java.lang.Object
+  extended by com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor
+
+
+
All Implemented Interfaces:
Compressor
+
+
+
+
public class YuiJavaScriptCompressor
extends Object
implements Compressor
+ + +

+Basic JavaScript compressor implementation using Yahoo YUI Compressor + that could be used by HtmlCompressor for inline JavaScript compression. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
HtmlCompressor.setJavaScriptCompressor(Compressor), +Yahoo YUI Compressor
+
+ +

+ + + + + + + + + + + +
+Nested Class Summary
+static classYuiJavaScriptCompressor.DefaultErrorReporter + +
+          Default ErrorReporter implementation that uses System.err + stream for error reporting.
+  + + + + + + + + + + +
+Constructor Summary
YuiJavaScriptCompressor() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Stringcompress(String source) + +
+          The main method that compresses the given source and returns a compressed result.
+ org.mozilla.javascript.ErrorReportergetErrorReporter() + +
+          Returns ErrorReporter used by YUI Compressor to log error messages + during JavasSript compression
+ intgetLineBreak() + +
+          Returns number of symbols per line Yahoo YUI Compressor + will use during JavaScript compression.
+ booleanisDisableOptimizations() + +
+          Returns true if Yahoo YUI Compressor + will disable all the built-in micro optimizations during JavaScript compression.
+ booleanisNoMunge() + +
+          Returns true if Yahoo YUI Compressor + will only minify javascript without obfuscating local symbols.
+ booleanisPreserveAllSemiColons() + +
+          Returns true if Yahoo YUI Compressor + will preserve unnecessary semicolons during JavaScript compression.
+ voidsetDisableOptimizations(boolean disableOptimizations) + +
+          Tells Yahoo YUI Compressor to disable all the built-in micro optimizations + during JavaScript compression.
+ voidsetErrorReporter(org.mozilla.javascript.ErrorReporter errorReporter) + +
+          Sets ErrorReporter that YUI Compressor will use for reporting errors during + JavaScript compression.
+ voidsetLineBreak(int lineBreak) + +
+          Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during JavaScript compression.
+ voidsetNoMunge(boolean noMunge) + +
+          Tells Yahoo YUI Compressor to only minify javascript without obfuscating + local symbols.
+ voidsetPreserveAllSemiColons(boolean preserveAllSemiColons) + +
+          Tells Yahoo YUI Compressor to preserve unnecessary semicolons + during JavaScript compression.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+YuiJavaScriptCompressor

+
+public YuiJavaScriptCompressor()
+
+
+ + + + + + + + +
+Method Detail
+ +

+compress

+
+public String compress(String source)
+
+
Description copied from interface: Compressor
+
The main method that compresses the given source and returns a compressed result. +

+

+
Specified by:
compress in interface Compressor
+
+
+
Parameters:
source - The source to compress. +
Returns:
Compressed result.
+
+
+
+ +

+isNoMunge

+
+public boolean isNoMunge()
+
+
Returns true if Yahoo YUI Compressor + will only minify javascript without obfuscating local symbols. + This corresponds to --nomunge command line option. +

+

+
+
+
+ +
Returns:
nomunge parameter value used for JavaScript compression.
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+setNoMunge

+
+public void setNoMunge(boolean noMunge)
+
+
Tells Yahoo YUI Compressor to only minify javascript without obfuscating + local symbols. This corresponds to --nomunge command line option. + This option has effect only if JavaScript compression is enabled. + Default is false. +

+

+
+
+
+
Parameters:
noMunge - set true to enable nomunge mode
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+isPreserveAllSemiColons

+
+public boolean isPreserveAllSemiColons()
+
+
Returns true if Yahoo YUI Compressor + will preserve unnecessary semicolons during JavaScript compression. + This corresponds to --preserve-semi command line option. +

+

+
+
+
+ +
Returns:
preserve-semi parameter value used for JavaScript compression.
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+setPreserveAllSemiColons

+
+public void setPreserveAllSemiColons(boolean preserveAllSemiColons)
+
+
Tells Yahoo YUI Compressor to preserve unnecessary semicolons + during JavaScript compression. This corresponds to + --preserve-semi command line option. + This option has effect only if JavaScript compression is enabled. + Default is false. +

+

+
+
+
+
Parameters:
preserveAllSemiColons - set true to enable preserve-semi mode
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+isDisableOptimizations

+
+public boolean isDisableOptimizations()
+
+
Returns true if Yahoo YUI Compressor + will disable all the built-in micro optimizations during JavaScript compression. + This corresponds to --disable-optimizations command line option. +

+

+
+
+
+ +
Returns:
disable-optimizations parameter value used for JavaScript compression.
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+setDisableOptimizations

+
+public void setDisableOptimizations(boolean disableOptimizations)
+
+
Tells Yahoo YUI Compressor to disable all the built-in micro optimizations + during JavaScript compression. This corresponds to + --disable-optimizations command line option. + This option has effect only if JavaScript compression is enabled. + Default is false. +

+

+
+
+
+
Parameters:
disableOptimizations - set true to enable + disable-optimizations mode
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+getLineBreak

+
+public int getLineBreak()
+
+
Returns number of symbols per line Yahoo YUI Compressor + will use during JavaScript compression. + This corresponds to --line-break command line option. +

+

+
+
+
+ +
Returns:
line-break parameter value used for JavaScript compression.
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+setLineBreak

+
+public void setLineBreak(int lineBreak)
+
+
Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during JavaScript compression. This corresponds to + --line-break command line option. + This option has effect only if JavaScript compression is enabled. + Default is -1 to disable line breaks. +

+

+
+
+
+
Parameters:
lineBreak - set number of symbols per line
See Also:
Yahoo YUI Compressor
+
+
+
+ +

+getErrorReporter

+
+public org.mozilla.javascript.ErrorReporter getErrorReporter()
+
+
Returns ErrorReporter used by YUI Compressor to log error messages + during JavasSript compression +

+

+
+
+
+ +
Returns:
ErrorReporter used by YUI Compressor to log error messages + during JavasSript compression
See Also:
Yahoo YUI Compressor, +Error Reporter Interface
+
+
+
+ +

+setErrorReporter

+
+public void setErrorReporter(org.mozilla.javascript.ErrorReporter errorReporter)
+
+
Sets ErrorReporter that YUI Compressor will use for reporting errors during + JavaScript compression. If no ErrorReporter was provided + YuiJavaScriptCompressor.DefaultErrorReporter will be used + which reports errors to System.err stream. +

+

+
+
+
+
Parameters:
errorReporter - ErrorReporter that will be used by YUI Compressor
See Also:
YuiJavaScriptCompressor.DefaultErrorReporter, +Yahoo YUI Compressor, +ErrorReporter Interface
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/class-use/ClosureJavaScriptCompressor.html b/doc/com/googlecode/htmlcompressor/compressor/class-use/ClosureJavaScriptCompressor.html new file mode 100644 index 0000000..26124bf --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/class-use/ClosureJavaScriptCompressor.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor

+
+No usage of com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/class-use/Compressor.html b/doc/com/googlecode/htmlcompressor/compressor/class-use/Compressor.html new file mode 100644 index 0000000..3398d90 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/class-use/Compressor.html @@ -0,0 +1,269 @@ + + + + + + +Uses of Interface com.googlecode.htmlcompressor.compressor.Compressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Interface
com.googlecode.htmlcompressor.compressor.Compressor

+
+ + + + + + + + + +
+Packages that use Compressor
com.googlecode.htmlcompressor.compressor  
+  +

+ + + + + +
+Uses of Compressor in com.googlecode.htmlcompressor.compressor
+  +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
Classes in com.googlecode.htmlcompressor.compressor that implement Compressor
+ classClosureJavaScriptCompressor + +
+          Basic JavaScript compressor implementation using Google Closure Compiler + that could be used by HtmlCompressor for inline JavaScript compression.
+ classHtmlCompressor + +
+          Class that compresses given HTML source by removing comments, extra spaces and + line breaks while preserving content within <pre>, <textarea>, <script> + and <style> tags.
+ classXmlCompressor + +
+          Class that compresses given XML source by removing comments, extra spaces and + line breaks while preserving content within CDATA blocks.
+ classYuiCssCompressor + +
+          Basic CSS compressor implementation using Yahoo YUI Compressor + that could be used by HtmlCompressor for inline CSS compression.
+ classYuiJavaScriptCompressor + +
+          Basic JavaScript compressor implementation using Yahoo YUI Compressor + that could be used by HtmlCompressor for inline JavaScript compression.
+  +

+ + + + + + + + + + + + + +
Methods in com.googlecode.htmlcompressor.compressor that return Compressor
+ CompressorHtmlCompressor.getCssCompressor() + +
+          Returns CSS compressor implementation that will be used + to compress inline CSS in HTML.
+ CompressorHtmlCompressor.getJavaScriptCompressor() + +
+          Returns JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML.
+  +

+ + + + + + + + + + + + + +
Methods in com.googlecode.htmlcompressor.compressor with parameters of type Compressor
+ voidHtmlCompressor.setCssCompressor(Compressor cssCompressor) + +
+          Sets CSS compressor implementation that will be used + to compress inline CSS in HTML.
+ voidHtmlCompressor.setJavaScriptCompressor(Compressor javaScriptCompressor) + +
+          Sets JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML.
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/class-use/HtmlCompressor.html b/doc/com/googlecode/htmlcompressor/compressor/class-use/HtmlCompressor.html new file mode 100644 index 0000000..d18af4f --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/class-use/HtmlCompressor.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.compressor.HtmlCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.compressor.HtmlCompressor

+
+No usage of com.googlecode.htmlcompressor.compressor.HtmlCompressor +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/class-use/HtmlCompressorStatistics.html b/doc/com/googlecode/htmlcompressor/compressor/class-use/HtmlCompressorStatistics.html new file mode 100644 index 0000000..3b9ecf6 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/class-use/HtmlCompressorStatistics.html @@ -0,0 +1,179 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics

+
+ + + + + + + + + +
+Packages that use HtmlCompressorStatistics
com.googlecode.htmlcompressor.compressor  
+  +

+ + + + + +
+Uses of HtmlCompressorStatistics in com.googlecode.htmlcompressor.compressor
+  +

+ + + + + + + + + +
Methods in com.googlecode.htmlcompressor.compressor that return HtmlCompressorStatistics
+ HtmlCompressorStatisticsHtmlCompressor.getStatistics() + +
+          Returns HtmlCompressorStatistics object containing statistics of the last HTML compression, if enabled.
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/class-use/HtmlMetrics.html b/doc/com/googlecode/htmlcompressor/compressor/class-use/HtmlMetrics.html new file mode 100644 index 0000000..8225cf6 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/class-use/HtmlMetrics.html @@ -0,0 +1,211 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.compressor.HtmlMetrics (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.compressor.HtmlMetrics

+
+ + + + + + + + + +
+Packages that use HtmlMetrics
com.googlecode.htmlcompressor.compressor  
+  +

+ + + + + +
+Uses of HtmlMetrics in com.googlecode.htmlcompressor.compressor
+  +

+ + + + + + + + + + + + + +
Methods in com.googlecode.htmlcompressor.compressor that return HtmlMetrics
+ HtmlMetricsHtmlCompressorStatistics.getCompressedMetrics() + +
+          Returns metrics of a compressed document
+ HtmlMetricsHtmlCompressorStatistics.getOriginalMetrics() + +
+          Returns metrics of an uncompressed document
+  +

+ + + + + + + + + + + + + +
Methods in com.googlecode.htmlcompressor.compressor with parameters of type HtmlMetrics
+ voidHtmlCompressorStatistics.setCompressedMetrics(HtmlMetrics compressedMetrics) + +
+           
+ voidHtmlCompressorStatistics.setOriginalMetrics(HtmlMetrics originalMetrics) + +
+           
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/class-use/XmlCompressor.html b/doc/com/googlecode/htmlcompressor/compressor/class-use/XmlCompressor.html new file mode 100644 index 0000000..07cfcc5 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/class-use/XmlCompressor.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.compressor.XmlCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.compressor.XmlCompressor

+
+No usage of com.googlecode.htmlcompressor.compressor.XmlCompressor +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/class-use/YuiCssCompressor.html b/doc/com/googlecode/htmlcompressor/compressor/class-use/YuiCssCompressor.html new file mode 100644 index 0000000..03cc229 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/class-use/YuiCssCompressor.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.compressor.YuiCssCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.compressor.YuiCssCompressor

+
+No usage of com.googlecode.htmlcompressor.compressor.YuiCssCompressor +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/class-use/YuiJavaScriptCompressor.DefaultErrorReporter.html b/doc/com/googlecode/htmlcompressor/compressor/class-use/YuiJavaScriptCompressor.DefaultErrorReporter.html new file mode 100644 index 0000000..f2c0fa8 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/class-use/YuiJavaScriptCompressor.DefaultErrorReporter.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.DefaultErrorReporter (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.DefaultErrorReporter

+
+No usage of com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.DefaultErrorReporter +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/class-use/YuiJavaScriptCompressor.html b/doc/com/googlecode/htmlcompressor/compressor/class-use/YuiJavaScriptCompressor.html new file mode 100644 index 0000000..4e0f43a --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/class-use/YuiJavaScriptCompressor.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor

+
+No usage of com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/package-frame.html b/doc/com/googlecode/htmlcompressor/compressor/package-frame.html new file mode 100644 index 0000000..d449597 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/package-frame.html @@ -0,0 +1,56 @@ + + + + + + +com.googlecode.htmlcompressor.compressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + +com.googlecode.htmlcompressor.compressor + + + + +
+Interfaces  + +
+Compressor
+ + + + + + +
+Classes  + +
+ClosureJavaScriptCompressor +
+HtmlCompressor +
+HtmlCompressorStatistics +
+HtmlMetrics +
+XmlCompressor +
+YuiCssCompressor +
+YuiJavaScriptCompressor +
+YuiJavaScriptCompressor.DefaultErrorReporter
+ + + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/package-summary.html b/doc/com/googlecode/htmlcompressor/compressor/package-summary.html new file mode 100644 index 0000000..250ec90 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/package-summary.html @@ -0,0 +1,205 @@ + + + + + + +com.googlecode.htmlcompressor.compressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.googlecode.htmlcompressor.compressor +

+ + + + + + + + + +
+Interface Summary
CompressorInterface describing compressor classes.
+  + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class Summary
ClosureJavaScriptCompressorBasic JavaScript compressor implementation using Google Closure Compiler + that could be used by HtmlCompressor for inline JavaScript compression.
HtmlCompressorClass that compresses given HTML source by removing comments, extra spaces and + line breaks while preserving content within <pre>, <textarea>, <script> + and <style> tags.
HtmlCompressorStatisticsClass that stores HTML compression statistics
HtmlMetricsClass that stores metrics about HTML documents.
XmlCompressorClass that compresses given XML source by removing comments, extra spaces and + line breaks while preserving content within CDATA blocks.
YuiCssCompressorBasic CSS compressor implementation using Yahoo YUI Compressor + that could be used by HtmlCompressor for inline CSS compression.
YuiJavaScriptCompressorBasic JavaScript compressor implementation using Yahoo YUI Compressor + that could be used by HtmlCompressor for inline JavaScript compression.
YuiJavaScriptCompressor.DefaultErrorReporterDefault ErrorReporter implementation that uses System.err + stream for error reporting.
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/package-tree.html b/doc/com/googlecode/htmlcompressor/compressor/package-tree.html new file mode 100644 index 0000000..234684b --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/package-tree.html @@ -0,0 +1,163 @@ + + + + + + +com.googlecode.htmlcompressor.compressor Class Hierarchy (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.googlecode.htmlcompressor.compressor +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +

+Interface Hierarchy +

+
    +
  • com.googlecode.htmlcompressor.compressor.Compressor
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/compressor/package-use.html b/doc/com/googlecode/htmlcompressor/compressor/package-use.html new file mode 100644 index 0000000..bcfd96c --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/compressor/package-use.html @@ -0,0 +1,181 @@ + + + + + + +Uses of Package com.googlecode.htmlcompressor.compressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Package
com.googlecode.htmlcompressor.compressor

+
+ + + + + + + + + +
+Packages that use com.googlecode.htmlcompressor.compressor
com.googlecode.htmlcompressor.compressor  
+  +

+ + + + + + + + + + + + + + +
+Classes in com.googlecode.htmlcompressor.compressor used by com.googlecode.htmlcompressor.compressor
Compressor + +
+          Interface describing compressor classes.
HtmlCompressorStatistics + +
+          Class that stores HTML compression statistics
HtmlMetrics + +
+          Class that stores metrics about HTML documents.
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/package-frame.html b/doc/com/googlecode/htmlcompressor/package-frame.html new file mode 100644 index 0000000..299c9b7 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/package-frame.html @@ -0,0 +1,31 @@ + + + + + + +com.googlecode.htmlcompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + +com.googlecode.htmlcompressor + + + + +
+Classes  + +
+CmdLineCompressor
+ + + + diff --git a/doc/com/googlecode/htmlcompressor/package-summary.html b/doc/com/googlecode/htmlcompressor/package-summary.html new file mode 100644 index 0000000..e2730fd --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/package-summary.html @@ -0,0 +1,156 @@ + + + + + + +com.googlecode.htmlcompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.googlecode.htmlcompressor +

+ + + + + + + + + +
+Class Summary
CmdLineCompressorWrapper for HTML and XML compressor classes that allows using them from a command line.
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/package-tree.html b/doc/com/googlecode/htmlcompressor/package-tree.html new file mode 100644 index 0000000..061f0f2 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/package-tree.html @@ -0,0 +1,152 @@ + + + + + + +com.googlecode.htmlcompressor Class Hierarchy (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.googlecode.htmlcompressor +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/package-use.html b/doc/com/googlecode/htmlcompressor/package-use.html new file mode 100644 index 0000000..4bfdbfa --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/package-use.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Package com.googlecode.htmlcompressor (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Package
com.googlecode.htmlcompressor

+
+No usage of com.googlecode.htmlcompressor +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/CssCompressorTag.html b/doc/com/googlecode/htmlcompressor/taglib/CssCompressorTag.html new file mode 100644 index 0000000..101bd41 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/CssCompressorTag.html @@ -0,0 +1,374 @@ + + + + + + +CssCompressorTag (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.taglib +
+Class CssCompressorTag

+
+java.lang.Object
+  extended by javax.servlet.jsp.tagext.TagSupport
+      extended by javax.servlet.jsp.tagext.BodyTagSupport
+          extended by com.googlecode.htmlcompressor.taglib.CssCompressorTag
+
+
+
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag
+
+
+
+
public class CssCompressorTag
extends javax.servlet.jsp.tagext.BodyTagSupport
+ + +

+JSP tag that compresses an CSS content within <compress:css> using Yahoo YUI Compressor. + All CSS-related properties from HtmlCompressor are supported. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
HtmlCompressor, +Yahoo YUI Compressor, +Serialized Form
+
+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
+  + + + + + + + + + + +
+Constructor Summary
CssCompressorTag() + +
+           
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intdoEndTag() + +
+           
+ voidsetEnabled(boolean enabled) + +
+           
+ voidsetYuiCssLineBreak(int yuiCssLineBreak) + +
+           
+ + + + + + + +
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, doStartTag, getBodyContent, getPreviousOut, release, setBodyContent
+ + + + + + + +
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+ + + + + + + +
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+CssCompressorTag

+
+public CssCompressorTag()
+
+
+ + + + + + + + +
+Method Detail
+ +

+doEndTag

+
+public int doEndTag()
+             throws javax.servlet.jsp.JspException
+
+
+
Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
+
+
+ +
Throws: +
javax.servlet.jsp.JspException
+
+
+
+ +

+setYuiCssLineBreak

+
+public void setYuiCssLineBreak(int yuiCssLineBreak)
+
+
+
See Also:
HtmlCompressor.setYuiCssLineBreak(int)
+
+
+
+ +

+setEnabled

+
+public void setEnabled(boolean enabled)
+
+
+
See Also:
HtmlCompressor.setEnabled(boolean)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/HtmlCompressorTag.html b/doc/com/googlecode/htmlcompressor/taglib/HtmlCompressorTag.html new file mode 100644 index 0000000..4f49cf9 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/HtmlCompressorTag.html @@ -0,0 +1,822 @@ + + + + + + +HtmlCompressorTag (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.taglib +
+Class HtmlCompressorTag

+
+java.lang.Object
+  extended by javax.servlet.jsp.tagext.TagSupport
+      extended by javax.servlet.jsp.tagext.BodyTagSupport
+          extended by com.googlecode.htmlcompressor.taglib.HtmlCompressorTag
+
+
+
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag
+
+
+
+
public class HtmlCompressorTag
extends javax.servlet.jsp.tagext.BodyTagSupport
+ + +

+JSP tag that compresses an HTML content within <compress:html>. + Compression parameters are set by default (no JavaScript and CSS compression). +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
HtmlCompressor, +Serialized Form
+
+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
+  + + + + + + + + + + +
+Constructor Summary
HtmlCompressorTag() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intdoEndTag() + +
+           
+ voidsetClosureOptLevel(String closureOptLevel) + +
+          Sets level of optimization if Google Closure Compiler is used + for compressing inline JavaScript.
+ voidsetCompressCss(boolean compressCss) + +
+           
+ voidsetCompressJavaScript(boolean compressJavaScript) + +
+           
+ voidsetEnabled(boolean enabled) + +
+           
+ voidsetJsCompressor(String jsCompressor) + +
+          Sets JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML.
+ voidsetPreserveLineBreaks(boolean preserveLineBreaks) + +
+           
+ voidsetRemoveComments(boolean removeComments) + +
+           
+ voidsetRemoveFormAttributes(boolean removeFormAttributes) + +
+           
+ voidsetRemoveHttpProtocol(boolean removeHttpProtocol) + +
+           
+ voidsetRemoveHttpsProtocol(boolean removeHttpsProtocol) + +
+           
+ voidsetRemoveInputAttributes(boolean removeInputAttributes) + +
+           
+ voidsetRemoveIntertagSpaces(boolean removeIntertagSpaces) + +
+           
+ voidsetRemoveJavaScriptProtocol(boolean removeJavaScriptProtocol) + +
+           
+ voidsetRemoveLinkAttributes(boolean removeLinkAttributes) + +
+           
+ voidsetRemoveMultiSpaces(boolean removeMultiSpaces) + +
+           
+ voidsetRemoveQuotes(boolean removeQuotes) + +
+           
+ voidsetRemoveScriptAttributes(boolean removeScriptAttributes) + +
+           
+ voidsetRemoveStyleAttributes(boolean removeStyleAttributes) + +
+           
+ voidsetSimpleBooleanAttributes(boolean simpleBooleanAttributes) + +
+           
+ voidsetSimpleDoctype(boolean simpleDoctype) + +
+           
+ voidsetYuiCssLineBreak(int yuiCssLineBreak) + +
+           
+ voidsetYuiJsDisableOptimizations(boolean yuiJsDisableOptimizations) + +
+           
+ voidsetYuiJsLineBreak(int yuiJsLineBreak) + +
+           
+ voidsetYuiJsNoMunge(boolean yuiJsNoMunge) + +
+           
+ voidsetYuiJsPreserveAllSemiColons(boolean yuiJsPreserveAllSemiColons) + +
+           
+ + + + + + + +
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, doStartTag, getBodyContent, getPreviousOut, release, setBodyContent
+ + + + + + + +
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+ + + + + + + +
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+HtmlCompressorTag

+
+public HtmlCompressorTag()
+
+
+ + + + + + + + +
+Method Detail
+ +

+doEndTag

+
+public int doEndTag()
+             throws javax.servlet.jsp.JspException
+
+
+
Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
+
+
+ +
Throws: +
javax.servlet.jsp.JspException
+
+
+
+ +

+setCompressJavaScript

+
+public void setCompressJavaScript(boolean compressJavaScript)
+
+
+
See Also:
HtmlCompressor.setCompressJavaScript(boolean)
+
+
+
+ +

+setCompressCss

+
+public void setCompressCss(boolean compressCss)
+
+
+
See Also:
HtmlCompressor.setCompressCss(boolean)
+
+
+
+ +

+setYuiJsNoMunge

+
+public void setYuiJsNoMunge(boolean yuiJsNoMunge)
+
+
+
See Also:
HtmlCompressor.setYuiJsNoMunge(boolean)
+
+
+
+ +

+setYuiJsPreserveAllSemiColons

+
+public void setYuiJsPreserveAllSemiColons(boolean yuiJsPreserveAllSemiColons)
+
+
+
See Also:
HtmlCompressor.setYuiJsPreserveAllSemiColons(boolean)
+
+
+
+ +

+setYuiJsDisableOptimizations

+
+public void setYuiJsDisableOptimizations(boolean yuiJsDisableOptimizations)
+
+
+
See Also:
HtmlCompressor.setYuiJsDisableOptimizations(boolean)
+
+
+
+ +

+setYuiJsLineBreak

+
+public void setYuiJsLineBreak(int yuiJsLineBreak)
+
+
+
See Also:
HtmlCompressor.setYuiJsLineBreak(int)
+
+
+
+ +

+setYuiCssLineBreak

+
+public void setYuiCssLineBreak(int yuiCssLineBreak)
+
+
+
See Also:
HtmlCompressor.setYuiCssLineBreak(int)
+
+
+
+ +

+setRemoveQuotes

+
+public void setRemoveQuotes(boolean removeQuotes)
+
+
+
See Also:
HtmlCompressor.setRemoveQuotes(boolean)
+
+
+
+ +

+setPreserveLineBreaks

+
+public void setPreserveLineBreaks(boolean preserveLineBreaks)
+
+
+
See Also:
HtmlCompressor.setPreserveLineBreaks(boolean)
+
+
+
+ +

+setEnabled

+
+public void setEnabled(boolean enabled)
+
+
+
See Also:
HtmlCompressor.setEnabled(boolean)
+
+
+
+ +

+setRemoveComments

+
+public void setRemoveComments(boolean removeComments)
+
+
+
See Also:
HtmlCompressor.setRemoveComments(boolean)
+
+
+
+ +

+setRemoveMultiSpaces

+
+public void setRemoveMultiSpaces(boolean removeMultiSpaces)
+
+
+
See Also:
HtmlCompressor.setRemoveMultiSpaces(boolean)
+
+
+
+ +

+setRemoveIntertagSpaces

+
+public void setRemoveIntertagSpaces(boolean removeIntertagSpaces)
+
+
+
See Also:
HtmlCompressor.setRemoveIntertagSpaces(boolean)
+
+
+
+ +

+setJsCompressor

+
+public void setJsCompressor(String jsCompressor)
+
+
Sets JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML. +

+

+
Parameters:
jsCompressor - Could be either "yui" for using YuiJavaScriptCompressor (used by default if none provided) or + "closure" for using ClosureJavaScriptCompressor
See Also:
YuiJavaScriptCompressor, +ClosureJavaScriptCompressor, +Yahoo YUI Compressor, +Google Closure Compiler
+
+
+
+ +

+setClosureOptLevel

+
+public void setClosureOptLevel(String closureOptLevel)
+
+
Sets level of optimization if Google Closure Compiler is used + for compressing inline JavaScript. +

+

+
Parameters:
closureOptLevel - Could be either "simple" (used by default), "whitespace" or "advanced"
See Also:
ClosureJavaScriptCompressor.setCompilationLevel(CompilationLevel)
+
+
+
+ +

+setSimpleDoctype

+
+public void setSimpleDoctype(boolean simpleDoctype)
+
+
+
See Also:
HtmlCompressor.setSimpleDoctype(boolean)
+
+
+
+ +

+setRemoveScriptAttributes

+
+public void setRemoveScriptAttributes(boolean removeScriptAttributes)
+
+
+
See Also:
HtmlCompressor.setRemoveScriptAttributes(boolean)
+
+
+
+ +

+setRemoveStyleAttributes

+
+public void setRemoveStyleAttributes(boolean removeStyleAttributes)
+
+
+
See Also:
HtmlCompressor.setRemoveStyleAttributes(boolean)
+
+
+
+ +

+setRemoveLinkAttributes

+
+public void setRemoveLinkAttributes(boolean removeLinkAttributes)
+
+
+
See Also:
HtmlCompressor.setRemoveLinkAttributes(boolean)
+
+
+
+ +

+setRemoveFormAttributes

+
+public void setRemoveFormAttributes(boolean removeFormAttributes)
+
+
+
See Also:
HtmlCompressor.setRemoveFormAttributes(boolean)
+
+
+
+ +

+setRemoveInputAttributes

+
+public void setRemoveInputAttributes(boolean removeInputAttributes)
+
+
+
See Also:
HtmlCompressor.setRemoveInputAttributes(boolean)
+
+
+
+ +

+setSimpleBooleanAttributes

+
+public void setSimpleBooleanAttributes(boolean simpleBooleanAttributes)
+
+
+
See Also:
HtmlCompressor.setSimpleBooleanAttributes(boolean)
+
+
+
+ +

+setRemoveJavaScriptProtocol

+
+public void setRemoveJavaScriptProtocol(boolean removeJavaScriptProtocol)
+
+
+
See Also:
HtmlCompressor.setRemoveJavaScriptProtocol(boolean)
+
+
+
+ +

+setRemoveHttpProtocol

+
+public void setRemoveHttpProtocol(boolean removeHttpProtocol)
+
+
+
See Also:
HtmlCompressor.setRemoveHttpProtocol(boolean)
+
+
+
+ +

+setRemoveHttpsProtocol

+
+public void setRemoveHttpsProtocol(boolean removeHttpsProtocol)
+
+
+
See Also:
HtmlCompressor.setRemoveHttpsProtocol(boolean)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/JavaScriptCompressorTag.html b/doc/com/googlecode/htmlcompressor/taglib/JavaScriptCompressorTag.html new file mode 100644 index 0000000..afa1b9d --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/JavaScriptCompressorTag.html @@ -0,0 +1,482 @@ + + + + + + +JavaScriptCompressorTag (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.taglib +
+Class JavaScriptCompressorTag

+
+java.lang.Object
+  extended by javax.servlet.jsp.tagext.TagSupport
+      extended by javax.servlet.jsp.tagext.BodyTagSupport
+          extended by com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag
+
+
+
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag
+
+
+
+
public class JavaScriptCompressorTag
extends javax.servlet.jsp.tagext.BodyTagSupport
+ + +

+JSP tag that compresses an JavaScript content within <compress:js> tags. + All JavaScript-related properties from HtmlCompressor are supported. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
HtmlCompressor, +Yahoo YUI Compressor, +Google Closure Compiler, +Serialized Form
+
+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
+  + + + + + + + + + + +
+Constructor Summary
JavaScriptCompressorTag() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intdoEndTag() + +
+           
+ voidsetClosureOptLevel(String closureOptLevel) + +
+          Sets level of optimization if Google Closure Compiler is used + for compressing inline JavaScript.
+ voidsetEnabled(boolean enabled) + +
+           
+ voidsetJsCompressor(String jsCompressor) + +
+          Sets JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML.
+ voidsetYuiJsDisableOptimizations(boolean yuiJsDisableOptimizations) + +
+           
+ voidsetYuiJsLineBreak(int yuiJsLineBreak) + +
+           
+ voidsetYuiJsNoMunge(boolean yuiJsNoMunge) + +
+           
+ voidsetYuiJsPreserveAllSemiColons(boolean yuiJsPreserveAllSemiColons) + +
+           
+ + + + + + + +
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, doStartTag, getBodyContent, getPreviousOut, release, setBodyContent
+ + + + + + + +
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+ + + + + + + +
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+JavaScriptCompressorTag

+
+public JavaScriptCompressorTag()
+
+
+ + + + + + + + +
+Method Detail
+ +

+doEndTag

+
+public int doEndTag()
+             throws javax.servlet.jsp.JspException
+
+
+
Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
+
+
+ +
Throws: +
javax.servlet.jsp.JspException
+
+
+
+ +

+setYuiJsNoMunge

+
+public void setYuiJsNoMunge(boolean yuiJsNoMunge)
+
+
+
See Also:
HtmlCompressor.setYuiJsNoMunge(boolean)
+
+
+
+ +

+setYuiJsPreserveAllSemiColons

+
+public void setYuiJsPreserveAllSemiColons(boolean yuiJsPreserveAllSemiColons)
+
+
+
See Also:
HtmlCompressor.setYuiJsPreserveAllSemiColons(boolean)
+
+
+
+ +

+setYuiJsDisableOptimizations

+
+public void setYuiJsDisableOptimizations(boolean yuiJsDisableOptimizations)
+
+
+
See Also:
HtmlCompressor.setYuiJsDisableOptimizations(boolean)
+
+
+
+ +

+setYuiJsLineBreak

+
+public void setYuiJsLineBreak(int yuiJsLineBreak)
+
+
+
See Also:
HtmlCompressor.setYuiJsLineBreak(int)
+
+
+
+ +

+setEnabled

+
+public void setEnabled(boolean enabled)
+
+
+
See Also:
HtmlCompressor.setEnabled(boolean)
+
+
+
+ +

+setJsCompressor

+
+public void setJsCompressor(String jsCompressor)
+
+
Sets JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML. +

+

+
Parameters:
jsCompressor - Could be either "yui" for using YuiJavaScriptCompressor (used by default if none provided) or + "closure" for using ClosureJavaScriptCompressor
See Also:
YuiJavaScriptCompressor, +ClosureJavaScriptCompressor, +Yahoo YUI Compressor, +Google Closure Compiler
+
+
+
+ +

+setClosureOptLevel

+
+public void setClosureOptLevel(String closureOptLevel)
+
+
Sets level of optimization if Google Closure Compiler is used + for compressing inline JavaScript. +

+

+
Parameters:
closureOptLevel - Could be either "simple" (used by default), "whitespace" or "advanced"
See Also:
ClosureJavaScriptCompressor.setCompilationLevel(CompilationLevel)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/XmlCompressorTag.html b/doc/com/googlecode/htmlcompressor/taglib/XmlCompressorTag.html new file mode 100644 index 0000000..d234e52 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/XmlCompressorTag.html @@ -0,0 +1,392 @@ + + + + + + +XmlCompressorTag (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.taglib +
+Class XmlCompressorTag

+
+java.lang.Object
+  extended by javax.servlet.jsp.tagext.TagSupport
+      extended by javax.servlet.jsp.tagext.BodyTagSupport
+          extended by com.googlecode.htmlcompressor.taglib.XmlCompressorTag
+
+
+
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag
+
+
+
+
public class XmlCompressorTag
extends javax.servlet.jsp.tagext.BodyTagSupport
+ + +

+JSP tag that compresses an XML content within <compress:xml>. + Compression parameters are set by default. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
XmlCompressor, +Serialized Form
+
+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
+ + + + + + + +
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
+  + + + + + + + + + + +
+Constructor Summary
XmlCompressorTag() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intdoEndTag() + +
+           
+ voidsetEnabled(boolean enabled) + +
+           
+ voidsetRemoveComments(boolean removeComments) + +
+           
+ voidsetRemoveIntertagSpaces(boolean removeIntertagSpaces) + +
+           
+ + + + + + + +
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, doStartTag, getBodyContent, getPreviousOut, release, setBodyContent
+ + + + + + + +
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+ + + + + + + +
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+XmlCompressorTag

+
+public XmlCompressorTag()
+
+
+ + + + + + + + +
+Method Detail
+ +

+doEndTag

+
+public int doEndTag()
+             throws javax.servlet.jsp.JspException
+
+
+
Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
+
+
+ +
Throws: +
javax.servlet.jsp.JspException
+
+
+
+ +

+setEnabled

+
+public void setEnabled(boolean enabled)
+
+
+
See Also:
XmlCompressor.setEnabled(boolean)
+
+
+
+ +

+setRemoveComments

+
+public void setRemoveComments(boolean removeComments)
+
+
+
See Also:
XmlCompressor.setRemoveComments(boolean)
+
+
+
+ +

+setRemoveIntertagSpaces

+
+public void setRemoveIntertagSpaces(boolean removeIntertagSpaces)
+
+
+
See Also:
XmlCompressor.setRemoveIntertagSpaces(boolean)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/class-use/CssCompressorTag.html b/doc/com/googlecode/htmlcompressor/taglib/class-use/CssCompressorTag.html new file mode 100644 index 0000000..4ff44d2 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/class-use/CssCompressorTag.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.taglib.CssCompressorTag (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.taglib.CssCompressorTag

+
+No usage of com.googlecode.htmlcompressor.taglib.CssCompressorTag +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/class-use/HtmlCompressorTag.html b/doc/com/googlecode/htmlcompressor/taglib/class-use/HtmlCompressorTag.html new file mode 100644 index 0000000..24c77ed --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/class-use/HtmlCompressorTag.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.taglib.HtmlCompressorTag

+
+No usage of com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/class-use/JavaScriptCompressorTag.html b/doc/com/googlecode/htmlcompressor/taglib/class-use/JavaScriptCompressorTag.html new file mode 100644 index 0000000..700665d --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/class-use/JavaScriptCompressorTag.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag

+
+No usage of com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/class-use/XmlCompressorTag.html b/doc/com/googlecode/htmlcompressor/taglib/class-use/XmlCompressorTag.html new file mode 100644 index 0000000..65cae16 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/class-use/XmlCompressorTag.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.taglib.XmlCompressorTag (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.taglib.XmlCompressorTag

+
+No usage of com.googlecode.htmlcompressor.taglib.XmlCompressorTag +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/package-frame.html b/doc/com/googlecode/htmlcompressor/taglib/package-frame.html new file mode 100644 index 0000000..d94ae91 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/package-frame.html @@ -0,0 +1,37 @@ + + + + + + +com.googlecode.htmlcompressor.taglib (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + +com.googlecode.htmlcompressor.taglib + + + + +
+Classes  + +
+CssCompressorTag +
+HtmlCompressorTag +
+JavaScriptCompressorTag +
+XmlCompressorTag
+ + + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/package-summary.html b/doc/com/googlecode/htmlcompressor/taglib/package-summary.html new file mode 100644 index 0000000..60ff595 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/package-summary.html @@ -0,0 +1,168 @@ + + + + + + +com.googlecode.htmlcompressor.taglib (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.googlecode.htmlcompressor.taglib +

+ + + + + + + + + + + + + + + + + + + + + +
+Class Summary
CssCompressorTagJSP tag that compresses an CSS content within <compress:css> using Yahoo YUI Compressor.
HtmlCompressorTagJSP tag that compresses an HTML content within <compress:html>.
JavaScriptCompressorTagJSP tag that compresses an JavaScript content within <compress:js> tags.
XmlCompressorTagJSP tag that compresses an XML content within <compress:xml>.
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/package-tree.html b/doc/com/googlecode/htmlcompressor/taglib/package-tree.html new file mode 100644 index 0000000..722941e --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/package-tree.html @@ -0,0 +1,158 @@ + + + + + + +com.googlecode.htmlcompressor.taglib Class Hierarchy (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.googlecode.htmlcompressor.taglib +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/taglib/package-use.html b/doc/com/googlecode/htmlcompressor/taglib/package-use.html new file mode 100644 index 0000000..3656d39 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/taglib/package-use.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Package com.googlecode.htmlcompressor.taglib (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Package
com.googlecode.htmlcompressor.taglib

+
+No usage of com.googlecode.htmlcompressor.taglib +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/CssCompressorDirective.html b/doc/com/googlecode/htmlcompressor/velocity/CssCompressorDirective.html new file mode 100644 index 0000000..e4e50fd --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/CssCompressorDirective.html @@ -0,0 +1,381 @@ + + + + + + +CssCompressorDirective (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.velocity +
+Class CssCompressorDirective

+
+java.lang.Object
+  extended by org.apache.velocity.runtime.directive.Directive
+      extended by com.googlecode.htmlcompressor.velocity.CssCompressorDirective
+
+
+
All Implemented Interfaces:
Cloneable, org.apache.velocity.runtime.directive.DirectiveConstants
+
+
+
+
public class CssCompressorDirective
extends org.apache.velocity.runtime.directive.Directive
+ + +

+Velocity directive that compresses an CSS content within #compressCss ... #end block. + All CSS-related properties from HtmlCompressor are supported. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
HtmlCompressor, +Yahoo YUI Compressor
+
+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface org.apache.velocity.runtime.directive.DirectiveConstants
BLOCK, LINE
+  + + + + + + + + + + +
+Constructor Summary
CssCompressorDirective() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ StringgetName() + +
+           
+ intgetType() + +
+           
+ voidinit(org.apache.velocity.runtime.RuntimeServices rs, + org.apache.velocity.context.InternalContextAdapter context, + org.apache.velocity.runtime.parser.node.Node node) + +
+           
+ booleanrender(org.apache.velocity.context.InternalContextAdapter context, + Writer writer, + org.apache.velocity.runtime.parser.node.Node node) + +
+           
+ + + + + + + +
Methods inherited from class org.apache.velocity.runtime.directive.Directive
getColumn, getLine, getTemplateName, setLocation, setLocation
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+CssCompressorDirective

+
+public CssCompressorDirective()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getName

+
+public String getName()
+
+
+
Specified by:
getName in class org.apache.velocity.runtime.directive.Directive
+
+
+
+
+
+
+ +

+getType

+
+public int getType()
+
+
+
Specified by:
getType in class org.apache.velocity.runtime.directive.Directive
+
+
+
+
+
+
+ +

+init

+
+public void init(org.apache.velocity.runtime.RuntimeServices rs,
+                 org.apache.velocity.context.InternalContextAdapter context,
+                 org.apache.velocity.runtime.parser.node.Node node)
+          throws org.apache.velocity.exception.TemplateInitException
+
+
+
Overrides:
init in class org.apache.velocity.runtime.directive.Directive
+
+
+ +
Throws: +
org.apache.velocity.exception.TemplateInitException
+
+
+
+ +

+render

+
+public boolean render(org.apache.velocity.context.InternalContextAdapter context,
+                      Writer writer,
+                      org.apache.velocity.runtime.parser.node.Node node)
+               throws IOException,
+                      org.apache.velocity.exception.ResourceNotFoundException,
+                      org.apache.velocity.exception.ParseErrorException,
+                      org.apache.velocity.exception.MethodInvocationException
+
+
+
Specified by:
render in class org.apache.velocity.runtime.directive.Directive
+
+
+ +
Throws: +
IOException +
org.apache.velocity.exception.ResourceNotFoundException +
org.apache.velocity.exception.ParseErrorException +
org.apache.velocity.exception.MethodInvocationException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/HtmlCompressorDirective.html b/doc/com/googlecode/htmlcompressor/velocity/HtmlCompressorDirective.html new file mode 100644 index 0000000..3b8496e --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/HtmlCompressorDirective.html @@ -0,0 +1,380 @@ + + + + + + +HtmlCompressorDirective (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.velocity +
+Class HtmlCompressorDirective

+
+java.lang.Object
+  extended by org.apache.velocity.runtime.directive.Directive
+      extended by com.googlecode.htmlcompressor.velocity.HtmlCompressorDirective
+
+
+
All Implemented Interfaces:
Cloneable, org.apache.velocity.runtime.directive.DirectiveConstants
+
+
+
+
public class HtmlCompressorDirective
extends org.apache.velocity.runtime.directive.Directive
+ + +

+Velocity directive that compresses an HTML content within #compressHtml ... #end block. + Compression parameters are set by default (no JavaScript and CSS compression). +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
HtmlCompressor
+
+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface org.apache.velocity.runtime.directive.DirectiveConstants
BLOCK, LINE
+  + + + + + + + + + + +
+Constructor Summary
HtmlCompressorDirective() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ StringgetName() + +
+           
+ intgetType() + +
+           
+ voidinit(org.apache.velocity.runtime.RuntimeServices rs, + org.apache.velocity.context.InternalContextAdapter context, + org.apache.velocity.runtime.parser.node.Node node) + +
+           
+ booleanrender(org.apache.velocity.context.InternalContextAdapter context, + Writer writer, + org.apache.velocity.runtime.parser.node.Node node) + +
+           
+ + + + + + + +
Methods inherited from class org.apache.velocity.runtime.directive.Directive
getColumn, getLine, getTemplateName, setLocation, setLocation
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+HtmlCompressorDirective

+
+public HtmlCompressorDirective()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getName

+
+public String getName()
+
+
+
Specified by:
getName in class org.apache.velocity.runtime.directive.Directive
+
+
+
+
+
+
+ +

+getType

+
+public int getType()
+
+
+
Specified by:
getType in class org.apache.velocity.runtime.directive.Directive
+
+
+
+
+
+
+ +

+init

+
+public void init(org.apache.velocity.runtime.RuntimeServices rs,
+                 org.apache.velocity.context.InternalContextAdapter context,
+                 org.apache.velocity.runtime.parser.node.Node node)
+          throws org.apache.velocity.exception.TemplateInitException
+
+
+
Overrides:
init in class org.apache.velocity.runtime.directive.Directive
+
+
+ +
Throws: +
org.apache.velocity.exception.TemplateInitException
+
+
+
+ +

+render

+
+public boolean render(org.apache.velocity.context.InternalContextAdapter context,
+                      Writer writer,
+                      org.apache.velocity.runtime.parser.node.Node node)
+               throws IOException,
+                      org.apache.velocity.exception.ResourceNotFoundException,
+                      org.apache.velocity.exception.ParseErrorException,
+                      org.apache.velocity.exception.MethodInvocationException
+
+
+
Specified by:
render in class org.apache.velocity.runtime.directive.Directive
+
+
+ +
Throws: +
IOException +
org.apache.velocity.exception.ResourceNotFoundException +
org.apache.velocity.exception.ParseErrorException +
org.apache.velocity.exception.MethodInvocationException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/JavaScriptCompressorDirective.html b/doc/com/googlecode/htmlcompressor/velocity/JavaScriptCompressorDirective.html new file mode 100644 index 0000000..f199a64 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/JavaScriptCompressorDirective.html @@ -0,0 +1,382 @@ + + + + + + +JavaScriptCompressorDirective (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.velocity +
+Class JavaScriptCompressorDirective

+
+java.lang.Object
+  extended by org.apache.velocity.runtime.directive.Directive
+      extended by com.googlecode.htmlcompressor.velocity.JavaScriptCompressorDirective
+
+
+
All Implemented Interfaces:
Cloneable, org.apache.velocity.runtime.directive.DirectiveConstants
+
+
+
+
public class JavaScriptCompressorDirective
extends org.apache.velocity.runtime.directive.Directive
+ + +

+Velocity directive that compresses an JavaScript content within #compressJs ... #end block. + All JavaScript-related properties from HtmlCompressor are supported. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
HtmlCompressor, +Yahoo YUI Compressor, +Google Closure Compiler
+
+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface org.apache.velocity.runtime.directive.DirectiveConstants
BLOCK, LINE
+  + + + + + + + + + + +
+Constructor Summary
JavaScriptCompressorDirective() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ StringgetName() + +
+           
+ intgetType() + +
+           
+ voidinit(org.apache.velocity.runtime.RuntimeServices rs, + org.apache.velocity.context.InternalContextAdapter context, + org.apache.velocity.runtime.parser.node.Node node) + +
+           
+ booleanrender(org.apache.velocity.context.InternalContextAdapter context, + Writer writer, + org.apache.velocity.runtime.parser.node.Node node) + +
+           
+ + + + + + + +
Methods inherited from class org.apache.velocity.runtime.directive.Directive
getColumn, getLine, getTemplateName, setLocation, setLocation
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+JavaScriptCompressorDirective

+
+public JavaScriptCompressorDirective()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getName

+
+public String getName()
+
+
+
Specified by:
getName in class org.apache.velocity.runtime.directive.Directive
+
+
+
+
+
+
+ +

+getType

+
+public int getType()
+
+
+
Specified by:
getType in class org.apache.velocity.runtime.directive.Directive
+
+
+
+
+
+
+ +

+init

+
+public void init(org.apache.velocity.runtime.RuntimeServices rs,
+                 org.apache.velocity.context.InternalContextAdapter context,
+                 org.apache.velocity.runtime.parser.node.Node node)
+          throws org.apache.velocity.exception.TemplateInitException
+
+
+
Overrides:
init in class org.apache.velocity.runtime.directive.Directive
+
+
+ +
Throws: +
org.apache.velocity.exception.TemplateInitException
+
+
+
+ +

+render

+
+public boolean render(org.apache.velocity.context.InternalContextAdapter context,
+                      Writer writer,
+                      org.apache.velocity.runtime.parser.node.Node node)
+               throws IOException,
+                      org.apache.velocity.exception.ResourceNotFoundException,
+                      org.apache.velocity.exception.ParseErrorException,
+                      org.apache.velocity.exception.MethodInvocationException
+
+
+
Specified by:
render in class org.apache.velocity.runtime.directive.Directive
+
+
+ +
Throws: +
IOException +
org.apache.velocity.exception.ResourceNotFoundException +
org.apache.velocity.exception.ParseErrorException +
org.apache.velocity.exception.MethodInvocationException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/XmlCompressorDirective.html b/doc/com/googlecode/htmlcompressor/velocity/XmlCompressorDirective.html new file mode 100644 index 0000000..a0b1128 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/XmlCompressorDirective.html @@ -0,0 +1,380 @@ + + + + + + +XmlCompressorDirective (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +com.googlecode.htmlcompressor.velocity +
+Class XmlCompressorDirective

+
+java.lang.Object
+  extended by org.apache.velocity.runtime.directive.Directive
+      extended by com.googlecode.htmlcompressor.velocity.XmlCompressorDirective
+
+
+
All Implemented Interfaces:
Cloneable, org.apache.velocity.runtime.directive.DirectiveConstants
+
+
+
+
public class XmlCompressorDirective
extends org.apache.velocity.runtime.directive.Directive
+ + +

+Velocity directive that compresses an XML content within #compressXml ... #end block. + Compression parameters are set by default. +

+ +

+

+
Author:
+
Sergiy Kovalchuk
+
See Also:
XmlCompressor
+
+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface org.apache.velocity.runtime.directive.DirectiveConstants
BLOCK, LINE
+  + + + + + + + + + + +
+Constructor Summary
XmlCompressorDirective() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ StringgetName() + +
+           
+ intgetType() + +
+           
+ voidinit(org.apache.velocity.runtime.RuntimeServices rs, + org.apache.velocity.context.InternalContextAdapter context, + org.apache.velocity.runtime.parser.node.Node node) + +
+           
+ booleanrender(org.apache.velocity.context.InternalContextAdapter context, + Writer writer, + org.apache.velocity.runtime.parser.node.Node node) + +
+           
+ + + + + + + +
Methods inherited from class org.apache.velocity.runtime.directive.Directive
getColumn, getLine, getTemplateName, setLocation, setLocation
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+XmlCompressorDirective

+
+public XmlCompressorDirective()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getName

+
+public String getName()
+
+
+
Specified by:
getName in class org.apache.velocity.runtime.directive.Directive
+
+
+
+
+
+
+ +

+getType

+
+public int getType()
+
+
+
Specified by:
getType in class org.apache.velocity.runtime.directive.Directive
+
+
+
+
+
+
+ +

+init

+
+public void init(org.apache.velocity.runtime.RuntimeServices rs,
+                 org.apache.velocity.context.InternalContextAdapter context,
+                 org.apache.velocity.runtime.parser.node.Node node)
+          throws org.apache.velocity.exception.TemplateInitException
+
+
+
Overrides:
init in class org.apache.velocity.runtime.directive.Directive
+
+
+ +
Throws: +
org.apache.velocity.exception.TemplateInitException
+
+
+
+ +

+render

+
+public boolean render(org.apache.velocity.context.InternalContextAdapter context,
+                      Writer writer,
+                      org.apache.velocity.runtime.parser.node.Node node)
+               throws IOException,
+                      org.apache.velocity.exception.ResourceNotFoundException,
+                      org.apache.velocity.exception.ParseErrorException,
+                      org.apache.velocity.exception.MethodInvocationException
+
+
+
Specified by:
render in class org.apache.velocity.runtime.directive.Directive
+
+
+ +
Throws: +
IOException +
org.apache.velocity.exception.ResourceNotFoundException +
org.apache.velocity.exception.ParseErrorException +
org.apache.velocity.exception.MethodInvocationException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/class-use/CssCompressorDirective.html b/doc/com/googlecode/htmlcompressor/velocity/class-use/CssCompressorDirective.html new file mode 100644 index 0000000..de09c90 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/class-use/CssCompressorDirective.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.velocity.CssCompressorDirective (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.velocity.CssCompressorDirective

+
+No usage of com.googlecode.htmlcompressor.velocity.CssCompressorDirective +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/class-use/HtmlCompressorDirective.html b/doc/com/googlecode/htmlcompressor/velocity/class-use/HtmlCompressorDirective.html new file mode 100644 index 0000000..7cfc44c --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/class-use/HtmlCompressorDirective.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.velocity.HtmlCompressorDirective (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.velocity.HtmlCompressorDirective

+
+No usage of com.googlecode.htmlcompressor.velocity.HtmlCompressorDirective +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/class-use/JavaScriptCompressorDirective.html b/doc/com/googlecode/htmlcompressor/velocity/class-use/JavaScriptCompressorDirective.html new file mode 100644 index 0000000..aebb1cf --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/class-use/JavaScriptCompressorDirective.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.velocity.JavaScriptCompressorDirective (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.velocity.JavaScriptCompressorDirective

+
+No usage of com.googlecode.htmlcompressor.velocity.JavaScriptCompressorDirective +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/class-use/XmlCompressorDirective.html b/doc/com/googlecode/htmlcompressor/velocity/class-use/XmlCompressorDirective.html new file mode 100644 index 0000000..7248e68 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/class-use/XmlCompressorDirective.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Class com.googlecode.htmlcompressor.velocity.XmlCompressorDirective (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Class
com.googlecode.htmlcompressor.velocity.XmlCompressorDirective

+
+No usage of com.googlecode.htmlcompressor.velocity.XmlCompressorDirective +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/package-frame.html b/doc/com/googlecode/htmlcompressor/velocity/package-frame.html new file mode 100644 index 0000000..67b9d58 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/package-frame.html @@ -0,0 +1,37 @@ + + + + + + +com.googlecode.htmlcompressor.velocity (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + +com.googlecode.htmlcompressor.velocity + + + + +
+Classes  + +
+CssCompressorDirective +
+HtmlCompressorDirective +
+JavaScriptCompressorDirective +
+XmlCompressorDirective
+ + + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/package-summary.html b/doc/com/googlecode/htmlcompressor/velocity/package-summary.html new file mode 100644 index 0000000..f386ec5 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/package-summary.html @@ -0,0 +1,168 @@ + + + + + + +com.googlecode.htmlcompressor.velocity (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package com.googlecode.htmlcompressor.velocity +

+ + + + + + + + + + + + + + + + + + + + + +
+Class Summary
CssCompressorDirectiveVelocity directive that compresses an CSS content within #compressCss ...
HtmlCompressorDirectiveVelocity directive that compresses an HTML content within #compressHtml ...
JavaScriptCompressorDirectiveVelocity directive that compresses an JavaScript content within #compressJs ...
XmlCompressorDirectiveVelocity directive that compresses an XML content within #compressXml ...
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/package-tree.html b/doc/com/googlecode/htmlcompressor/velocity/package-tree.html new file mode 100644 index 0000000..504e90a --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/package-tree.html @@ -0,0 +1,155 @@ + + + + + + +com.googlecode.htmlcompressor.velocity Class Hierarchy (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package com.googlecode.htmlcompressor.velocity +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/com/googlecode/htmlcompressor/velocity/package-use.html b/doc/com/googlecode/htmlcompressor/velocity/package-use.html new file mode 100644 index 0000000..492e972 --- /dev/null +++ b/doc/com/googlecode/htmlcompressor/velocity/package-use.html @@ -0,0 +1,143 @@ + + + + + + +Uses of Package com.googlecode.htmlcompressor.velocity (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Package
com.googlecode.htmlcompressor.velocity

+
+No usage of com.googlecode.htmlcompressor.velocity +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/constant-values.html b/doc/constant-values.html new file mode 100644 index 0000000..38041ca --- /dev/null +++ b/doc/constant-values.html @@ -0,0 +1,227 @@ + + + + + + +Constant Field Values (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Constant Field Values

+
+
+Contents + + + + + + +
+com.googlecode.*
+ +

+ + + + + + + + + + + + + + + + + + + + + + +
com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor
+public static final StringCOMPILATION_LEVEL_ADVANCED"advanced"
+public static final StringCOMPILATION_LEVEL_SIMPLE"simple"
+public static final StringCOMPILATION_LEVEL_WHITESPACE"whitespace"
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
com.googlecode.htmlcompressor.compressor.HtmlCompressor
+public static final StringALL_TAGS"all"
+public static final StringBLOCK_TAGS_MAX"html,head,body,br,p,h1,h2,h3,h4,h5,h6,blockquote,center,dl,fieldset,form,frame,frameset,hr,noframes,ol,table,tbody,tr,td,th,tfoot,thead,ul"
+public static final StringBLOCK_TAGS_MIN"html,head,body,br,p"
+public static final StringJS_COMPRESSOR_CLOSURE"closure"
+public static final StringJS_COMPRESSOR_YUI"yui"
+ +

+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/deprecated-list.html b/doc/deprecated-list.html new file mode 100644 index 0000000..be5345d --- /dev/null +++ b/doc/deprecated-list.html @@ -0,0 +1,145 @@ + + + + + + +Deprecated List (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Deprecated API

+
+
+Contents
    +
+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/help-doc.html b/doc/help-doc.html new file mode 100644 index 0000000..a8b16e4 --- /dev/null +++ b/doc/help-doc.html @@ -0,0 +1,222 @@ + + + + + + +API Help (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Overview

+
+ +

+The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

+

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

    +
  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types
+
+

+Class/Interface

+
+ +

+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description +

    +

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary +

    +

  • Field Detail
  • Constructor Detail
  • Method Detail
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+ +

+Annotation Type

+
+ +

+Each annotation type has its own separate page with the following sections:

    +
  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail
+
+ +

+Enum

+
+ +

+Each enum has its own separate page with the following sections:

    +
  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail
+
+

+Use

+
+Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
    +
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
+
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+

+Constant Field Values

+The Constant Field Values page lists the static final fields and their values. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/index-all.html b/doc/index-all.html new file mode 100644 index 0000000..07cf083 --- /dev/null +++ b/doc/index-all.html @@ -0,0 +1,918 @@ + + + + + + +Index (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +A B C D E G H I J M P R S T W X Y
+

+A

+
+
ALL_TAGS - +Static variable in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Could be passed to setRemoveSurroundingSpaces method + to remove all surrounding spaces (not recommended). +
analyze(String) - +Method in class com.googlecode.htmlcompressor.analyzer.HtmlAnalyzer +
  +
+
+

+B

+
+
BLOCK_TAGS_MAX - +Static variable in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Predefined list of tags that are block-level by default, excluding <div> and <li> tags. +
BLOCK_TAGS_MIN - +Static variable in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Predefined list of tags that are very likely to be block-level. +
+
+

+C

+
+
ClosureJavaScriptCompressor - Class in com.googlecode.htmlcompressor.compressor
Basic JavaScript compressor implementation using Google Closure Compiler + that could be used by HtmlCompressor for inline JavaScript compression.
ClosureJavaScriptCompressor() - +Constructor for class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
  +
ClosureJavaScriptCompressor(CompilationLevel) - +Constructor for class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
  +
CmdLineCompressor - Class in com.googlecode.htmlcompressor
Wrapper for HTML and XML compressor classes that allows using them from a command line.
CmdLineCompressor(String[]) - +Constructor for class com.googlecode.htmlcompressor.CmdLineCompressor +
  +
com.googlecode.htmlcompressor - package com.googlecode.htmlcompressor
 
com.googlecode.htmlcompressor.analyzer - package com.googlecode.htmlcompressor.analyzer
 
com.googlecode.htmlcompressor.compressor - package com.googlecode.htmlcompressor.compressor
 
com.googlecode.htmlcompressor.taglib - package com.googlecode.htmlcompressor.taglib
 
com.googlecode.htmlcompressor.velocity - package com.googlecode.htmlcompressor.velocity
 
COMPILATION_LEVEL_ADVANCED - +Static variable in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
  +
COMPILATION_LEVEL_SIMPLE - +Static variable in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
  +
COMPILATION_LEVEL_WHITESPACE - +Static variable in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
  +
compress(String) - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
  +
compress(String) - +Method in interface com.googlecode.htmlcompressor.compressor.Compressor +
The main method that compresses the given source and returns a compressed result. +
compress(String) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
The main method that compresses given HTML source and returns compressed + result. +
compress(String) - +Method in class com.googlecode.htmlcompressor.compressor.XmlCompressor +
The main method that compresses given XML source and returns compressed result. +
compress(String) - +Method in class com.googlecode.htmlcompressor.compressor.YuiCssCompressor +
  +
compress(String) - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
  +
Compressor - Interface in com.googlecode.htmlcompressor.compressor
Interface describing compressor classes.
CssCompressorDirective - Class in com.googlecode.htmlcompressor.velocity
Velocity directive that compresses an CSS content within #compressCss ...
CssCompressorDirective() - +Constructor for class com.googlecode.htmlcompressor.velocity.CssCompressorDirective +
  +
CssCompressorTag - Class in com.googlecode.htmlcompressor.taglib
JSP tag that compresses an CSS content within <compress:css> using Yahoo YUI Compressor.
CssCompressorTag() - +Constructor for class com.googlecode.htmlcompressor.taglib.CssCompressorTag +
  +
+
+

+D

+
+
doEndTag() - +Method in class com.googlecode.htmlcompressor.taglib.CssCompressorTag +
  +
doEndTag() - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
doEndTag() - +Method in class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag +
  +
doEndTag() - +Method in class com.googlecode.htmlcompressor.taglib.XmlCompressorTag +
  +
+
+

+E

+
+
error(String, String, int, String, int) - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.DefaultErrorReporter +
  +
+
+

+G

+
+
getCompilationLevel() - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Returns level of optimization that is applied when compiling JavaScript code. +
getCompilerOptions() - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Returns options that are used by the Closure compiler. +
getCompressedMetrics() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics +
Returns metrics of a compressed document +
getCssCompressor() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns CSS compressor implementation that will be used + to compress inline CSS in HTML. +
getEmptyChars() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
Returns number of empty characters (spaces, tabs, end of lines) in a document +
getErrorReporter() - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
Returns ErrorReporter used by YUI Compressor to log error messages + during JavasSript compression +
getExterns() - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Returns JSSourceFile used as a reference during the compression + at CompilationLevel.ADVANCED_OPTIMIZATIONS level. +
getFilesize() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
Returns total filesize of a document +
getInlineEventSize() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
Returns total size of inline event handlers (onclick, etc) +
getInlineScriptSize() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
Returns total size of inline <script> tags +
getInlineStyleSize() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
Returns total size of inline <style> tags +
getJavaScriptCompressor() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML. +
getLineBreak() - +Method in class com.googlecode.htmlcompressor.compressor.YuiCssCompressor +
Returns number of symbols per line Yahoo YUI Compressor + will use during CSS compression. +
getLineBreak() - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
Returns number of symbols per line Yahoo YUI Compressor + will use during JavaScript compression. +
getLoggingLevel() - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Returns logging level used by the Closure compiler. +
getName() - +Method in class com.googlecode.htmlcompressor.velocity.CssCompressorDirective +
  +
getName() - +Method in class com.googlecode.htmlcompressor.velocity.HtmlCompressorDirective +
  +
getName() - +Method in class com.googlecode.htmlcompressor.velocity.JavaScriptCompressorDirective +
  +
getName() - +Method in class com.googlecode.htmlcompressor.velocity.XmlCompressorDirective +
  +
getOriginalMetrics() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics +
Returns metrics of an uncompressed document +
getPreservedSize() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics +
Returns total size of blocks that were skipped by the compressor + (for example content inside <pre> tags or inside + <script> tags with disabled javascript compression) +
getPreservePatterns() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns a list of Patterns defining custom preserving block rules +
getRemoveSurroundingSpaces() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns a comma separated list of tags around which spaces will be removed. +
getStatistics() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns HtmlCompressorStatistics object containing statistics of the last HTML compression, if enabled. +
getTime() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics +
Returns total compression time. +
getType() - +Method in class com.googlecode.htmlcompressor.velocity.CssCompressorDirective +
  +
getType() - +Method in class com.googlecode.htmlcompressor.velocity.HtmlCompressorDirective +
  +
getType() - +Method in class com.googlecode.htmlcompressor.velocity.JavaScriptCompressorDirective +
  +
getType() - +Method in class com.googlecode.htmlcompressor.velocity.XmlCompressorDirective +
  +
getWarningLevel() - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Returns WarningLevel used by the Closure compiler +
getYuiCssLineBreak() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns number of symbols per line Yahoo YUI Compressor + will use during CSS compression. +
getYuiErrorReporter() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns ErrorReporter used by YUI Compressor to log error messages + during JavasSript compression +
getYuiJsLineBreak() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns number of symbols per line Yahoo YUI Compressor + will use during JavaScript compression. +
+
+

+H

+
+
HtmlAnalyzer - Class in com.googlecode.htmlcompressor.analyzer
Class that compresses provided source with different compression + settings and displays page size gains in a report
HtmlAnalyzer() - +Constructor for class com.googlecode.htmlcompressor.analyzer.HtmlAnalyzer +
  +
HtmlAnalyzer(String) - +Constructor for class com.googlecode.htmlcompressor.analyzer.HtmlAnalyzer +
  +
HtmlCompressor - Class in com.googlecode.htmlcompressor.compressor
Class that compresses given HTML source by removing comments, extra spaces and + line breaks while preserving content within <pre>, <textarea>, <script> + and <style> tags.
HtmlCompressor() - +Constructor for class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
  +
HtmlCompressorDirective - Class in com.googlecode.htmlcompressor.velocity
Velocity directive that compresses an HTML content within #compressHtml ...
HtmlCompressorDirective() - +Constructor for class com.googlecode.htmlcompressor.velocity.HtmlCompressorDirective +
  +
HtmlCompressorStatistics - Class in com.googlecode.htmlcompressor.compressor
Class that stores HTML compression statistics
HtmlCompressorStatistics() - +Constructor for class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics +
  +
HtmlCompressorTag - Class in com.googlecode.htmlcompressor.taglib
JSP tag that compresses an HTML content within <compress:html>.
HtmlCompressorTag() - +Constructor for class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
HtmlMetrics - Class in com.googlecode.htmlcompressor.compressor
Class that stores metrics about HTML documents.
HtmlMetrics() - +Constructor for class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
  +
+
+

+I

+
+
init(RuntimeServices, InternalContextAdapter, Node) - +Method in class com.googlecode.htmlcompressor.velocity.CssCompressorDirective +
  +
init(RuntimeServices, InternalContextAdapter, Node) - +Method in class com.googlecode.htmlcompressor.velocity.HtmlCompressorDirective +
  +
init(RuntimeServices, InternalContextAdapter, Node) - +Method in class com.googlecode.htmlcompressor.velocity.JavaScriptCompressorDirective +
  +
init(RuntimeServices, InternalContextAdapter, Node) - +Method in class com.googlecode.htmlcompressor.velocity.XmlCompressorDirective +
  +
isCompressCss() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if CSS compression is enabled. +
isCompressJavaScript() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if JavaScript compression is enabled. +
isCustomExternsOnly() - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Returns true if default externs defined inside Closure's jar are ignored + and only user defined ones are used. +
isDisableOptimizations() - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
Returns true if Yahoo YUI Compressor + will disable all the built-in micro optimizations during JavaScript compression. +
isEnabled() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if compression is enabled. +
isEnabled() - +Method in class com.googlecode.htmlcompressor.compressor.XmlCompressor +
Returns true if compression is enabled. +
isGenerateStatistics() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if HTML compression statistics is generated +
isNoMunge() - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
Returns true if Yahoo YUI Compressor + will only minify javascript without obfuscating local symbols. +
isPreserveAllSemiColons() - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
Returns true if Yahoo YUI Compressor + will preserve unnecessary semicolons during JavaScript compression. +
isPreserveLineBreaks() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if line breaks will be preserved. +
isRemoveComments() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if all HTML comments will be removed. +
isRemoveComments() - +Method in class com.googlecode.htmlcompressor.compressor.XmlCompressor +
Returns true if all XML comments will be removed. +
isRemoveFormAttributes() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if method="get" attributes will be removed from <form> tags +
isRemoveHttpProtocol() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if HTTP protocol will be removed from href, src, cite, and action tag attributes. +
isRemoveHttpsProtocol() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if HTTPS protocol will be removed from href, src, cite, and action tag attributes. +
isRemoveInputAttributes() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if type="text" attributes will be removed from <input> tags +
isRemoveIntertagSpaces() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if all inter-tag whitespace characters will be removed. +
isRemoveIntertagSpaces() - +Method in class com.googlecode.htmlcompressor.compressor.XmlCompressor +
Returns true if all inter-tag whitespace characters will be removed. +
isRemoveJavaScriptProtocol() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if javascript: pseudo-protocol will be removed from inline event handlers. +
isRemoveLinkAttributes() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if unnecessary attributes will be removed from <link> tags +
isRemoveMultiSpaces() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if all multiple whitespace characters will be replaced with single spaces. +
isRemoveQuotes() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if all unnecessary quotes will be removed + from tag attributes. +
isRemoveScriptAttributes() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if unnecessary attributes wil be removed from <script> tags +
isRemoveStyleAttributes() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if type="text/style" attributes will be removed from <style> tags +
isSimpleBooleanAttributes() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if boolean attributes will be simplified +
isSimpleDoctype() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if existing DOCTYPE declaration will be replaced with simple declaration. +
isYuiJsDisableOptimizations() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if Yahoo YUI Compressor + will disable all the built-in micro optimizations during JavaScript compression. +
isYuiJsNoMunge() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if Yahoo YUI Compressor + will only minify javascript without obfuscating local symbols. +
isYuiJsPreserveAllSemiColons() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Returns true if Yahoo YUI Compressor + will preserve unnecessary semicolons during JavaScript compression. +
+
+

+J

+
+
JavaScriptCompressorDirective - Class in com.googlecode.htmlcompressor.velocity
Velocity directive that compresses an JavaScript content within #compressJs ...
JavaScriptCompressorDirective() - +Constructor for class com.googlecode.htmlcompressor.velocity.JavaScriptCompressorDirective +
  +
JavaScriptCompressorTag - Class in com.googlecode.htmlcompressor.taglib
JSP tag that compresses an JavaScript content within <compress:js> tags.
JavaScriptCompressorTag() - +Constructor for class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag +
  +
JS_COMPRESSOR_CLOSURE - +Static variable in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
  +
JS_COMPRESSOR_YUI - +Static variable in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
  +
+
+

+M

+
+
main(String[]) - +Static method in class com.googlecode.htmlcompressor.CmdLineCompressor +
  +
+
+

+P

+
+
PHP_TAG_PATTERN - +Static variable in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Predefined pattern that matches <?php ... +
process(String[]) - +Method in class com.googlecode.htmlcompressor.CmdLineCompressor +
  +
+
+

+R

+
+
render(InternalContextAdapter, Writer, Node) - +Method in class com.googlecode.htmlcompressor.velocity.CssCompressorDirective +
  +
render(InternalContextAdapter, Writer, Node) - +Method in class com.googlecode.htmlcompressor.velocity.HtmlCompressorDirective +
  +
render(InternalContextAdapter, Writer, Node) - +Method in class com.googlecode.htmlcompressor.velocity.JavaScriptCompressorDirective +
  +
render(InternalContextAdapter, Writer, Node) - +Method in class com.googlecode.htmlcompressor.velocity.XmlCompressorDirective +
  +
runtimeError(String, String, int, String, int) - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.DefaultErrorReporter +
  +
+
+

+S

+
+
SERVER_SCRIPT_TAG_PATTERN - +Static variable in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Predefined pattern that matches <% ... +
SERVER_SIDE_INCLUDE_PATTERN - +Static variable in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Predefined pattern that matches <--# ... +
setClosureOptLevel(String) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
Sets level of optimization if Google Closure Compiler is used + for compressing inline JavaScript. +
setClosureOptLevel(String) - +Method in class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag +
Sets level of optimization if Google Closure Compiler is used + for compressing inline JavaScript. +
setCompilationLevel(CompilationLevel) - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Sets level of optimization that should be applied when compiling JavaScript code. +
setCompilerOptions(CompilerOptions) - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Sets options that will be used by the Closure compiler. +
setCompressCss(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Enables CSS compression within <style> tags using + Yahoo YUI Compressor + if set to true. +
setCompressCss(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setCompressedMetrics(HtmlMetrics) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics +
  +
setCompressJavaScript(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Enables JavaScript compression within <script> tags using + Yahoo YUI Compressor + if set to true. +
setCompressJavaScript(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setCssCompressor(Compressor) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Sets CSS compressor implementation that will be used + to compress inline CSS in HTML. +
setCustomExternsOnly(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
If set to true, default externs defined inside Closure's jar will be ignored + and only user defined ones will be used. +
setDisableOptimizations(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
Tells Yahoo YUI Compressor to disable all the built-in micro optimizations + during JavaScript compression. +
setEmptyChars(int) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
  +
setEnabled(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to false all compression will be bypassed. +
setEnabled(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.XmlCompressor +
If set to false all compression will be bypassed. +
setEnabled(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.CssCompressorTag +
  +
setEnabled(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setEnabled(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag +
  +
setEnabled(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.XmlCompressorTag +
  +
setErrorReporter(ErrorReporter) - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
Sets ErrorReporter that YUI Compressor will use for reporting errors during + JavaScript compression. +
setExterns(List<JSSourceFile>) - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Sets external JavaScript files that are used as a reference for function declarations if + CompilationLevel.ADVANCED_OPTIMIZATIONS compression level is used. +
setFilesize(int) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
  +
setGenerateStatistics(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, HTML compression statistics will be generated. +
setInlineEventSize(int) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
  +
setInlineScriptSize(int) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
  +
setInlineStyleSize(int) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
  +
setJavaScriptCompressor(Compressor) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Sets JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML. +
setJsCompressor(String) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
Sets JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML. +
setJsCompressor(String) - +Method in class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag +
Sets JavaScript compressor implementation that will be used + to compress inline JavaScript in HTML. +
setLineBreak(int) - +Method in class com.googlecode.htmlcompressor.compressor.YuiCssCompressor +
Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during CSS compression. +
setLineBreak(int) - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during JavaScript compression. +
setLoggingLevel(Level) - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Sets logging level for the Closure compiler. +
setNoMunge(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
Tells Yahoo YUI Compressor to only minify javascript without obfuscating + local symbols. +
setOriginalMetrics(HtmlMetrics) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics +
  +
setPreserveAllSemiColons(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
Tells Yahoo YUI Compressor to preserve unnecessary semicolons + during JavaScript compression. +
setPreservedSize(int) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics +
  +
setPreserveLineBreaks(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, line breaks will be preserved. +
setPreserveLineBreaks(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setPreservePatterns(List<Pattern>) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
This method allows setting custom block preservation rules defined by regular + expression patterns. +
setRemoveComments(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true all HTML comments will be removed. +
setRemoveComments(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.XmlCompressor +
If set to true all XML comments will be removed. +
setRemoveComments(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveComments(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.XmlCompressorTag +
  +
setRemoveFormAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, method="get" attributes will be removed from <form> tags. +
setRemoveFormAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveHttpProtocol(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, HTTP protocol will be removed from href, src, cite, and action tag attributes. +
setRemoveHttpProtocol(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveHttpsProtocol(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, HTTPS protocol will be removed from href, src, cite, and action tag attributes. +
setRemoveHttpsProtocol(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveInputAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, type="text" attributes will be removed from <input> tags. +
setRemoveInputAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveIntertagSpaces(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true all inter-tag whitespace characters will be removed. +
setRemoveIntertagSpaces(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.XmlCompressor +
If set to true all inter-tag whitespace characters will be removed. +
setRemoveIntertagSpaces(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveIntertagSpaces(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.XmlCompressorTag +
  +
setRemoveJavaScriptProtocol(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, javascript: pseudo-protocol will be removed from inline event handlers. +
setRemoveJavaScriptProtocol(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveLinkAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, following attributes will be removed from <link rel="stylesheet"> and <link rel="alternate stylesheet"> tags: + + type="text/css" + type="text/plain" + +
setRemoveLinkAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveMultiSpaces(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true all multiple whitespace characters will be replaced with single spaces. +
setRemoveMultiSpaces(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveQuotes(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true all unnecessary quotes will be removed + from tag attributes. +
setRemoveQuotes(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveScriptAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, following attributes will be removed from <script> tags: + + type="text/javascript" + type="application/javascript" + language="javascript" + +
setRemoveScriptAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveStyleAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, type="text/style" attributes will be removed from <style> tags. +
setRemoveStyleAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setRemoveSurroundingSpaces(String) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Enables surrounding spaces removal around provided comma separated list of tags. +
setSimpleBooleanAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, any values of following boolean attributes will be removed: + + checked + selected + disabled + readonly + +
setSimpleBooleanAttributes(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setSimpleDoctype(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
If set to true, existing DOCTYPE declaration will be replaced with simple <!DOCTYPE html> declaration. +
setSimpleDoctype(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setTime(long) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics +
  +
setWarningLevel(WarningLevel) - +Method in class com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor +
Indicates the amount of information you want from the compiler about possible problems in your code. +
setYuiCssLineBreak(int) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during CSS compression. +
setYuiCssLineBreak(int) - +Method in class com.googlecode.htmlcompressor.taglib.CssCompressorTag +
  +
setYuiCssLineBreak(int) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setYuiErrorReporter(ErrorReporter) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Sets ErrorReporter that YUI Compressor will use for reporting errors during + JavaScript compression. +
setYuiJsDisableOptimizations(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Tells Yahoo YUI Compressor to disable all the built-in micro optimizations + during JavaScript compression. +
setYuiJsDisableOptimizations(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setYuiJsDisableOptimizations(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag +
  +
setYuiJsLineBreak(int) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Tells Yahoo YUI Compressor to break lines after the specified number of symbols + during JavaScript compression. +
setYuiJsLineBreak(int) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setYuiJsLineBreak(int) - +Method in class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag +
  +
setYuiJsNoMunge(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Tells Yahoo YUI Compressor to only minify javascript without obfuscating + local symbols. +
setYuiJsNoMunge(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setYuiJsNoMunge(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag +
  +
setYuiJsPreserveAllSemiColons(boolean) - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressor +
Tells Yahoo YUI Compressor to preserve unnecessary semicolons + during JavaScript compression. +
setYuiJsPreserveAllSemiColons(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag +
  +
setYuiJsPreserveAllSemiColons(boolean) - +Method in class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag +
  +
+
+

+T

+
+
toString() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlCompressorStatistics +
  +
toString() - +Method in class com.googlecode.htmlcompressor.compressor.HtmlMetrics +
  +
+
+

+W

+
+
warning(String, String, int, String, int) - +Method in class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.DefaultErrorReporter +
  +
+
+

+X

+
+
XmlCompressor - Class in com.googlecode.htmlcompressor.compressor
Class that compresses given XML source by removing comments, extra spaces and + line breaks while preserving content within CDATA blocks.
XmlCompressor() - +Constructor for class com.googlecode.htmlcompressor.compressor.XmlCompressor +
  +
XmlCompressorDirective - Class in com.googlecode.htmlcompressor.velocity
Velocity directive that compresses an XML content within #compressXml ...
XmlCompressorDirective() - +Constructor for class com.googlecode.htmlcompressor.velocity.XmlCompressorDirective +
  +
XmlCompressorTag - Class in com.googlecode.htmlcompressor.taglib
JSP tag that compresses an XML content within <compress:xml>.
XmlCompressorTag() - +Constructor for class com.googlecode.htmlcompressor.taglib.XmlCompressorTag +
  +
+
+

+Y

+
+
YuiCssCompressor - Class in com.googlecode.htmlcompressor.compressor
Basic CSS compressor implementation using Yahoo YUI Compressor + that could be used by HtmlCompressor for inline CSS compression.
YuiCssCompressor() - +Constructor for class com.googlecode.htmlcompressor.compressor.YuiCssCompressor +
  +
YuiJavaScriptCompressor - Class in com.googlecode.htmlcompressor.compressor
Basic JavaScript compressor implementation using Yahoo YUI Compressor + that could be used by HtmlCompressor for inline JavaScript compression.
YuiJavaScriptCompressor() - +Constructor for class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor +
  +
YuiJavaScriptCompressor.DefaultErrorReporter - Class in com.googlecode.htmlcompressor.compressor
Default ErrorReporter implementation that uses System.err + stream for error reporting.
YuiJavaScriptCompressor.DefaultErrorReporter() - +Constructor for class com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.DefaultErrorReporter +
  +
+
+A B C D E G H I J M P R S T W X Y + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..3875cc4 --- /dev/null +++ b/doc/index.html @@ -0,0 +1,39 @@ + + + + + + +HTML Compressor and Minifier 1.5.2 API + + + + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to<A HREF="overview-summary.html">Non-frame version.</A> + + + diff --git a/doc/options b/doc/options new file mode 100644 index 0000000..c346e1c --- /dev/null +++ b/doc/options @@ -0,0 +1,25 @@ +-classpath +'D:/www/htmlcompressor/target/classes;C:/Users/serg/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar;C:/Users/serg/.m2/repository/org/apache/velocity/velocity-tools/2.0/velocity-tools-2.0.jar;C:/Users/serg/.m2/repository/commons-collections/commons-collections/3.2/commons-collections-3.2.jar;C:/Users/serg/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar;C:/Users/serg/.m2/repository/dom4j/dom4j/1.1/dom4j-1.1.jar;C:/Users/serg/.m2/repository/org/apache/struts/struts-tiles/1.3.8/struts-tiles-1.3.8.jar;C:/Users/serg/.m2/repository/com/google/guava/guava/r08/guava-r08.jar;C:/Users/serg/.m2/repository/commons-logging/commons-logging/1.1/commons-logging-1.1.jar;C:/Users/serg/.m2/repository/commons-digester/commons-digester/1.8/commons-digester-1.8.jar;C:/Users/serg/.m2/repository/antlr/antlr/2.7.2/antlr-2.7.2.jar;C:/Users/serg/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar;C:/Users/serg/.m2/repository/commons-validator/commons-validator/1.3.1/commons-validator-1.3.1.jar;C:/Users/serg/.m2/repository/args4j/args4j/2.0.12/args4j-2.0.12.jar;C:/Users/serg/.m2/repository/rhino/js/1.6R7/js-1.6R7.jar;C:/Users/serg/.m2/repository/commons-chain/commons-chain/1.1/commons-chain-1.1.jar;C:/Users/serg/.m2/repository/org/json/json/20090211/json-20090211.jar;C:/Users/serg/.m2/repository/org/apache/ant/ant-launcher/1.8.1/ant-launcher-1.8.1.jar;C:/Users/serg/.m2/repository/com/google/protobuf/protobuf-java/2.3.0/protobuf-java-2.3.0.jar;C:/Users/serg/.m2/repository/com/yahoo/platform/yui/yuicompressor/2.4.6/yuicompressor-2.4.6.jar;C:/Users/serg/.m2/repository/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar;C:/Users/serg/.m2/repository/org/apache/ant/ant/1.8.1/ant-1.8.1.jar;C:/Users/serg/.m2/repository/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar;C:/Users/serg/.m2/repository/org/apache/struts/struts-core/1.3.8/struts-core-1.3.8.jar;C:/Users/serg/.m2/repository/com/google/javascript/closure-compiler/r1043/closure-compiler-r1043.jar;C:/Users/serg/.m2/repository/org/apache/velocity/velocity/1.6.2/velocity-1.6.2.jar;C:/Users/serg/.m2/repository/org/apache/struts/struts-taglib/1.3.8/struts-taglib-1.3.8.jar;C:/Users/serg/.m2/repository/sslext/sslext/1.2-0/sslext-1.2-0.jar;C:/Users/serg/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar' +-encoding +'UTF-8' +-public +-sourcepath +'D:/www/htmlcompressor/src/main/java' +-author +-bottom +'Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved.' +-charset +'UTF-8' +-d +'D:/www/htmlcompressor/target/apidocs' +-docencoding +'UTF-8' +-doctitle +'HTML Compressor and Minifier 1.5.2 API' +-linkoffline +'http://download.oracle.com/javase/6/docs/api' 'D:/www/htmlcompressor/target/javadoc-bundle-options' +-notimestamp +-use +-version +-windowtitle +'HTML Compressor and Minifier 1.5.2 API' \ No newline at end of file diff --git a/doc/overview-frame.html b/doc/overview-frame.html new file mode 100644 index 0000000..daab4a1 --- /dev/null +++ b/doc/overview-frame.html @@ -0,0 +1,49 @@ + + + + + + +Overview List (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + + + + +
+
+ + + + + +
All Classes +

+ +Packages +
+com.googlecode.htmlcompressor +
+com.googlecode.htmlcompressor.analyzer +
+com.googlecode.htmlcompressor.compressor +
+com.googlecode.htmlcompressor.taglib +
+com.googlecode.htmlcompressor.velocity +
+

+ +

+  + + diff --git a/doc/overview-summary.html b/doc/overview-summary.html new file mode 100644 index 0000000..41f0c40 --- /dev/null +++ b/doc/overview-summary.html @@ -0,0 +1,171 @@ + + + + + + +Overview (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+HTML Compressor and Minifier 1.5.2 API +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+Packages
com.googlecode.htmlcompressor 
com.googlecode.htmlcompressor.analyzer 
com.googlecode.htmlcompressor.compressor 
com.googlecode.htmlcompressor.taglib 
com.googlecode.htmlcompressor.velocity 
+ +


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/overview-tree.html b/doc/overview-tree.html new file mode 100644 index 0000000..0971395 --- /dev/null +++ b/doc/overview-tree.html @@ -0,0 +1,171 @@ + + + + + + +Class Hierarchy (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
com.googlecode.htmlcompressor, com.googlecode.htmlcompressor.analyzer, com.googlecode.htmlcompressor.compressor, com.googlecode.htmlcompressor.taglib, com.googlecode.htmlcompressor.velocity
+
+

+Class Hierarchy +

+ +

+Interface Hierarchy +

+
    +
  • com.googlecode.htmlcompressor.compressor.Compressor
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/package-list b/doc/package-list new file mode 100644 index 0000000..809f89b --- /dev/null +++ b/doc/package-list @@ -0,0 +1,5 @@ +com.googlecode.htmlcompressor +com.googlecode.htmlcompressor.analyzer +com.googlecode.htmlcompressor.compressor +com.googlecode.htmlcompressor.taglib +com.googlecode.htmlcompressor.velocity diff --git a/doc/packages b/doc/packages new file mode 100644 index 0000000..05d74de --- /dev/null +++ b/doc/packages @@ -0,0 +1,5 @@ +com.googlecode.htmlcompressor.analyzer +com.googlecode.htmlcompressor +com.googlecode.htmlcompressor.compressor +com.googlecode.htmlcompressor.taglib +com.googlecode.htmlcompressor.velocity \ No newline at end of file diff --git a/doc/resources/inherit.gif b/doc/resources/inherit.gif new file mode 100644 index 0000000..c814867 Binary files /dev/null and b/doc/resources/inherit.gif differ diff --git a/doc/serialized-form.html b/doc/serialized-form.html new file mode 100644 index 0000000..7e9793a --- /dev/null +++ b/doc/serialized-form.html @@ -0,0 +1,556 @@ + + + + + + +Serialized Form (HTML Compressor and Minifier 1.5.2 API) + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Serialized Form

+
+
+ + + + + +
+Package com.googlecode.htmlcompressor.taglib
+ +

+ + + + + +
+Class com.googlecode.htmlcompressor.taglib.CssCompressorTag extends javax.servlet.jsp.tagext.BodyTagSupport implements Serializable
+ +

+ + + + + +
+Serialized Fields
+ +

+enabled

+
+boolean enabled
+
+
+
+
+
+

+yuiCssLineBreak

+
+int yuiCssLineBreak
+
+
+
+
+ +

+ + + + + +
+Class com.googlecode.htmlcompressor.taglib.HtmlCompressorTag extends javax.servlet.jsp.tagext.BodyTagSupport implements Serializable
+ +

+ + + + + +
+Serialized Fields
+ +

+enabled

+
+boolean enabled
+
+
+
+
+
+

+removeComments

+
+boolean removeComments
+
+
+
+
+
+

+removeMultiSpaces

+
+boolean removeMultiSpaces
+
+
+
+
+
+

+removeIntertagSpaces

+
+boolean removeIntertagSpaces
+
+
+
+
+
+

+removeQuotes

+
+boolean removeQuotes
+
+
+
+
+
+

+preserveLineBreaks

+
+boolean preserveLineBreaks
+
+
+
+
+
+

+simpleDoctype

+
+boolean simpleDoctype
+
+
+
+
+
+

+removeScriptAttributes

+
+boolean removeScriptAttributes
+
+
+
+
+
+

+removeStyleAttributes

+
+boolean removeStyleAttributes
+
+
+
+
+
+

+removeLinkAttributes

+
+boolean removeLinkAttributes
+
+
+
+
+
+

+removeFormAttributes

+
+boolean removeFormAttributes
+
+
+
+
+
+

+removeInputAttributes

+
+boolean removeInputAttributes
+
+
+
+
+
+

+simpleBooleanAttributes

+
+boolean simpleBooleanAttributes
+
+
+
+
+
+

+removeJavaScriptProtocol

+
+boolean removeJavaScriptProtocol
+
+
+
+
+
+

+removeHttpProtocol

+
+boolean removeHttpProtocol
+
+
+
+
+
+

+removeHttpsProtocol

+
+boolean removeHttpsProtocol
+
+
+
+
+
+

+compressJavaScript

+
+boolean compressJavaScript
+
+
+
+
+
+

+compressCss

+
+boolean compressCss
+
+
+
+
+
+

+jsCompressor

+
+String jsCompressor
+
+
+
+
+
+

+yuiJsNoMunge

+
+boolean yuiJsNoMunge
+
+
+
+
+
+

+yuiJsPreserveAllSemiColons

+
+boolean yuiJsPreserveAllSemiColons
+
+
+
+
+
+

+yuiJsDisableOptimizations

+
+boolean yuiJsDisableOptimizations
+
+
+
+
+
+

+yuiJsLineBreak

+
+int yuiJsLineBreak
+
+
+
+
+
+

+yuiCssLineBreak

+
+int yuiCssLineBreak
+
+
+
+
+
+

+closureOptLevel

+
+String closureOptLevel
+
+
+
+
+ +

+ + + + + +
+Class com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag extends javax.servlet.jsp.tagext.BodyTagSupport implements Serializable
+ +

+ + + + + +
+Serialized Fields
+ +

+enabled

+
+boolean enabled
+
+
+
+
+
+

+jsCompressor

+
+String jsCompressor
+
+
+
+
+
+

+yuiJsNoMunge

+
+boolean yuiJsNoMunge
+
+
+
+
+
+

+yuiJsPreserveAllSemiColons

+
+boolean yuiJsPreserveAllSemiColons
+
+
+
+
+
+

+yuiJsDisableOptimizations

+
+boolean yuiJsDisableOptimizations
+
+
+
+
+
+

+yuiJsLineBreak

+
+int yuiJsLineBreak
+
+
+
+
+
+

+closureOptLevel

+
+String closureOptLevel
+
+
+
+
+ +

+ + + + + +
+Class com.googlecode.htmlcompressor.taglib.XmlCompressorTag extends javax.servlet.jsp.tagext.BodyTagSupport implements Serializable
+ +

+ + + + + +
+Serialized Fields
+ +

+enabled

+
+boolean enabled
+
+
+
+
+
+

+removeComments

+
+boolean removeComments
+
+
+
+
+
+

+removeIntertagSpaces

+
+boolean removeIntertagSpaces
+
+
+
+
+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2009-2011 Sergiy Kovalchuk. All Rights Reserved. + + diff --git a/doc/stylesheet.css b/doc/stylesheet.css new file mode 100644 index 0000000..cbd3428 --- /dev/null +++ b/doc/stylesheet.css @@ -0,0 +1,29 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF; color:#000000 } + +/* Headings */ +h1 { font-size: 145% } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ +.TableRowColor { background: #FFFFFF; color:#000000 } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } +.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ +.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} + diff --git a/lib/compiler.jar b/lib/compiler.jar new file mode 100644 index 0000000..694808c Binary files /dev/null and b/lib/compiler.jar differ diff --git a/lib/jsp-api.jar b/lib/jsp-api.jar new file mode 100644 index 0000000..eac9e56 Binary files /dev/null and b/lib/jsp-api.jar differ diff --git a/lib/junit-4.8.2.jar b/lib/junit-4.8.2.jar new file mode 100644 index 0000000..5b4bb84 Binary files /dev/null and b/lib/junit-4.8.2.jar differ diff --git a/lib/velocity-1.7.jar b/lib/velocity-1.7.jar new file mode 100644 index 0000000..ae936d3 Binary files /dev/null and b/lib/velocity-1.7.jar differ diff --git a/lib/yuicompressor-2.4.6.jar b/lib/yuicompressor-2.4.6.jar new file mode 100644 index 0000000..61f6318 Binary files /dev/null and b/lib/yuicompressor-2.4.6.jar differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..c12ddc8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,306 @@ + + 4.0.0 + + + org.sonatype.oss + oss-parent + 7 + + + + + + com.googlecode.htmlcompressor + htmlcompressor + 1.5.3-SNAPSHOT + jar + + + + + + + com.google.javascript + closure-compiler + r1043 + true + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + org.apache.velocity + velocity-tools + 2.0 + provided + + + com.yahoo.platform.yui + yuicompressor + 2.4.6 + true + + + junit + junit + 4.8.2 + test + + + + + + + + UTF-8 + + + + + + + ${project.artifactId}-${project.version} + + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.0.1 + + + enforce-versions + + enforce + + + + + 2.2.1 + + + 1.5 + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.5 + UTF-8 + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + + + true + com.googlecode.htmlcompressor.CmdLineCompressor + + + yuicompressor-2.4.2.jar yuicompressor-2.4.3.jar yuicompressor-2.4.4.jar yuicompressor-2.4.5.jar yuicompressor-2.4.6.jar yuicompressor-2.4.7.jar yuicompressor-2.4.8.jar yuicompressor-2.4.9.jar yuicompressor.jar compiler.jar + + + + + + + org.apache.maven.plugins + maven-install-plugin + 2.3.1 + + true + + + + + org.apache.maven.plugins + maven-release-plugin + 2.1 + + forked-path + scm:svn:http://htmlcompressor.googlecode.com/svn/trunk/ + + + + + maven-assembly-plugin + 2.2.1 + + false + + src/main/assembly/distributive.xml + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + public + jargs + true + + + + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.6 + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + public + jargs + + + + + + + + + HTML Compressor and Minifier + HtmlCompressor is a small, fast and very easy to use Java library that minifies given HTML or XML source by removing extra whitespaces, comments and other unneeded characters without breaking the content structure. As a result pages become smaller in size and load faster. A command-line version of the compressor is also available. + http://code.google.com/p/htmlcompressor/ + 2009 + + + Apache License 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + repo + htmlcompressor is distributed under Apache License 2.0 + + + + Sergiy Kovalchuk + http://code.google.com/p/htmlcompressor/ + + + + serg472 + Sergiy Kovalchuk + serg472@gmail.com + http://code.google.com/p/htmlcompressor/ + Sergiy Kovalchuk + http://code.google.com/p/htmlcompressor/ + + owner + developer + + -8 + + + + + Alex Tunyk + alextunyk@gmail.com + http://alex.tunyk.com + TUNYK.COM + http://tunyk.com + + developer + + +2 + + + + + + + + Google Code - Issue Tracking + http://code.google.com/p/htmlcompressor/issues/list + + + scm:svn:http://htmlcompressor.googlecode.com/svn/trunk/ + scm:svn:https://htmlcompressor.googlecode.com/svn/trunk/ + http://code.google.com/p/htmlcompressor/source/browse/ + + + + + + + + release-sign-artifacts + + + performRelease + true + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.3 + + + sign-artifacts + verify + + sign + + + + + + + + + doc-folder-generation + + + + + maven-resources-plugin + 2.5 + + + copy-resources + validate + + copy-resources + + + doc + + + target/apidocs + + + + + + + + + + + diff --git a/src/main/assembly/distributive.xml b/src/main/assembly/distributive.xml new file mode 100644 index 0000000..75079ec --- /dev/null +++ b/src/main/assembly/distributive.xml @@ -0,0 +1,45 @@ + + distribution + + zip + + + + ${project.basedir}/src + + + ${project.basedir} + + pom.xml + build.sh + build.bat + *.txt + + + README.txt + + + + ${project.build.directory} + bin + + *.jar + + + + ${project.build.directory}/apidocs + doc + + + ${project.basedir}/lib + + + + + README.txt + true + + + \ No newline at end of file diff --git a/src/main/java/com/googlecode/htmlcompressor/CmdLineCompressor.java b/src/main/java/com/googlecode/htmlcompressor/CmdLineCompressor.java new file mode 100644 index 0000000..075e4a9 --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/CmdLineCompressor.java @@ -0,0 +1,669 @@ +package com.googlecode.htmlcompressor; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import jargs.gnu.CmdLineParser; +import jargs.gnu.CmdLineParser.Option; +import jargs.gnu.CmdLineParser.OptionException; + +import java.io.BufferedReader; +import java.io.Closeable; +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Stack; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; + +import com.google.javascript.jscomp.CompilationLevel; +import com.google.javascript.jscomp.JSSourceFile; +import com.googlecode.htmlcompressor.analyzer.HtmlAnalyzer; +import com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor; +import com.googlecode.htmlcompressor.compressor.Compressor; +import com.googlecode.htmlcompressor.compressor.HtmlCompressor; +import com.googlecode.htmlcompressor.compressor.XmlCompressor; + +/** + * Wrapper for HTML and XML compressor classes that allows using them from a command line. + * + *

Usage: java -jar htmlcompressor.jar [options] [input] + *

To view a list of all available parameters please run with -? option: + *

java -jar htmlcompressor.jar -? + * + * @author Sergiy Kovalchuk + */ +public class CmdLineCompressor { + + private static final Pattern urlPattern = Pattern.compile("^https?://.*$", Pattern.CASE_INSENSITIVE); + + private boolean helpOpt; + private boolean analyzeOpt; + private String charsetOpt; + private String outputFilenameOpt; + private String patternsFilenameOpt; + private String typeOpt; + private String filemaskOpt; + private boolean recursiveOpt; + private boolean preserveCommentsOpt; + private boolean preserveIntertagSpacesOpt; + private boolean preserveMultiSpacesOpt; + private boolean removeIntertagSpacesOpt; + private boolean removeQuotesOpt; + private String removeSurroundingSpacesOpt; + private boolean preserveLineBreaksOpt; + private boolean preservePhpTagsOpt; + private boolean preserveServerScriptTagsOpt; + private boolean preserveSsiTagsOpt; + private boolean compressJsOpt; + private boolean compressCssOpt; + private String jsCompressorOpt; + + private boolean simpleDoctypeOpt; + private boolean removeScriptAttributesOpt; + private boolean removeStyleAttributesOpt; + private boolean removeLinkAttributesOpt; + private boolean removeFormAttributesOpt; + private boolean removeInputAttributesOpt; + private boolean simpleBooleanAttributesOpt; + private boolean removeJavaScriptProtocolOpt; + private boolean removeHttpProtocolOpt; + private boolean removeHttpsProtocolOpt; + + private boolean nomungeOpt; + private int linebreakOpt; + private boolean preserveSemiOpt; + private boolean disableOptimizationsOpt; + + private String closureOptLevelOpt; + private boolean closureCustomExternsOnlyOpt; + private List closureExternsOpt; + + private String[] fileArgsOpt; + + public static void main(String[] args) { + CmdLineCompressor cmdLineCompressor = new CmdLineCompressor(args); + cmdLineCompressor.process(args); + } + + public CmdLineCompressor(String[] args) { + CmdLineParser parser = new CmdLineParser(); + + Option helpOpt = parser.addBooleanOption('h', "help"); + Option helpOptAlt = parser.addBooleanOption('?', "help_alt"); + Option analyzeOpt = parser.addBooleanOption('a', "analyze"); + Option recursiveOpt = parser.addBooleanOption('r', "recursive"); + Option charsetOpt = parser.addStringOption('c', "charset"); + Option outputFilenameOpt = parser.addStringOption('o', "output"); + Option patternsFilenameOpt = parser.addStringOption('p', "preserve"); + Option typeOpt = parser.addStringOption('t', "type"); + Option filemaskOpt = parser.addStringOption('m', "mask"); + Option preserveCommentsOpt = parser.addBooleanOption("preserve-comments"); + Option preserveIntertagSpacesOpt = parser.addBooleanOption("preserve-intertag-spaces"); + Option preserveMultiSpacesOpt = parser.addBooleanOption("preserve-multi-spaces"); + Option removeIntertagSpacesOpt = parser.addBooleanOption("remove-intertag-spaces"); + Option removeSurroundingSpacesOpt = parser.addStringOption("remove-surrounding-spaces"); + Option removeQuotesOpt = parser.addBooleanOption("remove-quotes"); + Option preserveLineBreaksOpt = parser.addBooleanOption("preserve-line-breaks"); + Option preservePhpTagsOpt = parser.addBooleanOption("preserve-php"); + Option preserveServerScriptTagsOpt = parser.addBooleanOption("preserve-server-script"); + Option preserveSsiTagsOpt = parser.addBooleanOption("preserve-ssi"); + Option compressJsOpt = parser.addBooleanOption("compress-js"); + Option compressCssOpt = parser.addBooleanOption("compress-css"); + Option jsCompressorOpt = parser.addStringOption("js-compressor"); + + Option simpleDoctypeOpt = parser.addBooleanOption("simple-doctype"); + Option removeScriptAttributesOpt = parser.addBooleanOption("remove-script-attr"); + Option removeStyleAttributesOpt = parser.addBooleanOption("remove-style-attr"); + Option removeLinkAttributesOpt = parser.addBooleanOption("remove-link-attr"); + Option removeFormAttributesOpt = parser.addBooleanOption("remove-form-attr"); + Option removeInputAttributesOpt = parser.addBooleanOption("remove-input-attr"); + Option simpleBooleanAttributesOpt = parser.addBooleanOption("simple-bool-attr"); + Option removeJavaScriptProtocolOpt = parser.addBooleanOption("remove-js-protocol"); + Option removeHttpProtocolOpt = parser.addBooleanOption("remove-http-protocol"); + Option removeHttpsProtocolOpt = parser.addBooleanOption("remove-https-protocol"); + + Option nomungeOpt = parser.addBooleanOption("nomunge"); + Option linebreakOpt = parser.addStringOption("line-break"); + Option preserveSemiOpt = parser.addBooleanOption("preserve-semi"); + Option disableOptimizationsOpt = parser.addBooleanOption("disable-optimizations"); + + Option closureOptLevelOpt = parser.addStringOption("closure-opt-level"); + Option closureCustomExternsOnlyOpt = parser.addBooleanOption("closure-custom-externs-only"); + Option closureExternsOpt = parser.addStringOption("closure-externs"); + + try { + parser.parse(args); + + this.helpOpt = (Boolean)parser.getOptionValue(helpOpt, false) || (Boolean)parser.getOptionValue(helpOptAlt, false); + this.analyzeOpt = (Boolean)parser.getOptionValue(analyzeOpt, false); + this.recursiveOpt = (Boolean)parser.getOptionValue(recursiveOpt, false); + this.charsetOpt = (String)parser.getOptionValue(charsetOpt, "UTF-8"); + this.outputFilenameOpt = (String)parser.getOptionValue(outputFilenameOpt); + this.patternsFilenameOpt = (String)parser.getOptionValue(patternsFilenameOpt); + this.typeOpt = (String)parser.getOptionValue(typeOpt); + this.filemaskOpt = (String)parser.getOptionValue(filemaskOpt); + this.preserveCommentsOpt = (Boolean)parser.getOptionValue(preserveCommentsOpt, false); + this.preserveIntertagSpacesOpt = (Boolean)parser.getOptionValue(preserveIntertagSpacesOpt, false); + this.preserveMultiSpacesOpt = (Boolean)parser.getOptionValue(preserveMultiSpacesOpt, false); + this.removeIntertagSpacesOpt = (Boolean)parser.getOptionValue(removeIntertagSpacesOpt, false); + this.removeQuotesOpt = (Boolean)parser.getOptionValue(removeQuotesOpt, false); + this.preserveLineBreaksOpt = (Boolean)parser.getOptionValue(preserveLineBreaksOpt, false); + this.preservePhpTagsOpt = (Boolean)parser.getOptionValue(preservePhpTagsOpt, false); + this.preserveServerScriptTagsOpt = (Boolean)parser.getOptionValue(preserveServerScriptTagsOpt, false); + this.preserveSsiTagsOpt = (Boolean)parser.getOptionValue(preserveSsiTagsOpt, false); + this.compressJsOpt = (Boolean)parser.getOptionValue(compressJsOpt, false); + this.compressCssOpt = (Boolean)parser.getOptionValue(compressCssOpt, false); + this.jsCompressorOpt = (String)parser.getOptionValue(jsCompressorOpt, HtmlCompressor.JS_COMPRESSOR_YUI); + + this.simpleDoctypeOpt = (Boolean)parser.getOptionValue(simpleDoctypeOpt, false); + this.removeScriptAttributesOpt = (Boolean)parser.getOptionValue(removeScriptAttributesOpt, false); + this.removeStyleAttributesOpt = (Boolean)parser.getOptionValue(removeStyleAttributesOpt, false); + this.removeLinkAttributesOpt = (Boolean)parser.getOptionValue(removeLinkAttributesOpt, false); + this.removeFormAttributesOpt = (Boolean)parser.getOptionValue(removeFormAttributesOpt, false); + this.removeInputAttributesOpt = (Boolean)parser.getOptionValue(removeInputAttributesOpt, false); + this.simpleBooleanAttributesOpt = (Boolean)parser.getOptionValue(simpleBooleanAttributesOpt, false); + this.removeJavaScriptProtocolOpt = (Boolean)parser.getOptionValue(removeJavaScriptProtocolOpt, false); + this.removeHttpProtocolOpt = (Boolean)parser.getOptionValue(removeHttpProtocolOpt, false); + this.removeHttpsProtocolOpt = (Boolean)parser.getOptionValue(removeHttpsProtocolOpt, false); + + this.nomungeOpt = (Boolean)parser.getOptionValue(nomungeOpt, false); + this.linebreakOpt = (Integer)parser.getOptionValue(linebreakOpt, -1); + this.preserveSemiOpt = (Boolean)parser.getOptionValue(preserveSemiOpt, false); + this.disableOptimizationsOpt = (Boolean)parser.getOptionValue(disableOptimizationsOpt, false); + + this.closureOptLevelOpt = (String)parser.getOptionValue(closureOptLevelOpt, ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE); + this.closureCustomExternsOnlyOpt = (Boolean)parser.getOptionValue(closureCustomExternsOnlyOpt, false); + + this.closureExternsOpt = parser.getOptionValues(closureExternsOpt); + + this.removeSurroundingSpacesOpt = (String)parser.getOptionValue(removeSurroundingSpacesOpt); + if(this.removeSurroundingSpacesOpt != null) { + if(this.removeSurroundingSpacesOpt.equalsIgnoreCase("min")) { + this.removeSurroundingSpacesOpt = HtmlCompressor.BLOCK_TAGS_MIN; + } else if(this.removeSurroundingSpacesOpt.equalsIgnoreCase("max")) { + this.removeSurroundingSpacesOpt = HtmlCompressor.BLOCK_TAGS_MAX; + } else if(this.removeSurroundingSpacesOpt.equalsIgnoreCase("all")) { + this.removeSurroundingSpacesOpt = HtmlCompressor.ALL_TAGS; + } + } + + //input file + this.fileArgsOpt = parser.getRemainingArgs(); + + //charset + this.charsetOpt = Charset.isSupported(this.charsetOpt) ? this.charsetOpt : "UTF-8"; + + //look for "/?" + for(int i=0;i 0 ? fileArgsOpt[0] : null))); + } else { + //compression mode + Compressor compressor = type.equals("xml") ? createXmlCompressor() : createHtmlCompressor(); + Map ioMap = buildInputOutputMap(); + for (Map.Entry entry : ioMap.entrySet()) { + writeResource(compressor.compress(readResource(buildReader(entry.getKey()))), buildWriter(entry.getValue())); + } + } + + } catch (NoClassDefFoundError e){ + if(HtmlCompressor.JS_COMPRESSOR_CLOSURE.equalsIgnoreCase(jsCompressorOpt)) { + System.out.println("ERROR: For JavaScript compression using Google Closure Compiler\n" + + "additional jar file called compiler.jar must be present\n" + + "in the same directory as HtmlCompressor jar"); + } else { + System.out.println("ERROR: For CSS or JavaScript compression using YUICompressor additional jar file \n" + + "called yuicompressor.jar must be present\n" + + "in the same directory as HtmlCompressor jar"); + } + } catch (OptionException e) { + System.out.println("ERROR: " + e.getMessage()); + printUsage(); + } catch (IOException e) { + System.out.println("ERROR: " + e.getMessage()); + } catch (IllegalArgumentException e) { + System.out.println("ERROR: " + e.getMessage()); + } + + } + + private Compressor createHtmlCompressor() throws IllegalArgumentException, OptionException { + + boolean useClosureCompressor = HtmlCompressor.JS_COMPRESSOR_CLOSURE.equalsIgnoreCase(jsCompressorOpt); + + //custom preserve patterns + List preservePatterns = new ArrayList(); + + //predefined + if(preservePhpTagsOpt) { + preservePatterns.add(HtmlCompressor.PHP_TAG_PATTERN); + } + + if(preserveServerScriptTagsOpt) { + preservePatterns.add(HtmlCompressor.SERVER_SCRIPT_TAG_PATTERN); + } + + if(preserveSsiTagsOpt) { + preservePatterns.add(HtmlCompressor.SERVER_SIDE_INCLUDE_PATTERN); + } + + if(patternsFilenameOpt != null) { + + BufferedReader patternsIn = null; + try { + + //read input file + patternsIn = new BufferedReader(new InputStreamReader(new FileInputStream(patternsFilenameOpt), charsetOpt)); + + String line = null; + while ((line = patternsIn.readLine()) != null){ + if(line.length() > 0) { + try { + preservePatterns.add(Pattern.compile(line)); + } catch (PatternSyntaxException e) { + throw new IllegalArgumentException("Regular expression compilation error: " + e.getMessage()); + } + } + } + } catch (IOException e) { + throw new IllegalArgumentException("Unable to read custom pattern definitions file: " + e.getMessage()); + } finally { + closeStream(patternsIn); + } + } + + //set compressor options + HtmlCompressor htmlCompressor = new HtmlCompressor(); + + htmlCompressor.setRemoveComments(!preserveCommentsOpt); + htmlCompressor.setRemoveMultiSpaces(!preserveMultiSpacesOpt); + htmlCompressor.setRemoveIntertagSpaces(removeIntertagSpacesOpt); + htmlCompressor.setRemoveQuotes(removeQuotesOpt); + htmlCompressor.setPreserveLineBreaks(preserveLineBreaksOpt); + htmlCompressor.setCompressJavaScript(compressJsOpt); + htmlCompressor.setCompressCss(compressCssOpt); + + htmlCompressor.setSimpleDoctype(simpleDoctypeOpt); + htmlCompressor.setRemoveScriptAttributes(removeScriptAttributesOpt); + htmlCompressor.setRemoveStyleAttributes(removeStyleAttributesOpt); + htmlCompressor.setRemoveLinkAttributes(removeLinkAttributesOpt); + htmlCompressor.setRemoveFormAttributes(removeFormAttributesOpt); + htmlCompressor.setRemoveInputAttributes(removeInputAttributesOpt); + htmlCompressor.setSimpleBooleanAttributes(simpleBooleanAttributesOpt); + htmlCompressor.setRemoveJavaScriptProtocol(removeJavaScriptProtocolOpt); + htmlCompressor.setRemoveHttpProtocol(removeHttpProtocolOpt); + htmlCompressor.setRemoveHttpsProtocol(removeHttpsProtocolOpt); + htmlCompressor.setRemoveSurroundingSpaces(removeSurroundingSpacesOpt); + + htmlCompressor.setPreservePatterns(preservePatterns); + + htmlCompressor.setYuiJsNoMunge(nomungeOpt); + htmlCompressor.setYuiJsPreserveAllSemiColons(preserveSemiOpt); + htmlCompressor.setYuiJsDisableOptimizations(disableOptimizationsOpt); + htmlCompressor.setYuiJsLineBreak(linebreakOpt); + htmlCompressor.setYuiCssLineBreak(linebreakOpt); + + //switch js compressor to closure + if(compressJsOpt && useClosureCompressor) { + ClosureJavaScriptCompressor closureCompressor = new ClosureJavaScriptCompressor(); + + if(closureOptLevelOpt.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_ADVANCED)) { + closureCompressor.setCompilationLevel(CompilationLevel.ADVANCED_OPTIMIZATIONS); + closureCompressor.setCustomExternsOnly(closureCustomExternsOnlyOpt); + + //get externs + if(closureExternsOpt.size() > 0) { + List externs = new ArrayList(); + for(String externFile : closureExternsOpt) { + externs.add(JSSourceFile.fromFile(externFile)); + } + closureCompressor.setExterns(externs); + } + } else if(closureOptLevelOpt.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_WHITESPACE)) { + closureCompressor.setCompilationLevel(CompilationLevel.WHITESPACE_ONLY); + } else { + closureCompressor.setCompilationLevel(CompilationLevel.SIMPLE_OPTIMIZATIONS); + } + + htmlCompressor.setJavaScriptCompressor(closureCompressor); + } + + return htmlCompressor; + } + + private Compressor createXmlCompressor() throws IllegalArgumentException, OptionException { + XmlCompressor xmlCompressor = new XmlCompressor(); + xmlCompressor.setRemoveComments(!preserveCommentsOpt); + xmlCompressor.setRemoveIntertagSpaces(!preserveIntertagSpacesOpt); + + return xmlCompressor; + } + + private Map buildInputOutputMap() throws IllegalArgumentException, IOException { + Map map = new HashMap(); + + File outpuFile = null; + if(outputFilenameOpt != null) { + outpuFile = new File(outputFilenameOpt); + + //make dirs + if(outputFilenameOpt.endsWith("/") || outputFilenameOpt.endsWith("\\")) { + outpuFile.mkdirs(); + } else { + (new File(outpuFile.getCanonicalFile().getParent())).mkdirs(); + } + } + + if(fileArgsOpt.length > 1 && (outpuFile == null || !outpuFile.isDirectory())) { + throw new IllegalArgumentException("Output must be a directory and end with a slash (/)"); + } + + if(fileArgsOpt.length == 0) { + map.put(null, outputFilenameOpt); + } else { + for(int i=0; i fileStack = new Stack(); + fileStack.push(inputFile); + while(!fileStack.isEmpty()) { + File child = fileStack.pop(); + if (child.isDirectory()) { + for(File f : child.listFiles(new CompressorFileFilter(typeOpt, filemaskOpt, true))) { + fileStack.push(f); + } + } else if (child.isFile()) { + String from = child.getCanonicalPath(); + String to = from.replaceFirst(escRegEx(inputFile.getCanonicalPath()), Matcher.quoteReplacement(outpuFile.getCanonicalPath())); + map.put(from, to); + //make dirs + (new File((new File(to)).getCanonicalFile().getParent())).mkdirs(); + } + } + } + } else { + throw new IllegalArgumentException("Output must be a directory and end with a slash (/)"); + } + } else { + //is file + if(outpuFile != null && outpuFile.isDirectory()) { + String from = inputFile.getCanonicalPath(); + String to = from.replaceFirst(escRegEx(inputFile.getCanonicalFile().getParentFile().getCanonicalPath()), Matcher.quoteReplacement(outpuFile.getCanonicalPath())); + map.put(fileArgsOpt[i], to); + } else { + map.put(fileArgsOpt[i], outputFilenameOpt); + } + + } + } else { + //is url + if(fileArgsOpt.length == 1 && (outpuFile == null || !outpuFile.isDirectory())) { + map.put(fileArgsOpt[i], outputFilenameOpt); + } else { + throw new IllegalArgumentException("Input URL should be single and cannot have directory as output"); + } + } + } + } + + return map; + } + + private BufferedReader buildReader(String filename) throws IOException { + + if (filename == null) { + return new BufferedReader(new InputStreamReader(System.in, charsetOpt)); + } else if(urlPattern.matcher(filename).matches()) { + return new BufferedReader(new InputStreamReader((new URL(filename)).openConnection().getInputStream())); + } else { + return new BufferedReader(new InputStreamReader(new FileInputStream(filename), charsetOpt)); + } + } + + private Writer buildWriter(String filename) throws IOException { + if (filename == null) { + return new OutputStreamWriter(System.out, charsetOpt); + } else { + return new OutputStreamWriter(new FileOutputStream(filename), charsetOpt); + } + } + + private String readResource(BufferedReader input) throws IOException { + + StringBuilder source = new StringBuilder(); + try { + String line = null; + while ((line = input.readLine()) != null){ + source.append(line); + source.append(System.getProperty("line.separator")); + } + + } finally { + closeStream(input); + } + + return source.toString(); + } + + private void writeResource(String content, Writer output) throws IOException { + try { + output.write(content); + } finally { + closeStream(output); + } + } + + private void closeStream(Closeable stream) { + if (stream != null) { + try { + stream.close(); + } catch (IOException ignore) {} + } + } + + private String escRegEx(String inStr) { + return inStr.replaceAll("([\\\\*+\\[\\](){}\\$.?\\^|])", "\\\\$1"); + } + + private void printUsage() { + System.out.println("Usage: java -jar htmlcompressor.jar [options] [input]\n\n" + + + "[input] URL, filename, directory, or space separated list\n" + + " of files and directories to compress.\n" + + " If none provided reads from \n\n" + + + "Global Options:\n" + + " -?, /?, -h, --help Displays this help screen\n" + + " -t, --type If not provided autodetects from file extension\n" + + " -r, --recursive Process files inside subdirectories\n" + + " -c, --charset Charset for reading files, UTF-8 by default\n" + + " -m, --mask Filter input files inside directories by mask\n" + + " -o, --output Filename or directory for compression results.\n" + + " If none provided outputs result to \n" + + " -a, --analyze Tries different settings and displays report.\n" + + " All settings except --js-compressor are ignored\n\n" + + + "XML Compression Options:\n" + + " --preserve-comments Preserve comments\n" + + " --preserve-intertag-spaces Preserve intertag spaces\n\n" + + + "HTML Compression Options:\n" + + " --preserve-comments Preserve comments\n" + + " --preserve-multi-spaces Preserve multiple spaces\n" + + " --preserve-line-breaks Preserve line breaks\n" + + " --remove-intertag-spaces Remove intertag spaces\n" + + " --remove-quotes Remove unneeded quotes\n" + + " --simple-doctype Change doctype to \n" + + " --remove-style-attr Remove TYPE attribute from STYLE tags\n" + + " --remove-link-attr Remove TYPE attribute from LINK tags\n" + + " --remove-script-attr Remove TYPE and LANGUAGE from SCRIPT tags\n" + + " --remove-form-attr Remove METHOD=\"GET\" from FORM tags\n" + + " --remove-input-attr Remove TYPE=\"TEXT\" from INPUT tags\n" + + " --simple-bool-attr Remove values from boolean tag attributes\n" + + " --remove-js-protocol Remove \"javascript:\" from inline event handlers\n" + + " --remove-http-protocol Remove \"http:\" from tag attributes\n" + + " --remove-https-protocol Remove \"https:\" from tag attributes\n" + + " --remove-surrounding-spaces \n" + + " Predefined or custom comma separated list of tags\n" + + " --compress-js Enable inline JavaScript compression\n" + + " --compress-css Enable inline CSS compression using YUICompressor\n" + + " --js-compressor Switch inline JavaScript compressor between\n" + + " YUICompressor (default) and Closure Compiler\n\n" + + + "JavaScript Compression Options for YUI Compressor:\n" + + " --nomunge Minify only, do not obfuscate\n" + + " --preserve-semi Preserve all semicolons\n" + + " --disable-optimizations Disable all micro optimizations\n" + + " --line-break Insert a line break after the specified column\n\n" + + + "JavaScript Compression Options for Google Closure Compiler:\n" + + " --closure-opt-level \n" + + " Sets level of optimization (simple by default)\n" + + " --closure-externs Sets custom externs file, repeat for each file\n" + + " --closure-custom-externs-only Disable default built-in externs\n\n" + + + "CSS Compression Options for YUI Compressor:\n" + + " --line-break Insert a line break after the specified column\n\n" + + + "Custom Block Preservation Options:\n" + + " --preserve-php Preserve tags\n" + + " --preserve-server-script Preserve <% ... %> tags\n" + + " --preserve-ssi Preserve tags\n" + + " -p, --preserve Read regular expressions that define\n" + + " custom preservation rules from a file\n\n" + + + "Please note that if you enable CSS or JavaScript compression, additional\n" + + "YUI Compressor or Google Closure Compiler jar files must be present\n" + + "in the same directory as this jar." + + ); + } + + private class CompressorFileFilter implements FileFilter { + + private Pattern filemaskPattern; + private boolean withDirs; + + public CompressorFileFilter(String type, String filemask, boolean withDirs) { + + this.withDirs = withDirs; + + if(filemask == null) { + if(type != null && type.equals("xml")) { + filemaskPattern = Pattern.compile("^.*\\.xml$", Pattern.CASE_INSENSITIVE); + } else { + filemaskPattern = Pattern.compile("^.*\\.html?$", Pattern.CASE_INSENSITIVE); + } + } else { + //turn mask into regexp + filemask = filemask.replaceAll(escRegEx("."), Matcher.quoteReplacement("\\.")); + filemask = filemask.replaceAll(escRegEx("*"), Matcher.quoteReplacement(".*")); + filemask = filemask.replaceAll(escRegEx("?"), Matcher.quoteReplacement(".")); + filemask = filemask.replaceAll(escRegEx(";"), Matcher.quoteReplacement("$|^")); + filemask = "^" + filemask + "$"; + + filemaskPattern = Pattern.compile(filemask, Pattern.CASE_INSENSITIVE); + } + } + + @Override + public boolean accept(File file) { + if(!withDirs) { + //take only matching non-dirs + if(!file.isDirectory()) { + return filemaskPattern.matcher(file.getName()).matches(); + } + } else { + //take matching files and dirs + return file.isDirectory() || filemaskPattern.matcher(file.getName()).matches(); + } + return false; + } + + } + +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/htmlcompressor/analyzer/HtmlAnalyzer.java b/src/main/java/com/googlecode/htmlcompressor/analyzer/HtmlAnalyzer.java new file mode 100644 index 0000000..692d27e --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/analyzer/HtmlAnalyzer.java @@ -0,0 +1,249 @@ +package com.googlecode.htmlcompressor.analyzer; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.text.NumberFormat; +import java.util.Formatter; + +import com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor; +import com.googlecode.htmlcompressor.compressor.HtmlCompressor; + +/** + * Class that compresses provided source with different compression + * settings and displays page size gains in a report + * + * @author Sergiy Kovalchuk + */ +public class HtmlAnalyzer { + + private String jsCompressor = HtmlCompressor.JS_COMPRESSOR_YUI; + + public HtmlAnalyzer() { + + } + + public HtmlAnalyzer(String jsCompressor) { + this.jsCompressor = jsCompressor; + } + + public void analyze(String source) { + int originalSize = source.length(); + + HtmlCompressor compressor = getCleanCompressor(); + String compResult = compressor.compress(source); + + printHeader(); + + System.out.println(formatLine("Compression disabled", originalSize, originalSize, originalSize)); + int prevSize = originalSize; + + + //spaces inside tags + System.out.println(formatLine("All settings disabled", originalSize, compResult.length(), prevSize)); + prevSize = compResult.length(); + + //remove comments + compressor.setRemoveComments(true); + compResult = compressor.compress(source); + System.out.println(formatLine("Comments removed", originalSize, compResult.length(), prevSize)); + prevSize = compResult.length(); + + //remove mulispaces + compressor.setRemoveMultiSpaces(true); + compResult = compressor.compress(source); + System.out.println(formatLine("Multiple spaces removed", originalSize, compResult.length(), prevSize)); + prevSize = compResult.length(); + + //remove intertag spaces + compressor.setRemoveIntertagSpaces(true); + compResult = compressor.compress(source); + System.out.println(formatLine("No spaces between tags", originalSize, compResult.length(), prevSize)); + prevSize = compResult.length(); + + //remove min surrounding spaces + compressor.setRemoveSurroundingSpaces(HtmlCompressor.BLOCK_TAGS_MIN); + compResult = compressor.compress(source); + System.out.println(formatLine("No surround spaces (min)", originalSize, compResult.length(), prevSize)); + prevSize = compResult.length(); + + //remove max surrounding spaces + compressor.setRemoveSurroundingSpaces(HtmlCompressor.BLOCK_TAGS_MAX); + compResult = compressor.compress(source); + System.out.println(formatLine("No surround spaces (max)", originalSize, compResult.length(), prevSize)); + prevSize = compResult.length(); + + //remove all surrounding spaces + compressor.setRemoveSurroundingSpaces(HtmlCompressor.ALL_TAGS); + compResult = compressor.compress(source); + System.out.println(formatLine("No surround spaces (all)", originalSize, compResult.length(), prevSize)); + prevSize = compResult.length(); + + //remove quotes + compressor.setRemoveQuotes(true); + compResult = compressor.compress(source); + System.out.println(formatLine("Quotes removed from tags", originalSize, compResult.length(), prevSize)); + prevSize = compResult.length(); + + //link attrib + compressor.setRemoveLinkAttributes(true); + compResult = compressor.compress(source); + System.out.println(formatLine(" attr. removed", originalSize, compResult.length(), prevSize)); + prevSize = compResult.length(); + + //style attrib + compressor.setRemoveStyleAttributes(true); + compResult = compressor.compress(source); + System.out.println(formatLine(")", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern tagPropertyPattern = Pattern.compile("(\\s\\w+)\\s*=\\s*(?=[^<]*?>)", Pattern.CASE_INSENSITIVE); + protected static final Pattern cdataPattern = Pattern.compile("\\s*\\s*", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern doctypePattern = Pattern.compile("]*>", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern typeAttrPattern = Pattern.compile("type\\s*=\\s*([\\\"']*)(.+?)\\1", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern jsTypeAttrPattern = Pattern.compile("(]*)type\\s*=\\s*([\"']*)(?:text|application)/javascript\\2([^>]*>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern jsLangAttrPattern = Pattern.compile("(]*)language\\s*=\\s*([\"']*)javascript\\2([^>]*>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern styleTypeAttrPattern = Pattern.compile("(]*)type\\s*=\\s*([\"']*)text/style\\2([^>]*>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern linkTypeAttrPattern = Pattern.compile("(]*)type\\s*=\\s*([\"']*)text/(?:css|plain)\\2([^>]*>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern linkRelAttrPattern = Pattern.compile("]*)rel\\s*=\\s*([\"']*)(?:alternate\\s+)?stylesheet\\1(?:[^>]*)>", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern formMethodAttrPattern = Pattern.compile("(]*)method\\s*=\\s*([\"']*)get\\2([^>]*>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern inputTypeAttrPattern = Pattern.compile("(]*)type\\s*=\\s*([\"']*)text\\2([^>]*>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern booleanAttrPattern = Pattern.compile("(<\\w+[^>]*)(checked|selected|disabled|readonly)\\s*=\\s*([\"']*)\\w*\\3([^>]*>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern eventJsProtocolPattern = Pattern.compile("^javascript:\\s*(.+)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern httpProtocolPattern = Pattern.compile("(<[^>]+?(?:href|src|cite|action)\\s*=\\s*['\"])http:(//[^>]+?>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern httpsProtocolPattern = Pattern.compile("(<[^>]+?(?:href|src|cite|action)\\s*=\\s*['\"])https:(//[^>]+?>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern relExternalPattern = Pattern.compile("<(?:[^>]*)rel\\s*=\\s*([\"']*)(?:alternate\\s+)?external\\1(?:[^>]*)>", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern eventPattern1 = Pattern.compile("(\\son[a-z]+\\s*=\\s*\")([^\"\\\\\\r\\n]*(?:\\\\.[^\"\\\\\\r\\n]*)*)(\")", Pattern.CASE_INSENSITIVE); //unmasked: \son[a-z]+\s*=\s*"[^"\\\r\n]*(?:\\.[^"\\\r\n]*)*" + protected static final Pattern eventPattern2 = Pattern.compile("(\\son[a-z]+\\s*=\\s*')([^'\\\\\\r\\n]*(?:\\\\.[^'\\\\\\r\\n]*)*)(')", Pattern.CASE_INSENSITIVE); + protected static final Pattern lineBreakPattern = Pattern.compile("(?:\\p{Blank}*(\\r?\\n)\\p{Blank}*)+"); + protected static final Pattern surroundingSpacesMinPattern = Pattern.compile("\\s*(|[\\s/][^>]*>))\\s*", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern surroundingSpacesMaxPattern = Pattern.compile("\\s*(|[\\s/][^>]*>))\\s*", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern surroundingSpacesAllPattern = Pattern.compile("\\s*(<[^>]+>)\\s*", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + + //patterns for searching for temporary replacements + protected static final Pattern tempCondCommentPattern = Pattern.compile("%%%~COMPRESS~COND~(\\d+?)~%%%"); + protected static final Pattern tempPrePattern = Pattern.compile("%%%~COMPRESS~PRE~(\\d+?)~%%%"); + protected static final Pattern tempTextAreaPattern = Pattern.compile("%%%~COMPRESS~TEXTAREA~(\\d+?)~%%%"); + protected static final Pattern tempScriptPattern = Pattern.compile("%%%~COMPRESS~SCRIPT~(\\d+?)~%%%"); + protected static final Pattern tempStylePattern = Pattern.compile("%%%~COMPRESS~STYLE~(\\d+?)~%%%"); + protected static final Pattern tempEventPattern = Pattern.compile("%%%~COMPRESS~EVENT~(\\d+?)~%%%"); + protected static final Pattern tempSkipPattern = Pattern.compile("%%%~COMPRESS~SKIP~(\\d+?)~%%%"); + protected static final Pattern tempLineBreakPattern = Pattern.compile("%%%~COMPRESS~LT~(\\d+?)~%%%"); + + /** + * The main method that compresses given HTML source and returns compressed + * result. + * + * @param html HTML content to compress + * @return compressed content. + */ + public String compress(String html) { + if(!enabled || html == null || html.length() == 0) { + return html; + } + + //calculate uncompressed statistics + initStatistics(html); + + //preserved block containers + List condCommentBlocks = new ArrayList(); + List preBlocks = new ArrayList(); + List taBlocks = new ArrayList(); + List scriptBlocks = new ArrayList(); + List styleBlocks = new ArrayList(); + List eventBlocks = new ArrayList(); + List skipBlocks = new ArrayList(); + List lineBreakBlocks = new ArrayList(); + List> userBlocks = new ArrayList>(); + + //preserve blocks + html = preserveBlocks(html, preBlocks, taBlocks, scriptBlocks, styleBlocks, eventBlocks, condCommentBlocks, skipBlocks, lineBreakBlocks, userBlocks); + + //process pure html + html = processHtml(html); + + //process preserved blocks + processPreservedBlocks(preBlocks, taBlocks, scriptBlocks, styleBlocks, eventBlocks, condCommentBlocks, skipBlocks, lineBreakBlocks, userBlocks); + + //put preserved blocks back + html = returnBlocks(html, preBlocks, taBlocks, scriptBlocks, styleBlocks, eventBlocks, condCommentBlocks, skipBlocks, lineBreakBlocks, userBlocks); + + //calculate compressed statistics + endStatistics(html); + + return html; + } + + protected void initStatistics(String html) { + //create stats + if(generateStatistics) { + statistics = new HtmlCompressorStatistics(); + statistics.setTime((new Date()).getTime()); + statistics.getOriginalMetrics().setFilesize(html.length()); + + //calculate number of empty chars + Matcher matcher = emptyPattern.matcher(html); + while(matcher.find()) { + statistics.getOriginalMetrics().setEmptyChars(statistics.getOriginalMetrics().getEmptyChars() + 1); + } + } else { + statistics = null; + } + } + + protected void endStatistics(String html) { + //calculate compression time + if(generateStatistics) { + statistics.setTime((new Date()).getTime() - statistics.getTime()); + statistics.getCompressedMetrics().setFilesize(html.length()); + + //calculate number of empty chars + Matcher matcher = emptyPattern.matcher(html); + while(matcher.find()) { + statistics.getCompressedMetrics().setEmptyChars(statistics.getCompressedMetrics().getEmptyChars() + 1); + } + } + } + + protected String preserveBlocks(String html, List preBlocks, List taBlocks, List scriptBlocks, List styleBlocks, List eventBlocks, List condCommentBlocks, List skipBlocks, List lineBreakBlocks, List> userBlocks) { + + //preserve user blocks + if(preservePatterns != null) { + for(int p=0;p userBlock = new ArrayList(); + + Matcher matcher = preservePatterns.get(p).matcher(html); + int index = 0; + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + if(matcher.group(0).trim().length() > 0) { + userBlock.add(matcher.group(0)); + matcher.appendReplacement(sb, MessageFormat.format(tempUserBlock, p, index++)); + } + } + matcher.appendTail(sb); + html = sb.toString(); + userBlocks.add(userBlock); + } + } + + //preserve skip blocks + Matcher matcher = skipPattern.matcher(html); + int skipBlockIndex = 0; + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + if(matcher.group(1).trim().length() > 0) { + skipBlocks.add(matcher.group(1)); + matcher.appendReplacement(sb, MessageFormat.format(tempSkipBlock, skipBlockIndex++)); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //preserve conditional comments + HtmlCompressor condCommentCompressor = createCompressorClone(); + matcher = condCommentPattern.matcher(html); + int index = 0; + sb = new StringBuffer(); + while(matcher.find()) { + if(matcher.group(2).trim().length() > 0) { + condCommentBlocks.add(matcher.group(1) + condCommentCompressor.compress(matcher.group(2)) + matcher.group(3)); + matcher.appendReplacement(sb, MessageFormat.format(tempCondCommentBlock, index++)); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //preserve inline events + matcher = eventPattern1.matcher(html); + index = 0; + sb = new StringBuffer(); + while(matcher.find()) { + if(matcher.group(2).trim().length() > 0) { + eventBlocks.add(matcher.group(2)); + matcher.appendReplacement(sb, "$1"+MessageFormat.format(tempEventBlock, index++)+"$3"); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + matcher = eventPattern2.matcher(html); + sb = new StringBuffer(); + while(matcher.find()) { + if(matcher.group(2).trim().length() > 0) { + eventBlocks.add(matcher.group(2)); + matcher.appendReplacement(sb, "$1"+MessageFormat.format(tempEventBlock, index++)+"$3"); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //preserve PRE tags + matcher = prePattern.matcher(html); + index = 0; + sb = new StringBuffer(); + while(matcher.find()) { + if(matcher.group(2).trim().length() > 0) { + preBlocks.add(matcher.group(2)); + matcher.appendReplacement(sb, "$1"+MessageFormat.format(tempPreBlock, index++)+"$3"); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //preserve SCRIPT tags + matcher = scriptPattern.matcher(html); + index = 0; + sb = new StringBuffer(); + while(matcher.find()) { + //ignore empty scripts + if(matcher.group(2).trim().length() > 0) { + + //check type + String type = ""; + Matcher typeMatcher = typeAttrPattern.matcher(matcher.group(1)); + if(typeMatcher.find()) { + type = typeMatcher.group(2).toLowerCase(); + } + + if(type.length() == 0 || type.equals("text/javascript") || type.equals("application/javascript")) { + //javascript block, preserve and compress with js compressor + scriptBlocks.add(matcher.group(2)); + matcher.appendReplacement(sb, "$1"+MessageFormat.format(tempScriptBlock, index++)+"$3"); + } else if(type.equals("text/x-jquery-tmpl")) { + //jquery template, ignore so it gets compressed with the rest of html + } else { + //some custom script, preserve it inside "skip blocks" so it won't be compressed with js compressor + skipBlocks.add(matcher.group(2)); + matcher.appendReplacement(sb, "$1"+MessageFormat.format(tempSkipBlock, skipBlockIndex++)+"$3"); + } + + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //preserve STYLE tags + matcher = stylePattern.matcher(html); + index = 0; + sb = new StringBuffer(); + while(matcher.find()) { + if(matcher.group(2).trim().length() > 0) { + styleBlocks.add(matcher.group(2)); + matcher.appendReplacement(sb, "$1"+MessageFormat.format(tempStyleBlock, index++)+"$3"); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //preserve TEXTAREA tags + matcher = taPattern.matcher(html); + index = 0; + sb = new StringBuffer(); + while(matcher.find()) { + if(matcher.group(2).trim().length() > 0) { + taBlocks.add(matcher.group(2)); + matcher.appendReplacement(sb, "$1"+MessageFormat.format(tempTextAreaBlock, index++)+"$3"); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //preserve line breaks + if(preserveLineBreaks) { + matcher = lineBreakPattern.matcher(html); + index = 0; + sb = new StringBuffer(); + while(matcher.find()) { + lineBreakBlocks.add(matcher.group(1)); + matcher.appendReplacement(sb, MessageFormat.format(tempLineBreakBlock, index++)); + } + matcher.appendTail(sb); + html = sb.toString(); + } + + return html; + } + + protected String returnBlocks(String html, List preBlocks, List taBlocks, List scriptBlocks, List styleBlocks, List eventBlocks, List condCommentBlocks, List skipBlocks, List lineBreakBlocks, List> userBlocks) { + + //put line breaks back + if(preserveLineBreaks) { + Matcher matcher = tempLineBreakPattern.matcher(html); + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + int i = Integer.parseInt(matcher.group(1)); + if(lineBreakBlocks.size() > i) { + matcher.appendReplacement(sb, lineBreakBlocks.get(i)); + } + } + matcher.appendTail(sb); + html = sb.toString(); + } + + //put TEXTAREA blocks back + Matcher matcher = tempTextAreaPattern.matcher(html); + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + int i = Integer.parseInt(matcher.group(1)); + if(taBlocks.size() > i) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(taBlocks.get(i))); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //put STYLE blocks back + matcher = tempStylePattern.matcher(html); + sb = new StringBuffer(); + while(matcher.find()) { + int i = Integer.parseInt(matcher.group(1)); + if(styleBlocks.size() > i) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(styleBlocks.get(i))); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //put SCRIPT blocks back + matcher = tempScriptPattern.matcher(html); + sb = new StringBuffer(); + while(matcher.find()) { + int i = Integer.parseInt(matcher.group(1)); + if(scriptBlocks.size() > i) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(scriptBlocks.get(i))); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //put PRE blocks back + matcher = tempPrePattern.matcher(html); + sb = new StringBuffer(); + while(matcher.find()) { + int i = Integer.parseInt(matcher.group(1)); + if(preBlocks.size() > i) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(preBlocks.get(i))); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //put event blocks back + matcher = tempEventPattern.matcher(html); + sb = new StringBuffer(); + while(matcher.find()) { + int i = Integer.parseInt(matcher.group(1)); + if(eventBlocks.size() > i) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(eventBlocks.get(i))); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //put conditional comments back + matcher = tempCondCommentPattern.matcher(html); + sb = new StringBuffer(); + while(matcher.find()) { + int i = Integer.parseInt(matcher.group(1)); + if(condCommentBlocks.size() > i) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(condCommentBlocks.get(i))); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //put skip blocks back + matcher = tempSkipPattern.matcher(html); + sb = new StringBuffer(); + while(matcher.find()) { + int i = Integer.parseInt(matcher.group(1)); + if(skipBlocks.size() > i) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(skipBlocks.get(i))); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + //put user blocks back + if(preservePatterns != null) { + for(int p = preservePatterns.size() - 1; p >= 0; p--) { + Pattern tempUserPattern = Pattern.compile("%%%~COMPRESS~USER" + p + "~(\\d+?)~%%%"); + matcher = tempUserPattern.matcher(html); + sb = new StringBuffer(); + while(matcher.find()) { + int i = Integer.parseInt(matcher.group(1)); + if(userBlocks.size() > p && userBlocks.get(p).size() > i) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(userBlocks.get(p).get(i))); + } + } + matcher.appendTail(sb); + html = sb.toString(); + } + } + + return html; + } + + protected String processHtml(String html) { + + //remove comments + html = removeComments(html); + + //simplify doctype + html = simpleDoctype(html); + + //remove script attributes + html = removeScriptAttributes(html); + + //remove style attributes + html = removeStyleAttributes(html); + + //remove link attributes + html = removeLinkAttributes(html); + + //remove form attributes + html = removeFormAttributes(html); + + //remove input attributes + html = removeInputAttributes(html); + + //simplify boolean attributes + html = simpleBooleanAttributes(html); + + //remove http from attributes + html = removeHttpProtocol(html); + + //remove https from attributes + html = removeHttpsProtocol(html); + + //remove inter-tag spaces + html = removeIntertagSpaces(html); + + //remove multi whitespace characters + html = removeMultiSpaces(html); + + //remove spaces around equals sign and ending spaces + html = removeSpacesInsideTags(html); + + //remove quotes from tag attributes + html = removeQuotesInsideTags(html); + + //remove surrounding spaces + html = removeSurroundingSpaces(html); + + return html.trim(); + } + + protected String removeSurroundingSpaces(String html) { + //remove spaces around provided tags + if(removeSurroundingSpaces != null) { + Pattern pattern; + if(removeSurroundingSpaces.equalsIgnoreCase(BLOCK_TAGS_MIN)) { + pattern = surroundingSpacesMinPattern; + } else if(removeSurroundingSpaces.equalsIgnoreCase(BLOCK_TAGS_MAX)) { + pattern = surroundingSpacesMaxPattern; + } if(removeSurroundingSpaces.equalsIgnoreCase(ALL_TAGS)) { + pattern = surroundingSpacesAllPattern; + } else { + pattern = Pattern.compile("\\s*(|[\\s/][^>]*>))\\s*", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + } + + Matcher matcher = pattern.matcher(html); + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + matcher.appendReplacement(sb, "$1"); + } + matcher.appendTail(sb); + html = sb.toString(); + + } + return html; + } + + protected String removeQuotesInsideTags(String html) { + //remove quotes from tag attributes + if(removeQuotes) { + Matcher matcher = tagQuotePattern.matcher(html); + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + //if quoted attribute is followed by "/" add extra space + if(matcher.group(3).trim().length() == 0) { + matcher.appendReplacement(sb, "=$2"); + } else { + matcher.appendReplacement(sb, "=$2 $3"); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + } + return html; + } + + protected String removeSpacesInsideTags(String html) { + //remove spaces around equals sign inside tags + html = tagPropertyPattern.matcher(html).replaceAll("$1="); + + //remove ending spaces inside tags + //html = tagEndSpacePattern.matcher(html).replaceAll("$1$2"); + Matcher matcher = tagEndSpacePattern.matcher(html); + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + //keep space if attribute value is unquoted before trailing slash + if(matcher.group(2).startsWith("/") && tagLastUnquotedValuePattern.matcher(matcher.group(1)).find()) { + matcher.appendReplacement(sb, "$1 $2"); + } else { + matcher.appendReplacement(sb, "$1$2"); + } + } + matcher.appendTail(sb); + html = sb.toString(); + + return html; + } + + protected String removeMultiSpaces(String html) { + //collapse multiple spaces + if(removeMultiSpaces) { + html = multispacePattern.matcher(html).replaceAll(" "); + } + return html; + } + + protected String removeIntertagSpaces(String html) { + //remove inter-tag spaces + if(removeIntertagSpaces) { + html = intertagPattern_TagTag.matcher(html).replaceAll("><"); + html = intertagPattern_TagCustom.matcher(html).replaceAll(">%%%~"); + html = intertagPattern_CustomTag.matcher(html).replaceAll("~%%%<"); + html = intertagPattern_CustomCustom.matcher(html).replaceAll("~%%%%%%~"); + } + return html; + } + + protected String removeComments(String html) { + //remove comments + if(removeComments) { + html = commentPattern.matcher(html).replaceAll(""); + } + return html; + } + + protected String simpleDoctype(String html) { + //simplify doctype + if(simpleDoctype) { + html = doctypePattern.matcher(html).replaceAll(""); + } + return html; + } + + protected String removeScriptAttributes(String html) { + + if(removeScriptAttributes) { + //remove type from script tags + html = jsTypeAttrPattern.matcher(html).replaceAll("$1$3"); + + //remove language from script tags + html = jsLangAttrPattern.matcher(html).replaceAll("$1$3"); + } + return html; + } + + protected String removeStyleAttributes(String html) { + //remove type from style tags + if(removeStyleAttributes) { + html = styleTypeAttrPattern.matcher(html).replaceAll("$1$3"); + } + return html; + } + + protected String removeLinkAttributes(String html) { + //remove type from link tags with rel=stylesheet + if(removeLinkAttributes) { + Matcher matcher = linkTypeAttrPattern.matcher(html); + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + //if rel=stylesheet + if(linkRelAttrPattern.matcher(matcher.group(0)).matches()) { + matcher.appendReplacement(sb, "$1$3"); + } else { + matcher.appendReplacement(sb, "$0"); + } + } + matcher.appendTail(sb); + html = sb.toString(); + } + return html; + } + + protected String removeFormAttributes(String html) { + //remove method from form tags + if(removeFormAttributes) { + html = formMethodAttrPattern.matcher(html).replaceAll("$1$3"); + } + return html; + } + + protected String removeInputAttributes(String html) { + //remove type from input tags + if(removeInputAttributes) { + html = inputTypeAttrPattern.matcher(html).replaceAll("$1$3"); + } + return html; + } + + protected String simpleBooleanAttributes(String html) { + //simplify boolean attributes + if(simpleBooleanAttributes) { + html = booleanAttrPattern.matcher(html).replaceAll("$1$2$4"); + } + return html; + } + + protected String removeHttpProtocol(String html) { + //remove http protocol from tag attributes + if(removeHttpProtocol) { + Matcher matcher = httpProtocolPattern.matcher(html); + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + //if rel!=external + if(!relExternalPattern.matcher(matcher.group(0)).matches()) { + matcher.appendReplacement(sb, "$1$2"); + } else { + matcher.appendReplacement(sb, "$0"); + } + } + matcher.appendTail(sb); + html = sb.toString(); + } + return html; + } + + protected String removeHttpsProtocol(String html) { + //remove https protocol from tag attributes + if(removeHttpsProtocol) { + Matcher matcher = httpsProtocolPattern.matcher(html); + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + //if rel!=external + if(!relExternalPattern.matcher(matcher.group(0)).matches()) { + matcher.appendReplacement(sb, "$1$2"); + } else { + matcher.appendReplacement(sb, "$0"); + } + } + matcher.appendTail(sb); + html = sb.toString(); + } + return html; + } + + protected void processPreservedBlocks(List preBlocks, List taBlocks, List scriptBlocks, List styleBlocks, List eventBlocks, List condCommentBlocks, List skipBlocks, List lineBreakBlocks, List> userBlocks) { + processPreBlocks(preBlocks); + processTextAreaBlocks(taBlocks); + processScriptBlocks(scriptBlocks); + processStyleBlocks(styleBlocks); + processEventBlocks(eventBlocks); + processCondCommentBlocks(condCommentBlocks); + processSkipBlocks(skipBlocks); + processUserBlocks(userBlocks); + processLineBreakBlocks(lineBreakBlocks); + } + + protected void processPreBlocks(List preBlocks) { + if(generateStatistics) { + for(String block : preBlocks) { + statistics.setPreservedSize(statistics.getPreservedSize() + block.length()); + } + } + } + + protected void processTextAreaBlocks(List taBlocks) { + if(generateStatistics) { + for(String block : taBlocks) { + statistics.setPreservedSize(statistics.getPreservedSize() + block.length()); + } + } + } + + protected void processCondCommentBlocks(List condCommentBlocks) { + if(generateStatistics) { + for(String block : condCommentBlocks) { + statistics.setPreservedSize(statistics.getPreservedSize() + block.length()); + } + } + } + + protected void processSkipBlocks(List skipBlocks) { + if(generateStatistics) { + for(String block : skipBlocks) { + statistics.setPreservedSize(statistics.getPreservedSize() + block.length()); + } + } + } + + protected void processLineBreakBlocks(List lineBreakBlocks) { + if(generateStatistics) { + for(String block : lineBreakBlocks) { + statistics.setPreservedSize(statistics.getPreservedSize() + block.length()); + } + } + } + + protected void processUserBlocks(List> userBlocks) { + if(generateStatistics) { + for(List blockList : userBlocks) { + for(String block : blockList) { + statistics.setPreservedSize(statistics.getPreservedSize() + block.length()); + } + } + } + } + + protected void processEventBlocks(List eventBlocks) { + + if(generateStatistics) { + for(String block : eventBlocks) { + statistics.getOriginalMetrics().setInlineEventSize(statistics.getOriginalMetrics().getInlineEventSize() + block.length()); + } + } + + if(removeJavaScriptProtocol) { + for(int i = 0; i < eventBlocks.size(); i++) { + eventBlocks.set(i, removeJavaScriptProtocol(eventBlocks.get(i))); + } + } else if(generateStatistics) { + for(String block : eventBlocks) { + statistics.setPreservedSize(statistics.getPreservedSize() + block.length()); + } + } + + if(generateStatistics) { + for(String block : eventBlocks) { + statistics.getCompressedMetrics().setInlineEventSize(statistics.getCompressedMetrics().getInlineEventSize() + block.length()); + } + } + } + + protected String removeJavaScriptProtocol(String source) { + //remove javascript: from inline events + String result = source; + + Matcher matcher = eventJsProtocolPattern.matcher(source); + if(matcher.matches()) { + result = matcher.replaceFirst("$1"); + } + + if(generateStatistics) { + statistics.setPreservedSize(statistics.getPreservedSize() + result.length()); + } + + return result; + } + + protected void processScriptBlocks(List scriptBlocks) { + + if(generateStatistics) { + for(String block : scriptBlocks) { + statistics.getOriginalMetrics().setInlineScriptSize(statistics.getOriginalMetrics().getInlineScriptSize() + block.length()); + } + } + + if(compressJavaScript) { + for(int i = 0; i < scriptBlocks.size(); i++) { + scriptBlocks.set(i, compressJavaScript(scriptBlocks.get(i))); + } + } else if(generateStatistics) { + for(String block : scriptBlocks) { + statistics.setPreservedSize(statistics.getPreservedSize() + block.length()); + } + } + + if(generateStatistics) { + for(String block : scriptBlocks) { + statistics.getCompressedMetrics().setInlineScriptSize(statistics.getCompressedMetrics().getInlineScriptSize() + block.length()); + } + } + } + + protected void processStyleBlocks(List styleBlocks) { + + if(generateStatistics) { + for(String block : styleBlocks) { + statistics.getOriginalMetrics().setInlineStyleSize(statistics.getOriginalMetrics().getInlineStyleSize() + block.length()); + } + } + + if(compressCss) { + for(int i = 0; i < styleBlocks.size(); i++) { + styleBlocks.set(i, compressCssStyles(styleBlocks.get(i))); + } + } else if(generateStatistics) { + for(String block : styleBlocks) { + statistics.setPreservedSize(statistics.getPreservedSize() + block.length()); + } + } + + if(generateStatistics) { + for(String block : styleBlocks) { + statistics.getCompressedMetrics().setInlineStyleSize(statistics.getCompressedMetrics().getInlineStyleSize() + block.length()); + } + } + } + + protected String compressJavaScript(String source) { + + //set default javascript compressor + if(javaScriptCompressor == null) { + YuiJavaScriptCompressor yuiJsCompressor = new YuiJavaScriptCompressor(); + yuiJsCompressor.setNoMunge(yuiJsNoMunge); + yuiJsCompressor.setPreserveAllSemiColons(yuiJsPreserveAllSemiColons); + yuiJsCompressor.setDisableOptimizations(yuiJsDisableOptimizations); + yuiJsCompressor.setLineBreak(yuiJsLineBreak); + + if(yuiErrorReporter != null) { + yuiJsCompressor.setErrorReporter(yuiErrorReporter); + } + + javaScriptCompressor = yuiJsCompressor; + } + + //detect CDATA wrapper + boolean cdataWrapper = false; + Matcher matcher = cdataPattern.matcher(source); + if(matcher.matches()) { + cdataWrapper = true; + source = matcher.group(1); + } + + String result = javaScriptCompressor.compress(source); + + if(cdataWrapper) { + result = ""; + } + + return result; + + } + + protected String compressCssStyles(String source) { + + //set default css compressor + if(cssCompressor == null) { + YuiCssCompressor yuiCssCompressor = new YuiCssCompressor(); + yuiCssCompressor.setLineBreak(yuiCssLineBreak); + + cssCompressor = yuiCssCompressor; + } + + //detect CDATA wrapper + boolean cdataWrapper = false; + Matcher matcher = cdataPattern.matcher(source); + if(matcher.matches()) { + cdataWrapper = true; + source = matcher.group(1); + } + + String result = cssCompressor.compress(source); + + if(cdataWrapper) { + result = ""; + } + + return result; + + } + + protected HtmlCompressor createCompressorClone() { + HtmlCompressor clone = new HtmlCompressor(); + clone.setJavaScriptCompressor(javaScriptCompressor); + clone.setCssCompressor(cssCompressor); + clone.setRemoveComments(removeComments); + clone.setRemoveMultiSpaces(removeMultiSpaces); + clone.setRemoveIntertagSpaces(removeIntertagSpaces); + clone.setRemoveQuotes(removeQuotes); + clone.setCompressJavaScript(compressJavaScript); + clone.setCompressCss(compressCss); + clone.setSimpleDoctype(simpleDoctype); + clone.setRemoveScriptAttributes(removeScriptAttributes); + clone.setRemoveStyleAttributes(removeStyleAttributes); + clone.setRemoveLinkAttributes(removeLinkAttributes); + clone.setRemoveFormAttributes(removeFormAttributes); + clone.setRemoveInputAttributes(removeInputAttributes); + clone.setSimpleBooleanAttributes(simpleBooleanAttributes); + clone.setRemoveJavaScriptProtocol(removeJavaScriptProtocol); + clone.setRemoveHttpProtocol(removeHttpProtocol); + clone.setRemoveHttpsProtocol(removeHttpsProtocol); + clone.setPreservePatterns(preservePatterns); + clone.setYuiJsNoMunge(yuiJsNoMunge); + clone.setYuiJsPreserveAllSemiColons(yuiJsPreserveAllSemiColons); + clone.setYuiJsDisableOptimizations(yuiJsDisableOptimizations); + clone.setYuiJsLineBreak(yuiJsLineBreak); + clone.setYuiCssLineBreak(yuiCssLineBreak); + clone.setYuiErrorReporter(yuiErrorReporter); + + return clone; + + } + + /** + * Returns true if JavaScript compression is enabled. + * + * @return current state of JavaScript compression. + */ + public boolean isCompressJavaScript() { + return compressJavaScript; + } + + /** + * Enables JavaScript compression within <script> tags using + * Yahoo YUI Compressor + * if set to true. Default is false for performance reasons. + * + *

Note: Compressing JavaScript is not recommended if pages are + * compressed dynamically on-the-fly because of performance impact. + * You should consider putting JavaScript into a separate file and + * compressing it using standalone YUICompressor for example.

+ * + * @param compressJavaScript set true to enable JavaScript compression. + * Default is false + * + * @see Yahoo YUI Compressor + * + */ + public void setCompressJavaScript(boolean compressJavaScript) { + this.compressJavaScript = compressJavaScript; + } + + /** + * Returns true if CSS compression is enabled. + * + * @return current state of CSS compression. + */ + public boolean isCompressCss() { + return compressCss; + } + + /** + * Enables CSS compression within <style> tags using + * Yahoo YUI Compressor + * if set to true. Default is false for performance reasons. + * + *

Note: Compressing CSS is not recommended if pages are + * compressed dynamically on-the-fly because of performance impact. + * You should consider putting CSS into a separate file and + * compressing it using standalone YUICompressor for example.

+ * + * @param compressCss set true to enable CSS compression. + * Default is false + * + * @see Yahoo YUI Compressor + * + */ + public void setCompressCss(boolean compressCss) { + this.compressCss = compressCss; + } + + /** + * Returns true if Yahoo YUI Compressor + * will only minify javascript without obfuscating local symbols. + * This corresponds to --nomunge command line option. + * + * @return nomunge parameter value used for JavaScript compression. + * + * @see Yahoo YUI Compressor + */ + public boolean isYuiJsNoMunge() { + return yuiJsNoMunge; + } + + /** + * Tells Yahoo YUI Compressor to only minify javascript without obfuscating + * local symbols. This corresponds to --nomunge command line option. + * This option has effect only if JavaScript compression is enabled. + * Default is false. + * + * @param yuiJsNoMunge set true to enable nomunge mode + * + * @see Yahoo YUI Compressor + */ + public void setYuiJsNoMunge(boolean yuiJsNoMunge) { + this.yuiJsNoMunge = yuiJsNoMunge; + } + + /** + * Returns true if Yahoo YUI Compressor + * will preserve unnecessary semicolons during JavaScript compression. + * This corresponds to --preserve-semi command line option. + * + * @return preserve-semi parameter value used for JavaScript compression. + * + * @see Yahoo YUI Compressor + */ + public boolean isYuiJsPreserveAllSemiColons() { + return yuiJsPreserveAllSemiColons; + } + + /** + * Tells Yahoo YUI Compressor to preserve unnecessary semicolons + * during JavaScript compression. This corresponds to + * --preserve-semi command line option. + * This option has effect only if JavaScript compression is enabled. + * Default is false. + * + * @param yuiJsPreserveAllSemiColons set true to enable preserve-semi mode + * + * @see Yahoo YUI Compressor + */ + public void setYuiJsPreserveAllSemiColons(boolean yuiJsPreserveAllSemiColons) { + this.yuiJsPreserveAllSemiColons = yuiJsPreserveAllSemiColons; + } + + /** + * Returns true if Yahoo YUI Compressor + * will disable all the built-in micro optimizations during JavaScript compression. + * This corresponds to --disable-optimizations command line option. + * + * @return disable-optimizations parameter value used for JavaScript compression. + * + * @see Yahoo YUI Compressor + */ + public boolean isYuiJsDisableOptimizations() { + return yuiJsDisableOptimizations; + } + + /** + * Tells Yahoo YUI Compressor to disable all the built-in micro optimizations + * during JavaScript compression. This corresponds to + * --disable-optimizations command line option. + * This option has effect only if JavaScript compression is enabled. + * Default is false. + * + * @param yuiJsDisableOptimizations set true to enable + * disable-optimizations mode + * + * @see Yahoo YUI Compressor + */ + public void setYuiJsDisableOptimizations(boolean yuiJsDisableOptimizations) { + this.yuiJsDisableOptimizations = yuiJsDisableOptimizations; + } + + /** + * Returns number of symbols per line Yahoo YUI Compressor + * will use during JavaScript compression. + * This corresponds to --line-break command line option. + * + * @return line-break parameter value used for JavaScript compression. + * + * @see Yahoo YUI Compressor + */ + public int getYuiJsLineBreak() { + return yuiJsLineBreak; + } + + /** + * Tells Yahoo YUI Compressor to break lines after the specified number of symbols + * during JavaScript compression. This corresponds to + * --line-break command line option. + * This option has effect only if JavaScript compression is enabled. + * Default is -1 to disable line breaks. + * + * @param yuiJsLineBreak set number of symbols per line + * + * @see Yahoo YUI Compressor + */ + public void setYuiJsLineBreak(int yuiJsLineBreak) { + this.yuiJsLineBreak = yuiJsLineBreak; + } + + /** + * Returns number of symbols per line Yahoo YUI Compressor + * will use during CSS compression. + * This corresponds to --line-break command line option. + * + * @return line-break parameter value used for CSS compression. + * + * @see Yahoo YUI Compressor + */ + public int getYuiCssLineBreak() { + return yuiCssLineBreak; + } + + /** + * Tells Yahoo YUI Compressor to break lines after the specified number of symbols + * during CSS compression. This corresponds to + * --line-break command line option. + * This option has effect only if CSS compression is enabled. + * Default is -1 to disable line breaks. + * + * @param yuiCssLineBreak set number of symbols per line + * + * @see Yahoo YUI Compressor + */ + public void setYuiCssLineBreak(int yuiCssLineBreak) { + this.yuiCssLineBreak = yuiCssLineBreak; + } + + /** + * Returns true if all unnecessary quotes will be removed + * from tag attributes. + * + */ + public boolean isRemoveQuotes() { + return removeQuotes; + } + + /** + * If set to true all unnecessary quotes will be removed + * from tag attributes. Default is false. + * + *

Note: Even though quotes are removed only when it is safe to do so, + * it still might break strict HTML validation. Turn this option on only if + * a page validation is not very important or to squeeze the most out of the compression. + * This option has no performance impact. + * + * @param removeQuotes set true to remove unnecessary quotes from tag attributes + */ + public void setRemoveQuotes(boolean removeQuotes) { + this.removeQuotes = removeQuotes; + } + + /** + * Returns true if compression is enabled. + * + * @return true if compression is enabled. + */ + public boolean isEnabled() { + return enabled; + } + + /** + * If set to false all compression will be bypassed. Might be useful for testing purposes. + * Default is true. + * + * @param enabled set false to bypass all compression + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + /** + * Returns true if all HTML comments will be removed. + * + * @return true if all HTML comments will be removed + */ + public boolean isRemoveComments() { + return removeComments; + } + + /** + * If set to true all HTML comments will be removed. + * Default is true. + * + * @param removeComments set true to remove all HTML comments + */ + public void setRemoveComments(boolean removeComments) { + this.removeComments = removeComments; + } + + /** + * Returns true if all multiple whitespace characters will be replaced with single spaces. + * + * @return true if all multiple whitespace characters will be replaced with single spaces. + */ + public boolean isRemoveMultiSpaces() { + return removeMultiSpaces; + } + + /** + * If set to true all multiple whitespace characters will be replaced with single spaces. + * Default is true. + * + * @param removeMultiSpaces set true to replace all multiple whitespace characters + * will single spaces. + */ + public void setRemoveMultiSpaces(boolean removeMultiSpaces) { + this.removeMultiSpaces = removeMultiSpaces; + } + + /** + * Returns true if all inter-tag whitespace characters will be removed. + * + * @return true if all inter-tag whitespace characters will be removed. + */ + public boolean isRemoveIntertagSpaces() { + return removeIntertagSpaces; + } + + /** + * If set to true all inter-tag whitespace characters will be removed. + * Default is false. + * + *

Note: It is fairly safe to turn this option on unless you + * rely on spaces for page formatting. Even if you do, you can always preserve + * required spaces with &nbsp;. This option has no performance impact. + * + * @param removeIntertagSpaces set true to remove all inter-tag whitespace characters + */ + public void setRemoveIntertagSpaces(boolean removeIntertagSpaces) { + this.removeIntertagSpaces = removeIntertagSpaces; + } + + /** + * Returns a list of Patterns defining custom preserving block rules + * + * @return list of Pattern objects defining rules for preserving block rules + */ + public List getPreservePatterns() { + return preservePatterns; + } + + /** + * This method allows setting custom block preservation rules defined by regular + * expression patterns. Blocks that match provided patterns will be skipped during HTML compression. + * + *

Custom preservation rules have higher priority than default rules. + * Priority between custom rules are defined by their position in a list + * (beginning of a list has higher priority). + * + *

Besides custom patterns, you can use 3 predefined patterns: + * {@link #PHP_TAG_PATTERN PHP_TAG_PATTERN}, + * {@link #SERVER_SCRIPT_TAG_PATTERN SERVER_SCRIPT_TAG_PATTERN}, + * {@link #SERVER_SIDE_INCLUDE_PATTERN SERVER_SIDE_INCLUDE_PATTERN}. + * + * @param preservePatterns List of Pattern objects that will be + * used to skip matched blocks during compression + */ + public void setPreservePatterns(List preservePatterns) { + this.preservePatterns = preservePatterns; + } + + /** + * Returns ErrorReporter used by YUI Compressor to log error messages + * during JavasSript compression + * + * @return ErrorReporter used by YUI Compressor to log error messages + * during JavasSript compression + * + * @see Yahoo YUI Compressor + * @see Error Reporter Interface + */ + public ErrorReporter getYuiErrorReporter() { + return yuiErrorReporter; + } + + /** + * Sets ErrorReporter that YUI Compressor will use for reporting errors during + * JavaScript compression. If no ErrorReporter was provided + * {@link YuiJavaScriptCompressor.DefaultErrorReporter} will be used + * which reports errors to System.err stream. + * + * @param yuiErrorReporter ErrorReporter that will be used by YUI Compressor + * + * @see YuiJavaScriptCompressor.DefaultErrorReporter + * @see Yahoo YUI Compressor + * @see ErrorReporter Interface + */ + public void setYuiErrorReporter(ErrorReporter yuiErrorReporter) { + this.yuiErrorReporter = yuiErrorReporter; + } + + /** + * Returns JavaScript compressor implementation that will be used + * to compress inline JavaScript in HTML. + * + * @return Compressor implementation that will be used + * to compress inline JavaScript in HTML. + * + * @see YuiJavaScriptCompressor + * @see ClosureJavaScriptCompressor + * @see Yahoo YUI Compressor + * @see Google Closure Compiler + */ + public Compressor getJavaScriptCompressor() { + return javaScriptCompressor; + } + + /** + * Sets JavaScript compressor implementation that will be used + * to compress inline JavaScript in HTML. + * + *

HtmlCompressor currently + * comes with basic implementations for Yahoo YUI Compressor (called {@link YuiJavaScriptCompressor}) + * and Google Closure Compiler (called {@link ClosureJavaScriptCompressor}) that should be enough for most cases, + * but users can also create their own JavaScript compressors for custom needs. + * + *

If no compressor is set {@link YuiJavaScriptCompressor} will be used by default. + * + * @param javaScriptCompressor {@link Compressor} implementation that will be used for inline JavaScript compression + * + * @see YuiJavaScriptCompressor + * @see ClosureJavaScriptCompressor + * @see Yahoo YUI Compressor + * @see Google Closure Compiler + */ + public void setJavaScriptCompressor(Compressor javaScriptCompressor) { + this.javaScriptCompressor = javaScriptCompressor; + } + + /** + * Returns CSS compressor implementation that will be used + * to compress inline CSS in HTML. + * + * @return Compressor implementation that will be used + * to compress inline CSS in HTML. + * + * @see YuiCssCompressor + * @see Yahoo YUI Compressor + */ + public Compressor getCssCompressor() { + return cssCompressor; + } + + /** + * Sets CSS compressor implementation that will be used + * to compress inline CSS in HTML. + * + *

HtmlCompressor currently + * comes with basic implementation for Yahoo YUI Compressor (called {@link YuiCssCompressor}), + * but users can also create their own CSS compressors for custom needs. + * + *

If no compressor is set {@link YuiCssCompressor} will be used by default. + * + * @param cssCompressor {@link Compressor} implementation that will be used for inline CSS compression + * + * @see YuiCssCompressor + * @see Yahoo YUI Compressor + */ + public void setCssCompressor(Compressor cssCompressor) { + this.cssCompressor = cssCompressor; + } + + /** + * Returns true if existing DOCTYPE declaration will be replaced with simple declaration. + * + * @return true if existing DOCTYPE declaration will be replaced with simple declaration. + */ + public boolean isSimpleDoctype() { + return simpleDoctype; + } + + /** + * If set to true, existing DOCTYPE declaration will be replaced with simple <!DOCTYPE html> declaration. + * Default is false. + * + * @param simpleDoctype set true to replace existing DOCTYPE declaration with <!DOCTYPE html> + */ + public void setSimpleDoctype(boolean simpleDoctype) { + this.simpleDoctype = simpleDoctype; + } + + /** + * Returns true if unnecessary attributes wil be removed from <script> tags + * + * @return true if unnecessary attributes wil be removed from <script> tags + */ + public boolean isRemoveScriptAttributes() { + return removeScriptAttributes; + } + + /** + * If set to true, following attributes will be removed from <script> tags: + *

    + *
  • type="text/javascript"
  • + *
  • type="application/javascript"
  • + *
  • language="javascript"
  • + *
+ * + *

Default is false. + * + * @param removeScriptAttributes set true to remove unnecessary attributes from <script> tags + */ + public void setRemoveScriptAttributes(boolean removeScriptAttributes) { + this.removeScriptAttributes = removeScriptAttributes; + } + + /** + * Returns true if type="text/style" attributes will be removed from <style> tags + * + * @return true if type="text/style" attributes will be removed from <style> tags + */ + public boolean isRemoveStyleAttributes() { + return removeStyleAttributes; + } + + /** + * If set to true, type="text/style" attributes will be removed from <style> tags. Default is false. + * + * @param removeStyleAttributes set true to remove type="text/style" attributes from <style> tags + */ + public void setRemoveStyleAttributes(boolean removeStyleAttributes) { + this.removeStyleAttributes = removeStyleAttributes; + } + + /** + * Returns true if unnecessary attributes will be removed from <link> tags + * + * @return true if unnecessary attributes will be removed from <link> tags + */ + public boolean isRemoveLinkAttributes() { + return removeLinkAttributes; + } + + /** + * If set to true, following attributes will be removed from <link rel="stylesheet"> and <link rel="alternate stylesheet"> tags: + *

    + *
  • type="text/css"
  • + *
  • type="text/plain"
  • + *
+ * + *

Default is false. + * + * @param removeLinkAttributes set true to remove unnecessary attributes from <link> tags + */ + public void setRemoveLinkAttributes(boolean removeLinkAttributes) { + this.removeLinkAttributes = removeLinkAttributes; + } + + /** + * Returns true if method="get" attributes will be removed from <form> tags + * + * @return true if method="get" attributes will be removed from <form> tags + */ + public boolean isRemoveFormAttributes() { + return removeFormAttributes; + } + + /** + * If set to true, method="get" attributes will be removed from <form> tags. Default is false. + * + * @param removeFormAttributes set true to remove method="get" attributes from <form> tags + */ + public void setRemoveFormAttributes(boolean removeFormAttributes) { + this.removeFormAttributes = removeFormAttributes; + } + + /** + * Returns true if type="text" attributes will be removed from <input> tags + * @return true if type="text" attributes will be removed from <input> tags + */ + public boolean isRemoveInputAttributes() { + return removeInputAttributes; + } + + /** + * If set to true, type="text" attributes will be removed from <input> tags. Default is false. + * + * @param removeInputAttributes set true to remove type="text" attributes from <input> tags + */ + public void setRemoveInputAttributes(boolean removeInputAttributes) { + this.removeInputAttributes = removeInputAttributes; + } + + /** + * Returns true if boolean attributes will be simplified + * + * @return true if boolean attributes will be simplified + */ + public boolean isSimpleBooleanAttributes() { + return simpleBooleanAttributes; + } + + /** + * If set to true, any values of following boolean attributes will be removed: + *

    + *
  • checked
  • + *
  • selected
  • + *
  • disabled
  • + *
  • readonly
  • + *
+ * + *

For example, <input readonly="readonly"> would become <input readonly> + * + *

Default is false. + * + * @param simpleBooleanAttributes set true to simplify boolean attributes + */ + public void setSimpleBooleanAttributes(boolean simpleBooleanAttributes) { + this.simpleBooleanAttributes = simpleBooleanAttributes; + } + + /** + * Returns true if javascript: pseudo-protocol will be removed from inline event handlers. + * + * @return true if javascript: pseudo-protocol will be removed from inline event handlers. + */ + public boolean isRemoveJavaScriptProtocol() { + return removeJavaScriptProtocol; + } + + /** + * If set to true, javascript: pseudo-protocol will be removed from inline event handlers. + * + *

For example, <a onclick="javascript:alert()"> would become <a onclick="alert()"> + * + *

Default is false. + * + * @param removeJavaScriptProtocol set true to remove javascript: pseudo-protocol from inline event handlers. + */ + public void setRemoveJavaScriptProtocol(boolean removeJavaScriptProtocol) { + this.removeJavaScriptProtocol = removeJavaScriptProtocol; + } + + /** + * Returns true if HTTP protocol will be removed from href, src, cite, and action tag attributes. + * + * @return true if HTTP protocol will be removed from href, src, cite, and action tag attributes. + */ + public boolean isRemoveHttpProtocol() { + return removeHttpProtocol; + } + + /** + * If set to true, HTTP protocol will be removed from href, src, cite, and action tag attributes. + * URL without a protocol would make a browser use document's current protocol instead. + * + *

Tags marked with rel="external" will be skipped. + * + *

For example: + *

<a href="http://example.com"> <script src="http://google.com/js.js" rel="external"> + *

would become: + *

<a href="//example.com"> <script src="http://google.com/js.js" rel="external"> + * + *

Default is false. + * + * @param removeHttpProtocol set true to remove HTTP protocol from tag attributes + */ + public void setRemoveHttpProtocol(boolean removeHttpProtocol) { + this.removeHttpProtocol = removeHttpProtocol; + } + + /** + * Returns true if HTTPS protocol will be removed from href, src, cite, and action tag attributes. + * + * @return true if HTTPS protocol will be removed from href, src, cite, and action tag attributes. + */ + public boolean isRemoveHttpsProtocol() { + return removeHttpsProtocol; + } + + /** + * If set to true, HTTPS protocol will be removed from href, src, cite, and action tag attributes. + * URL without a protocol would make a browser use document's current protocol instead. + * + *

Tags marked with rel="external" will be skipped. + * + *

For example: + *

<a href="https://example.com"> <script src="https://google.com/js.js" rel="external"> + *

would become: + *

<a href="//example.com"> <script src="https://google.com/js.js" rel="external"> + * + *

Default is false. + * + * @param removeHttpsProtocol set true to remove HTTP protocol from tag attributes + */ + public void setRemoveHttpsProtocol(boolean removeHttpsProtocol) { + this.removeHttpsProtocol = removeHttpsProtocol; + } + + /** + * Returns true if HTML compression statistics is generated + * + * @return true if HTML compression statistics is generated + */ + public boolean isGenerateStatistics() { + return generateStatistics; + } + + /** + * If set to true, HTML compression statistics will be generated. + * + *

Important: Enabling statistics makes HTML compressor not thread safe. + * + *

Default is false. + * + * @param generateStatistics set true to generate HTML compression statistics + * + * @see #getStatistics() + */ + public void setGenerateStatistics(boolean generateStatistics) { + this.generateStatistics = generateStatistics; + } + + /** + * Returns {@link HtmlCompressorStatistics} object containing statistics of the last HTML compression, if enabled. + * Should be called after {@link #compress(String)} + * + * @return {@link HtmlCompressorStatistics} object containing last HTML compression statistics + * + * @see HtmlCompressorStatistics + * @see #setGenerateStatistics(boolean) + */ + public HtmlCompressorStatistics getStatistics() { + return statistics; + } + + /** + * Returns true if line breaks will be preserved. + * + * @return true if line breaks will be preserved. + */ + public boolean isPreserveLineBreaks() { + return preserveLineBreaks; + } + + /** + * If set to true, line breaks will be preserved. + * + *

Default is false. + * + * @param preserveLineBreaks set true to preserve line breaks + */ + public void setPreserveLineBreaks(boolean preserveLineBreaks) { + this.preserveLineBreaks = preserveLineBreaks; + } + + /** + * Returns a comma separated list of tags around which spaces will be removed. + * + * @return a comma separated list of tags around which spaces will be removed. + */ + public String getRemoveSurroundingSpaces() { + return removeSurroundingSpaces; + } + + /** + * Enables surrounding spaces removal around provided comma separated list of tags. + * + *

Besides custom defined lists, you can pass one of 3 predefined lists of tags: + * {@link #BLOCK_TAGS_MIN BLOCK_TAGS_MIN}, + * {@link #BLOCK_TAGS_MAX BLOCK_TAGS_MAX}, + * {@link #ALL_TAGS ALL_TAGS}. + * + * @param tagList a comma separated list of tags around which spaces will be removed + */ + public void setRemoveSurroundingSpaces(String tagList) { + if(tagList != null && tagList.length() == 0) { + tagList = null; + } + this.removeSurroundingSpaces = tagList; + } + +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/htmlcompressor/compressor/HtmlCompressorStatistics.java b/src/main/java/com/googlecode/htmlcompressor/compressor/HtmlCompressorStatistics.java new file mode 100644 index 0000000..143b470 --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/compressor/HtmlCompressorStatistics.java @@ -0,0 +1,106 @@ +package com.googlecode.htmlcompressor.compressor; +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Class that stores HTML compression statistics + * + * @author Sergiy Kovalchuk + * @see HtmlCompressor#getStatistics() + */ +public class HtmlCompressorStatistics { + + private HtmlMetrics originalMetrics = new HtmlMetrics(); + private HtmlMetrics compressedMetrics = new HtmlMetrics(); + private long time = 0; + private int preservedSize = 0; + + /** + * Returns metrics of an uncompressed document + * + * @return metrics of an uncompressed document + * @see HtmlMetrics + */ + public HtmlMetrics getOriginalMetrics() { + return originalMetrics; + } + + /** + * @param originalMetrics the originalMetrics to set + */ + public void setOriginalMetrics(HtmlMetrics originalMetrics) { + this.originalMetrics = originalMetrics; + } + + /** + * Returns metrics of a compressed document + * + * @return metrics of a compressed document + * @see HtmlMetrics + */ + public HtmlMetrics getCompressedMetrics() { + return compressedMetrics; + } + + /** + * @param compressedMetrics the compressedMetrics to set + */ + public void setCompressedMetrics(HtmlMetrics compressedMetrics) { + this.compressedMetrics = compressedMetrics; + } + + /** + * Returns total compression time. + * + *

Please note that compression performance varies very significantly depending on whether it was + * a cold run or not (specifics of Java VM), so for accurate real world results it is recommended + * to take measurements accordingly. + * + * @return the compression time, in milliseconds + * + */ + public long getTime() { + return time; + } + + /** + * @param time the time to set + */ + public void setTime(long time) { + this.time = time; + } + + /** + * Returns total size of blocks that were skipped by the compressor + * (for example content inside <pre> tags or inside + * <script> tags with disabled javascript compression) + * + * @return the total size of blocks that were skipped by the compressor, in bytes + */ + public int getPreservedSize() { + return preservedSize; + } + + /** + * @param preservedSize the preservedSize to set + */ + public void setPreservedSize(int preservedSize) { + this.preservedSize = preservedSize; + } + + @Override + public String toString() { + return String.format("Time=%d, Preserved=%d, Original={%s}, Compressed={%s}", time, preservedSize, originalMetrics.toString(), compressedMetrics.toString()); + } +} diff --git a/src/main/java/com/googlecode/htmlcompressor/compressor/HtmlMetrics.java b/src/main/java/com/googlecode/htmlcompressor/compressor/HtmlMetrics.java new file mode 100644 index 0000000..345dd8d --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/compressor/HtmlMetrics.java @@ -0,0 +1,114 @@ +package com.googlecode.htmlcompressor.compressor; +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Class that stores metrics about HTML documents. + * + * @author Sergiy Kovalchuk + */ +public class HtmlMetrics { + + private int filesize = 0; + private int emptyChars = 0; + private int inlineScriptSize = 0; + private int inlineStyleSize = 0; + private int inlineEventSize = 0; + + /** + * Returns total filesize of a document + * + * @return total filesize of a document, in bytes + */ + public int getFilesize() { + return filesize; + } + + /** + * @param filesize the filesize to set + */ + public void setFilesize(int filesize) { + this.filesize = filesize; + } + + /** + * Returns number of empty characters (spaces, tabs, end of lines) in a document + * + * @return number of empty characters in a document + */ + public int getEmptyChars() { + return emptyChars; + } + + /** + * @param emptyChars the emptyChars to set + */ + public void setEmptyChars(int emptyChars) { + this.emptyChars = emptyChars; + } + + /** + * Returns total size of inline <script> tags + * + * @return total size of inline <script> tags, in bytes + */ + public int getInlineScriptSize() { + return inlineScriptSize; + } + + /** + * @param inlineScriptSize the inlineScriptSize to set + */ + public void setInlineScriptSize(int inlineScriptSize) { + this.inlineScriptSize = inlineScriptSize; + } + + /** + * Returns total size of inline <style> tags + * + * @return total size of inline <style> tags, in bytes + */ + public int getInlineStyleSize() { + return inlineStyleSize; + } + + /** + * @param inlineStyleSize the inlineStyleSize to set + */ + public void setInlineStyleSize(int inlineStyleSize) { + this.inlineStyleSize = inlineStyleSize; + } + + /** + * Returns total size of inline event handlers (onclick, etc) + * + * @return total size of inline event handlers, in bytes + */ + public int getInlineEventSize() { + return inlineEventSize; + } + + /** + * @param inlineEventSize the inlineEventSize to set + */ + public void setInlineEventSize(int inlineEventSize) { + this.inlineEventSize = inlineEventSize; + } + + @Override + public String toString() { + return String.format("Filesize=%d, Empty Chars=%d, Script Size=%d, Style Size=%d, Event Handler Size=%d", filesize, emptyChars, inlineScriptSize, inlineStyleSize, inlineEventSize); + } + +} diff --git a/src/main/java/com/googlecode/htmlcompressor/compressor/XmlCompressor.java b/src/main/java/com/googlecode/htmlcompressor/compressor/XmlCompressor.java new file mode 100644 index 0000000..9abcb71 --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/compressor/XmlCompressor.java @@ -0,0 +1,203 @@ +package com.googlecode.htmlcompressor.compressor; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Class that compresses given XML source by removing comments, extra spaces and + * line breaks while preserving content within CDATA blocks. + * + * @author Sergiy Kovalchuk + */ +public class XmlCompressor implements Compressor { + + private boolean enabled = true; + + //default settings + private boolean removeComments = true; + private boolean removeIntertagSpaces = true; + + //temp replacements for preserved blocks + protected static final String tempCdataBlock = "%%%COMPRESS~CDATA~{0,number,#}%%%"; + + //compiled regex patterns + protected static final Pattern cdataPattern = Pattern.compile("", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern commentPattern = Pattern.compile("", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern intertagPattern = Pattern.compile(">\\s+<", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern tagEndSpacePattern = Pattern.compile("(<(?:[^>]+?))(?:\\s+?)(/?>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern multispacePattern = Pattern.compile("\\s+(?=[^<]*?>)", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + protected static final Pattern tagPropertyPattern = Pattern.compile("(\\s\\w+)\\s*=\\s*(?=[^<]*?>)", Pattern.CASE_INSENSITIVE); + + protected static final Pattern tempCdataPattern = Pattern.compile("%%%COMPRESS~CDATA~(\\d+?)%%%", Pattern.DOTALL | Pattern.CASE_INSENSITIVE); + + /** + * The main method that compresses given XML source and returns compressed result. + * + * @param xml XML content to compress + * @return compressed content. + */ + @Override + public String compress(String xml) { + if(!enabled || xml == null || xml.length() == 0) { + return xml; + } + + //preserved block containers + List cdataBlocks = new ArrayList(); + + //preserve blocks + xml = preserveBlocks(xml, cdataBlocks); + + //process pure xml + xml = processXml(xml); + + //return preserved blocks + xml = returnBlocks(xml, cdataBlocks); + + return xml.trim(); + } + + protected String preserveBlocks(String xml, List cdataBlocks) { + //preserve CDATA blocks + Matcher matcher = cdataPattern.matcher(xml); + int index = 0; + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + cdataBlocks.add(matcher.group(0)); + matcher.appendReplacement(sb, MessageFormat.format(tempCdataBlock, index++)); + } + matcher.appendTail(sb); + xml = sb.toString(); + + return xml; + } + + protected String returnBlocks(String xml, List cdataBlocks) { + //put CDATA blocks back + Matcher matcher = tempCdataPattern.matcher(xml); + StringBuffer sb = new StringBuffer(); + while(matcher.find()) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(cdataBlocks.get(Integer.parseInt(matcher.group(1))))); + } + matcher.appendTail(sb); + xml = sb.toString(); + + return xml; + } + + protected String processXml(String xml) { + //remove comments + xml = removeComments(xml); + + //remove inter-tag spaces + xml = removeIntertagSpaces(xml); + + //remove unneeded spaces inside tags + xml = removeSpacesInsideTags(xml); + + return xml; + } + + protected String removeSpacesInsideTags(String xml) { + //replace miltiple spaces inside tags with single spaces + xml = multispacePattern.matcher(xml).replaceAll(" "); + + //remove spaces around equal sign inside tags + xml = tagPropertyPattern.matcher(xml).replaceAll("$1="); + + //remove ending spaces inside tags + xml = tagEndSpacePattern.matcher(xml).replaceAll("$1$2"); + return xml; + } + + protected String removeIntertagSpaces(String xml) { + //remove inter-tag spaces + if(removeIntertagSpaces) { + xml = intertagPattern.matcher(xml).replaceAll("><"); + } + return xml; + } + + protected String removeComments(String xml) { + //remove comments + if(removeComments) { + xml = commentPattern.matcher(xml).replaceAll(""); + } + return xml; + } + + /** + * Returns true if compression is enabled. + * + * @return true if compression is enabled. + */ + public boolean isEnabled() { + return enabled; + } + + /** + * If set to false all compression will be bypassed. Might be useful for testing purposes. + * Default is true. + * + * @param enabled set false to bypass all compression + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + /** + * Returns true if all XML comments will be removed. + * + * @return true if all XML comments will be removed + */ + public boolean isRemoveComments() { + return removeComments; + } + + /** + * If set to true all XML comments will be removed. + * Default is true. + * + * @param removeComments set true to remove all XML comments + */ + public void setRemoveComments(boolean removeComments) { + this.removeComments = removeComments; + } + + /** + * Returns true if all inter-tag whitespace characters will be removed. + * + * @return true if all inter-tag whitespace characters will be removed. + */ + public boolean isRemoveIntertagSpaces() { + return removeIntertagSpaces; + } + + /** + * If set to true all inter-tag whitespace characters will be removed. + * Default is true. + * + * @param removeIntertagSpaces set true to remove all inter-tag whitespace characters + */ + public void setRemoveIntertagSpaces(boolean removeIntertagSpaces) { + this.removeIntertagSpaces = removeIntertagSpaces; + } + +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/htmlcompressor/compressor/YuiCssCompressor.java b/src/main/java/com/googlecode/htmlcompressor/compressor/YuiCssCompressor.java new file mode 100644 index 0000000..da591ec --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/compressor/YuiCssCompressor.java @@ -0,0 +1,81 @@ +package com.googlecode.htmlcompressor.compressor; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; + +import com.yahoo.platform.yui.compressor.CssCompressor; + +/** + * Basic CSS compressor implementation using Yahoo YUI Compressor + * that could be used by {@link HtmlCompressor} for inline CSS compression. + * + * @author Sergiy Kovalchuk + * + * @see HtmlCompressor#setCssCompressor(Compressor) + * @see Yahoo YUI Compressor + */ +public class YuiCssCompressor implements Compressor { + + private int lineBreak = -1; + + public YuiCssCompressor() { + } + + @Override + public String compress(String source) { + StringWriter result = new StringWriter(); + + try { + CssCompressor compressor = new CssCompressor(new StringReader(source)); + compressor.compress(result, lineBreak); + } catch (IOException e) { + result.write(source); + e.printStackTrace(); + } + + return result.toString(); + } + + /** + * Returns number of symbols per line Yahoo YUI Compressor + * will use during CSS compression. + * This corresponds to --line-break command line option. + * + * @return line-break parameter value used for CSS compression. + * + * @see Yahoo YUI Compressor + */ + public int getLineBreak() { + return lineBreak; + } + /** + * Tells Yahoo YUI Compressor to break lines after the specified number of symbols + * during CSS compression. This corresponds to + * --line-break command line option. + * This option has effect only if CSS compression is enabled. + * Default is -1 to disable line breaks. + * + * @param lineBreak set number of symbols per line + * + * @see Yahoo YUI Compressor + */ + public void setLineBreak(int lineBreak) { + this.lineBreak = lineBreak; + } + +} diff --git a/src/main/java/com/googlecode/htmlcompressor/compressor/YuiJavaScriptCompressor.java b/src/main/java/com/googlecode/htmlcompressor/compressor/YuiJavaScriptCompressor.java new file mode 100644 index 0000000..c4cb1cc --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/compressor/YuiJavaScriptCompressor.java @@ -0,0 +1,239 @@ +package com.googlecode.htmlcompressor.compressor; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; + +import org.mozilla.javascript.ErrorReporter; +import org.mozilla.javascript.EvaluatorException; + +import com.yahoo.platform.yui.compressor.JavaScriptCompressor; + +/** + * Basic JavaScript compressor implementation using Yahoo YUI Compressor + * that could be used by {@link HtmlCompressor} for inline JavaScript compression. + * + * @author Sergiy Kovalchuk + * + * @see HtmlCompressor#setJavaScriptCompressor(Compressor) + * @see Yahoo YUI Compressor + */ +public class YuiJavaScriptCompressor implements Compressor { + + //YUICompressor default settings + private boolean noMunge = false; + private boolean preserveAllSemiColons = false; + private boolean disableOptimizations = false; + private int lineBreak = -1; + + private ErrorReporter errorReporter = new DefaultErrorReporter(); + + public YuiJavaScriptCompressor() { + } + + @Override + public String compress(String source) { + + StringWriter result = new StringWriter(); + try { + JavaScriptCompressor compressor = new JavaScriptCompressor(new StringReader(source), errorReporter); + compressor.compress(result, lineBreak, !noMunge, false, preserveAllSemiColons, disableOptimizations); + } catch (IOException e) { + result.write(source); + e.printStackTrace(); + } + return result.toString(); + + } + + /** + * Default ErrorReporter implementation that uses System.err + * stream for error reporting. Used by YUI Compressor to log errors during JavaScript compression. + * + * @see Yahoo YUI Compressor + * @see ErrorReporter Interface + * + * @author Sergiy Kovalchuk + * + */ + public static class DefaultErrorReporter implements ErrorReporter{ + + public void warning(String message, String sourceName, int line, String lineSource, int lineOffset) { + if (line < 0) { + System.err.println("[WARNING] HtmlCompressor: \"" + message + "\" during JavaScript compression"); + } else { + System.err.println("[WARNING] HtmlCompressor: \"" + message + "\" at line [" + line + ":" + lineOffset + "] during JavaScript compression" + (lineSource != null ? ": " + lineSource : "")); + } + } + + public void error(String message, String sourceName, int line, String lineSource, int lineOffset) { + if (line < 0) { + System.err.println("[ERROR] HtmlCompressor: \"" + message + "\" during JavaScript compression"); + } else { + System.err.println("[ERROR] HtmlCompressor: \"" + message + "\" at line [" + line + ":" + lineOffset + "] during JavaScript compression" + (lineSource != null ? ": " + lineSource : "")); + } + } + + public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource, int lineOffset) { + error(message, sourceName, line, lineSource, lineOffset); + return new EvaluatorException(message); + } + } + + /** + * Returns true if Yahoo YUI Compressor + * will only minify javascript without obfuscating local symbols. + * This corresponds to --nomunge command line option. + * + * @return nomunge parameter value used for JavaScript compression. + * + * @see Yahoo YUI Compressor + */ + public boolean isNoMunge() { + return noMunge; + } + + /** + * Tells Yahoo YUI Compressor to only minify javascript without obfuscating + * local symbols. This corresponds to --nomunge command line option. + * This option has effect only if JavaScript compression is enabled. + * Default is false. + * + * @param noMunge set true to enable nomunge mode + * + * @see Yahoo YUI Compressor + */ + public void setNoMunge(boolean noMunge) { + this.noMunge = noMunge; + } + + /** + * Returns true if Yahoo YUI Compressor + * will preserve unnecessary semicolons during JavaScript compression. + * This corresponds to --preserve-semi command line option. + * + * @return preserve-semi parameter value used for JavaScript compression. + * + * @see Yahoo YUI Compressor + */ + public boolean isPreserveAllSemiColons() { + return preserveAllSemiColons; + } + + /** + * Tells Yahoo YUI Compressor to preserve unnecessary semicolons + * during JavaScript compression. This corresponds to + * --preserve-semi command line option. + * This option has effect only if JavaScript compression is enabled. + * Default is false. + * + * @param preserveAllSemiColons set true to enable preserve-semi mode + * + * @see Yahoo YUI Compressor + */ + public void setPreserveAllSemiColons(boolean preserveAllSemiColons) { + this.preserveAllSemiColons = preserveAllSemiColons; + } + + /** + * Returns true if Yahoo YUI Compressor + * will disable all the built-in micro optimizations during JavaScript compression. + * This corresponds to --disable-optimizations command line option. + * + * @return disable-optimizations parameter value used for JavaScript compression. + * + * @see Yahoo YUI Compressor + */ + public boolean isDisableOptimizations() { + return disableOptimizations; + } + + /** + * Tells Yahoo YUI Compressor to disable all the built-in micro optimizations + * during JavaScript compression. This corresponds to + * --disable-optimizations command line option. + * This option has effect only if JavaScript compression is enabled. + * Default is false. + * + * @param disableOptimizations set true to enable + * disable-optimizations mode + * + * @see Yahoo YUI Compressor + */ + public void setDisableOptimizations(boolean disableOptimizations) { + this.disableOptimizations = disableOptimizations; + } + + /** + * Returns number of symbols per line Yahoo YUI Compressor + * will use during JavaScript compression. + * This corresponds to --line-break command line option. + * + * @return line-break parameter value used for JavaScript compression. + * + * @see Yahoo YUI Compressor + */ + public int getLineBreak() { + return lineBreak; + } + + /** + * Tells Yahoo YUI Compressor to break lines after the specified number of symbols + * during JavaScript compression. This corresponds to + * --line-break command line option. + * This option has effect only if JavaScript compression is enabled. + * Default is -1 to disable line breaks. + * + * @param lineBreak set number of symbols per line + * + * @see Yahoo YUI Compressor + */ + public void setLineBreak(int lineBreak) { + this.lineBreak = lineBreak; + } + + /** + * Returns ErrorReporter used by YUI Compressor to log error messages + * during JavasSript compression + * + * @return ErrorReporter used by YUI Compressor to log error messages + * during JavasSript compression + * + * @see Yahoo YUI Compressor + * @see Error Reporter Interface + */ + public ErrorReporter getErrorReporter() { + return errorReporter; + } + + /** + * Sets ErrorReporter that YUI Compressor will use for reporting errors during + * JavaScript compression. If no ErrorReporter was provided + * {@link YuiJavaScriptCompressor.DefaultErrorReporter} will be used + * which reports errors to System.err stream. + * + * @param errorReporter ErrorReporter that will be used by YUI Compressor + * + * @see YuiJavaScriptCompressor.DefaultErrorReporter + * @see Yahoo YUI Compressor + * @see ErrorReporter Interface + */ + public void setErrorReporter(ErrorReporter errorReporter) { + this.errorReporter = errorReporter; + } + +} diff --git a/src/main/java/com/googlecode/htmlcompressor/taglib/CssCompressorTag.java b/src/main/java/com/googlecode/htmlcompressor/taglib/CssCompressorTag.java new file mode 100644 index 0000000..ef1330b --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/taglib/CssCompressorTag.java @@ -0,0 +1,87 @@ +package com.googlecode.htmlcompressor.taglib; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.BodyContent; +import javax.servlet.jsp.tagext.BodyTagSupport; + +import com.googlecode.htmlcompressor.compressor.HtmlCompressor; +import com.googlecode.htmlcompressor.compressor.YuiCssCompressor; + +/** + * JSP tag that compresses an CSS content within <compress:css> using Yahoo YUI Compressor. + * All CSS-related properties from {@link HtmlCompressor} are supported. + * + * @see HtmlCompressor + * @see Yahoo YUI Compressor + * + * @author Sergiy Kovalchuk + */ +@SuppressWarnings("serial") +public class CssCompressorTag extends BodyTagSupport { + + private boolean enabled = true; + + //YUICompressor settings + private int yuiCssLineBreak = -1; + + @Override + public int doEndTag() throws JspException { + + BodyContent bodyContent = getBodyContent(); + String content = bodyContent.getString(); + + try { + if(enabled) { + //call YUICompressor + YuiCssCompressor compressor = new YuiCssCompressor(); + compressor.setLineBreak(yuiCssLineBreak); + String result = compressor.compress(content); + + bodyContent.clear(); + bodyContent.append(result); + bodyContent.writeOut(pageContext.getOut()); + } else { + bodyContent.clear(); + bodyContent.append(content); + bodyContent.writeOut(pageContext.getOut()); + } + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + return super.doEndTag(); + } + + /** + * @see HtmlCompressor#setYuiCssLineBreak(int) + */ + public void setYuiCssLineBreak(int yuiCssLineBreak) { + this.yuiCssLineBreak = yuiCssLineBreak; + } + + /** + * @see HtmlCompressor#setEnabled(boolean) + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/htmlcompressor/taglib/HtmlCompressorTag.java b/src/main/java/com/googlecode/htmlcompressor/taglib/HtmlCompressorTag.java new file mode 100644 index 0000000..5c94a9d --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/taglib/HtmlCompressorTag.java @@ -0,0 +1,321 @@ +package com.googlecode.htmlcompressor.taglib; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.BodyContent; +import javax.servlet.jsp.tagext.BodyTagSupport; + +import com.google.javascript.jscomp.CompilationLevel; +import com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor; +import com.googlecode.htmlcompressor.compressor.HtmlCompressor; +import com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor; + +/** + * JSP tag that compresses an HTML content within <compress:html>. + * Compression parameters are set by default (no JavaScript and CSS compression). + * + * @see HtmlCompressor + * + * @author Sergiy Kovalchuk + */ +@SuppressWarnings("serial") +public class HtmlCompressorTag extends BodyTagSupport { + + private boolean enabled = true; + + //default settings + private boolean removeComments = true; + private boolean removeMultiSpaces = true; + + //optional settings + private boolean removeIntertagSpaces = false; + private boolean removeQuotes = false; + private boolean preserveLineBreaks = false; + private boolean simpleDoctype = false; + private boolean removeScriptAttributes = false; + private boolean removeStyleAttributes = false; + private boolean removeLinkAttributes = false; + private boolean removeFormAttributes = false; + private boolean removeInputAttributes = false; + private boolean simpleBooleanAttributes = false; + private boolean removeJavaScriptProtocol = false; + private boolean removeHttpProtocol = false; + private boolean removeHttpsProtocol = false; + private boolean compressJavaScript = false; + private boolean compressCss = false; + + private String jsCompressor = HtmlCompressor.JS_COMPRESSOR_YUI; + + //YUICompressor settings + private boolean yuiJsNoMunge = false; + private boolean yuiJsPreserveAllSemiColons = false; + private boolean yuiJsDisableOptimizations = false; + private int yuiJsLineBreak = -1; + private int yuiCssLineBreak = -1; + + //Closure compressor settings + private String closureOptLevel = ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE; + + @Override + public int doEndTag() throws JspException { + + BodyContent bodyContent = getBodyContent(); + String content = bodyContent.getString(); + + HtmlCompressor htmlCompressor = new HtmlCompressor(); + htmlCompressor.setEnabled(enabled); + htmlCompressor.setRemoveComments(removeComments); + htmlCompressor.setRemoveMultiSpaces(removeMultiSpaces); + htmlCompressor.setRemoveIntertagSpaces(removeIntertagSpaces); + htmlCompressor.setRemoveQuotes(removeQuotes); + htmlCompressor.setPreserveLineBreaks(preserveLineBreaks); + htmlCompressor.setCompressJavaScript(compressJavaScript); + htmlCompressor.setCompressCss(compressCss); + htmlCompressor.setYuiJsNoMunge(yuiJsNoMunge); + htmlCompressor.setYuiJsPreserveAllSemiColons(yuiJsPreserveAllSemiColons); + htmlCompressor.setYuiJsDisableOptimizations(yuiJsDisableOptimizations); + htmlCompressor.setYuiJsLineBreak(yuiJsLineBreak); + htmlCompressor.setYuiCssLineBreak(yuiCssLineBreak); + + htmlCompressor.setSimpleDoctype(simpleDoctype); + htmlCompressor.setRemoveScriptAttributes(removeScriptAttributes); + htmlCompressor.setRemoveStyleAttributes(removeStyleAttributes); + htmlCompressor.setRemoveLinkAttributes(removeLinkAttributes); + htmlCompressor.setRemoveFormAttributes(removeFormAttributes); + htmlCompressor.setRemoveInputAttributes(removeInputAttributes); + htmlCompressor.setSimpleBooleanAttributes(simpleBooleanAttributes); + htmlCompressor.setRemoveJavaScriptProtocol(removeJavaScriptProtocol); + htmlCompressor.setRemoveHttpProtocol(removeHttpProtocol); + htmlCompressor.setRemoveHttpsProtocol(removeHttpsProtocol); + + if(compressJavaScript && jsCompressor.equalsIgnoreCase(HtmlCompressor.JS_COMPRESSOR_CLOSURE)) { + ClosureJavaScriptCompressor closureCompressor = new ClosureJavaScriptCompressor(); + if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_ADVANCED)) { + closureCompressor.setCompilationLevel(CompilationLevel.ADVANCED_OPTIMIZATIONS); + } else if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_WHITESPACE)) { + closureCompressor.setCompilationLevel(CompilationLevel.WHITESPACE_ONLY); + } else { + closureCompressor.setCompilationLevel(CompilationLevel.SIMPLE_OPTIMIZATIONS); + } + htmlCompressor.setJavaScriptCompressor(closureCompressor); + } + + try { + bodyContent.clear(); + bodyContent.append(htmlCompressor.compress(content)); + bodyContent.writeOut(pageContext.getOut()); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + return super.doEndTag(); + } + + /** + * @see HtmlCompressor#setCompressJavaScript(boolean) + */ + public void setCompressJavaScript(boolean compressJavaScript) { + this.compressJavaScript = compressJavaScript; + } + + /** + * @see HtmlCompressor#setCompressCss(boolean) + */ + public void setCompressCss(boolean compressCss) { + this.compressCss = compressCss; + } + + /** + * @see HtmlCompressor#setYuiJsNoMunge(boolean) + */ + public void setYuiJsNoMunge(boolean yuiJsNoMunge) { + this.yuiJsNoMunge = yuiJsNoMunge; + } + + /** + * @see HtmlCompressor#setYuiJsPreserveAllSemiColons(boolean) + */ + public void setYuiJsPreserveAllSemiColons(boolean yuiJsPreserveAllSemiColons) { + this.yuiJsPreserveAllSemiColons = yuiJsPreserveAllSemiColons; + } + + /** + * @see HtmlCompressor#setYuiJsDisableOptimizations(boolean) + */ + public void setYuiJsDisableOptimizations(boolean yuiJsDisableOptimizations) { + this.yuiJsDisableOptimizations = yuiJsDisableOptimizations; + } + + /** + * @see HtmlCompressor#setYuiJsLineBreak(int) + */ + public void setYuiJsLineBreak(int yuiJsLineBreak) { + this.yuiJsLineBreak = yuiJsLineBreak; + } + + /** + * @see HtmlCompressor#setYuiCssLineBreak(int) + */ + public void setYuiCssLineBreak(int yuiCssLineBreak) { + this.yuiCssLineBreak = yuiCssLineBreak; + } + + /** + * @see HtmlCompressor#setRemoveQuotes(boolean) + */ + public void setRemoveQuotes(boolean removeQuotes) { + this.removeQuotes = removeQuotes; + } + + /** + * @see HtmlCompressor#setPreserveLineBreaks(boolean) + */ + public void setPreserveLineBreaks(boolean preserveLineBreaks) { + this.preserveLineBreaks = preserveLineBreaks; + } + + /** + * @see HtmlCompressor#setEnabled(boolean) + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + /** + * @see HtmlCompressor#setRemoveComments(boolean) + */ + public void setRemoveComments(boolean removeComments) { + this.removeComments = removeComments; + } + + /** + * @see HtmlCompressor#setRemoveMultiSpaces(boolean) + */ + public void setRemoveMultiSpaces(boolean removeMultiSpaces) { + this.removeMultiSpaces = removeMultiSpaces; + } + + /** + * @see HtmlCompressor#setRemoveIntertagSpaces(boolean) + */ + public void setRemoveIntertagSpaces(boolean removeIntertagSpaces) { + this.removeIntertagSpaces = removeIntertagSpaces; + } + + /** + * Sets JavaScript compressor implementation that will be used + * to compress inline JavaScript in HTML. + * + * @param jsCompressor Could be either "yui" for using {@link YuiJavaScriptCompressor} (used by default if none provided) or + * "closure" for using {@link ClosureJavaScriptCompressor} + * + * @see YuiJavaScriptCompressor + * @see ClosureJavaScriptCompressor + * @see Yahoo YUI Compressor + * @see Google Closure Compiler + + */ + public void setJsCompressor(String jsCompressor) { + this.jsCompressor = jsCompressor; + } + + /** + * Sets level of optimization if Google Closure Compiler is used + * for compressing inline JavaScript. + * + * @param closureOptLevel Could be either "simple" (used by default), "whitespace" or "advanced" + * + * @see ClosureJavaScriptCompressor#setCompilationLevel(CompilationLevel) + */ + public void setClosureOptLevel(String closureOptLevel) { + this.closureOptLevel = closureOptLevel; + } + + /** + * @see HtmlCompressor#setSimpleDoctype(boolean) + */ + public void setSimpleDoctype(boolean simpleDoctype) { + this.simpleDoctype = simpleDoctype; + } + + /** + * @see HtmlCompressor#setRemoveScriptAttributes(boolean) + */ + public void setRemoveScriptAttributes(boolean removeScriptAttributes) { + this.removeScriptAttributes = removeScriptAttributes; + } + + /** + * @see HtmlCompressor#setRemoveStyleAttributes(boolean) + */ + public void setRemoveStyleAttributes(boolean removeStyleAttributes) { + this.removeStyleAttributes = removeStyleAttributes; + } + + /** + * @see HtmlCompressor#setRemoveLinkAttributes(boolean) + */ + public void setRemoveLinkAttributes(boolean removeLinkAttributes) { + this.removeLinkAttributes = removeLinkAttributes; + } + + /** + * @see HtmlCompressor#setRemoveFormAttributes(boolean) + */ + public void setRemoveFormAttributes(boolean removeFormAttributes) { + this.removeFormAttributes = removeFormAttributes; + } + + /** + * @see HtmlCompressor#setRemoveInputAttributes(boolean) + */ + public void setRemoveInputAttributes(boolean removeInputAttributes) { + this.removeInputAttributes = removeInputAttributes; + } + + /** + * @see HtmlCompressor#setSimpleBooleanAttributes(boolean) + */ + public void setSimpleBooleanAttributes(boolean simpleBooleanAttributes) { + this.simpleBooleanAttributes = simpleBooleanAttributes; + } + + /** + * @see HtmlCompressor#setRemoveJavaScriptProtocol(boolean) + */ + public void setRemoveJavaScriptProtocol(boolean removeJavaScriptProtocol) { + this.removeJavaScriptProtocol = removeJavaScriptProtocol; + } + + /** + * @see HtmlCompressor#setRemoveHttpProtocol(boolean) + */ + public void setRemoveHttpProtocol(boolean removeHttpProtocol) { + this.removeHttpProtocol = removeHttpProtocol; + } + + /** + * @see HtmlCompressor#setRemoveHttpsProtocol(boolean) + */ + public void setRemoveHttpsProtocol(boolean removeHttpsProtocol) { + this.removeHttpsProtocol = removeHttpsProtocol; + } + +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/htmlcompressor/taglib/JavaScriptCompressorTag.java b/src/main/java/com/googlecode/htmlcompressor/taglib/JavaScriptCompressorTag.java new file mode 100644 index 0000000..06bd33e --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/taglib/JavaScriptCompressorTag.java @@ -0,0 +1,171 @@ +package com.googlecode.htmlcompressor.taglib; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.BodyContent; +import javax.servlet.jsp.tagext.BodyTagSupport; + +import com.google.javascript.jscomp.CompilationLevel; +import com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor; +import com.googlecode.htmlcompressor.compressor.HtmlCompressor; +import com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor; + +/** + * JSP tag that compresses an JavaScript content within <compress:js> tags. + * All JavaScript-related properties from {@link HtmlCompressor} are supported. + * + * @see HtmlCompressor + * @see Yahoo YUI Compressor + * @see Google Closure Compiler + * + * @author Sergiy Kovalchuk + */ +@SuppressWarnings("serial") +public class JavaScriptCompressorTag extends BodyTagSupport { + + private boolean enabled = true; + + private String jsCompressor = HtmlCompressor.JS_COMPRESSOR_YUI; + + //YUICompressor settings + private boolean yuiJsNoMunge = false; + private boolean yuiJsPreserveAllSemiColons = false; + private boolean yuiJsDisableOptimizations = false; + private int yuiJsLineBreak = -1; + + //Closure compressor settings + private String closureOptLevel = ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE; + + @Override + public int doEndTag() throws JspException { + + BodyContent bodyContent = getBodyContent(); + String content = bodyContent.getString(); + + try { + if(enabled) { + + String result = content; + + if(jsCompressor.equalsIgnoreCase(HtmlCompressor.JS_COMPRESSOR_CLOSURE)) { + //call Closure compressor + ClosureJavaScriptCompressor closureCompressor = new ClosureJavaScriptCompressor(); + if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_ADVANCED)) { + closureCompressor.setCompilationLevel(CompilationLevel.ADVANCED_OPTIMIZATIONS); + } else if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_WHITESPACE)) { + closureCompressor.setCompilationLevel(CompilationLevel.WHITESPACE_ONLY); + } else { + closureCompressor.setCompilationLevel(CompilationLevel.SIMPLE_OPTIMIZATIONS); + } + + result = closureCompressor.compress(content); + + } else { + //call YUICompressor + YuiJavaScriptCompressor yuiCompressor = new YuiJavaScriptCompressor(); + yuiCompressor.setDisableOptimizations(yuiJsDisableOptimizations); + yuiCompressor.setLineBreak(yuiJsLineBreak); + yuiCompressor.setNoMunge(yuiJsNoMunge); + yuiCompressor.setPreserveAllSemiColons(yuiJsPreserveAllSemiColons); + + result = yuiCompressor.compress(content); + } + + bodyContent.clear(); + bodyContent.append(result); + bodyContent.writeOut(pageContext.getOut()); + } else { + bodyContent.clear(); + bodyContent.append(content); + bodyContent.writeOut(pageContext.getOut()); + } + + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + return super.doEndTag(); + } + + /** + * @see HtmlCompressor#setYuiJsNoMunge(boolean) + */ + public void setYuiJsNoMunge(boolean yuiJsNoMunge) { + this.yuiJsNoMunge = yuiJsNoMunge; + } + + /** + * @see HtmlCompressor#setYuiJsPreserveAllSemiColons(boolean) + */ + public void setYuiJsPreserveAllSemiColons(boolean yuiJsPreserveAllSemiColons) { + this.yuiJsPreserveAllSemiColons = yuiJsPreserveAllSemiColons; + } + + /** + * @see HtmlCompressor#setYuiJsDisableOptimizations(boolean) + */ + public void setYuiJsDisableOptimizations(boolean yuiJsDisableOptimizations) { + this.yuiJsDisableOptimizations = yuiJsDisableOptimizations; + } + + /** + * @see HtmlCompressor#setYuiJsLineBreak(int) + */ + public void setYuiJsLineBreak(int yuiJsLineBreak) { + this.yuiJsLineBreak = yuiJsLineBreak; + } + + /** + * @see HtmlCompressor#setEnabled(boolean) + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + /** + * Sets JavaScript compressor implementation that will be used + * to compress inline JavaScript in HTML. + * + * @param jsCompressor Could be either "yui" for using {@link YuiJavaScriptCompressor} (used by default if none provided) or + * "closure" for using {@link ClosureJavaScriptCompressor} + * + * @see YuiJavaScriptCompressor + * @see ClosureJavaScriptCompressor + * @see Yahoo YUI Compressor + * @see Google Closure Compiler + + */ + public void setJsCompressor(String jsCompressor) { + this.jsCompressor = jsCompressor; + } + + /** + * Sets level of optimization if Google Closure Compiler is used + * for compressing inline JavaScript. + * + * @param closureOptLevel Could be either "simple" (used by default), "whitespace" or "advanced" + * + * @see ClosureJavaScriptCompressor#setCompilationLevel(CompilationLevel) + */ + public void setClosureOptLevel(String closureOptLevel) { + this.closureOptLevel = closureOptLevel; + } + +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/htmlcompressor/taglib/XmlCompressorTag.java b/src/main/java/com/googlecode/htmlcompressor/taglib/XmlCompressorTag.java new file mode 100644 index 0000000..d92c82f --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/taglib/XmlCompressorTag.java @@ -0,0 +1,87 @@ +package com.googlecode.htmlcompressor.taglib; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.BodyContent; +import javax.servlet.jsp.tagext.BodyTagSupport; + +import com.googlecode.htmlcompressor.compressor.XmlCompressor; + +/** + * JSP tag that compresses an XML content within <compress:xml>. + * Compression parameters are set by default. + * + * @see XmlCompressor + * + * @author Sergiy Kovalchuk + */ +@SuppressWarnings("serial") +public class XmlCompressorTag extends BodyTagSupport { + + private boolean enabled = true; + + //default settings + private boolean removeComments = true; + private boolean removeIntertagSpaces = true; + + @Override + public int doEndTag() throws JspException { + + BodyContent bodyContent = getBodyContent(); + String content = bodyContent.getString(); + + XmlCompressor compressor = new XmlCompressor(); + compressor.setEnabled(enabled); + compressor.setRemoveComments(removeComments); + compressor.setRemoveIntertagSpaces(removeIntertagSpaces); + + try { + bodyContent.clear(); + bodyContent.append(compressor.compress(content)); + bodyContent.writeOut(pageContext.getOut()); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + return super.doEndTag(); + } + + /** + * @see XmlCompressor#setEnabled(boolean) + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + /** + * @see XmlCompressor#setRemoveComments(boolean) + */ + public void setRemoveComments(boolean removeComments) { + this.removeComments = removeComments; + } + + /** + * @see XmlCompressor#setRemoveIntertagSpaces(boolean) + */ + public void setRemoveIntertagSpaces(boolean removeIntertagSpaces) { + this.removeIntertagSpaces = removeIntertagSpaces; + } + +} \ No newline at end of file diff --git a/src/main/java/com/googlecode/htmlcompressor/velocity/CssCompressorDirective.java b/src/main/java/com/googlecode/htmlcompressor/velocity/CssCompressorDirective.java new file mode 100644 index 0000000..c24f350 --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/velocity/CssCompressorDirective.java @@ -0,0 +1,101 @@ +package com.googlecode.htmlcompressor.velocity; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; + +import org.apache.velocity.context.InternalContextAdapter; +import org.apache.velocity.exception.MethodInvocationException; +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.exception.TemplateInitException; +import org.apache.velocity.runtime.RuntimeServices; +import org.apache.velocity.runtime.directive.Directive; +import org.apache.velocity.runtime.log.Log; +import org.apache.velocity.runtime.parser.node.Node; + +import com.googlecode.htmlcompressor.compressor.HtmlCompressor; +import com.googlecode.htmlcompressor.compressor.YuiCssCompressor; + +/** + * Velocity directive that compresses an CSS content within #compressCss ... #end block. + * All CSS-related properties from {@link HtmlCompressor} are supported. + * + * @see HtmlCompressor + * @see Yahoo YUI Compressor + * + * @author Sergiy Kovalchuk + */ +public class CssCompressorDirective extends Directive { + + private Log log; + + private boolean enabled = true; + + //YUICompressor settings + private int yuiCssLineBreak = -1; + + public String getName() { + return "compressCss"; + } + + public int getType() { + return BLOCK; + } + + @Override + public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException { + super.init(rs, context, node); + log = rs.getLog(); + + //set compressor properties + enabled = rs.getBoolean("userdirective.compressCss.enabled", true); + yuiCssLineBreak = rs.getInt("userdirective.compressCss.yuiCssLineBreak", -1); + } + + public boolean render(InternalContextAdapter context, Writer writer, Node node) + throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { + + //render content + StringWriter content = new StringWriter(); + node.jjtGetChild(0).render(context, content); + + //compress + if(enabled) { + try { + + YuiCssCompressor compressor = new YuiCssCompressor(); + compressor.setLineBreak(yuiCssLineBreak); + String result = compressor.compress(content.toString()); + + writer.write(result); + } catch (Exception e) { + writer.write(content.toString()); + String msg = "Failed to compress content: "+content.toString(); + log.error(msg, e); + throw new RuntimeException(msg, e); + + } + } else { + writer.write(content.toString()); + } + + return true; + + } + +} diff --git a/src/main/java/com/googlecode/htmlcompressor/velocity/HtmlCompressorDirective.java b/src/main/java/com/googlecode/htmlcompressor/velocity/HtmlCompressorDirective.java new file mode 100644 index 0000000..639b7a4 --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/velocity/HtmlCompressorDirective.java @@ -0,0 +1,126 @@ +package com.googlecode.htmlcompressor.velocity; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; + +import org.apache.velocity.context.InternalContextAdapter; +import org.apache.velocity.exception.MethodInvocationException; +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.exception.TemplateInitException; +import org.apache.velocity.runtime.RuntimeServices; +import org.apache.velocity.runtime.directive.Directive; +import org.apache.velocity.runtime.parser.node.Node; +import org.apache.velocity.runtime.log.Log; + +import com.google.javascript.jscomp.CompilationLevel; +import com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor; +import com.googlecode.htmlcompressor.compressor.HtmlCompressor; + +/** + * Velocity directive that compresses an HTML content within #compressHtml ... #end block. + * Compression parameters are set by default (no JavaScript and CSS compression). + * + * @see HtmlCompressor + * + * @author Sergiy Kovalchuk + */ +public class HtmlCompressorDirective extends Directive { + + private static final HtmlCompressor htmlCompressor = new HtmlCompressor(); + + private Log log; + + public String getName() { + return "compressHtml"; + } + + public int getType() { + return BLOCK; + } + + @Override + public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException { + super.init(rs, context, node); + log = rs.getLog(); + + boolean compressJavaScript = rs.getBoolean("userdirective.compressHtml.compressJavaScript", false); + + //set compressor properties + htmlCompressor.setEnabled(rs.getBoolean("userdirective.compressHtml.enabled", true)); + htmlCompressor.setRemoveComments(rs.getBoolean("userdirective.compressHtml.removeComments", true)); + htmlCompressor.setRemoveMultiSpaces(rs.getBoolean("userdirective.compressHtml.removeMultiSpaces", true)); + htmlCompressor.setRemoveIntertagSpaces(rs.getBoolean("userdirective.compressHtml.removeIntertagSpaces", false)); + htmlCompressor.setRemoveQuotes(rs.getBoolean("userdirective.compressHtml.removeQuotes", false)); + htmlCompressor.setPreserveLineBreaks(rs.getBoolean("userdirective.compressHtml.preserveLineBreaks", false)); + htmlCompressor.setCompressJavaScript(compressJavaScript); + htmlCompressor.setCompressCss(rs.getBoolean("userdirective.compressHtml.compressCss", false)); + htmlCompressor.setYuiJsNoMunge(rs.getBoolean("userdirective.compressHtml.yuiJsNoMunge", false)); + htmlCompressor.setYuiJsPreserveAllSemiColons(rs.getBoolean("userdirective.compressHtml.yuiJsPreserveAllSemiColons", false)); + htmlCompressor.setYuiJsLineBreak(rs.getInt("userdirective.compressHtml.yuiJsLineBreak", -1)); + htmlCompressor.setYuiCssLineBreak(rs.getInt("userdirective.compressHtml.yuiCssLineBreak", -1)); + htmlCompressor.setSimpleDoctype(rs.getBoolean("userdirective.compressHtml.simpleDoctype", false)); + htmlCompressor.setRemoveScriptAttributes(rs.getBoolean("userdirective.compressHtml.removeScriptAttributes", false)); + htmlCompressor.setRemoveStyleAttributes(rs.getBoolean("userdirective.compressHtml.removeStyleAttributes", false)); + htmlCompressor.setRemoveLinkAttributes(rs.getBoolean("userdirective.compressHtml.removeLinkAttributes", false)); + htmlCompressor.setRemoveFormAttributes(rs.getBoolean("userdirective.compressHtml.removeFormAttributes", false)); + htmlCompressor.setRemoveInputAttributes(rs.getBoolean("userdirective.compressHtml.removeInputAttributes", false)); + htmlCompressor.setSimpleBooleanAttributes(rs.getBoolean("userdirective.compressHtml.simpleBooleanAttributes", false)); + htmlCompressor.setRemoveJavaScriptProtocol(rs.getBoolean("userdirective.compressHtml.removeJavaScriptProtocol", false)); + htmlCompressor.setRemoveHttpProtocol(rs.getBoolean("userdirective.compressHtml.removeHttpProtocol", false)); + htmlCompressor.setRemoveHttpsProtocol(rs.getBoolean("userdirective.compressHtml.removeHttpsProtocol", false)); + + + if(compressJavaScript && rs.getString("userdirective.compressHtml.jsCompressor", HtmlCompressor.JS_COMPRESSOR_YUI).equalsIgnoreCase(HtmlCompressor.JS_COMPRESSOR_CLOSURE)) { + String closureOptLevel = rs.getString("userdirective.compressHtml.closureOptLevel", ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE); + + ClosureJavaScriptCompressor closureCompressor = new ClosureJavaScriptCompressor(); + if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_ADVANCED)) { + closureCompressor.setCompilationLevel(CompilationLevel.ADVANCED_OPTIMIZATIONS); + } else if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_WHITESPACE)) { + closureCompressor.setCompilationLevel(CompilationLevel.WHITESPACE_ONLY); + } else { + closureCompressor.setCompilationLevel(CompilationLevel.SIMPLE_OPTIMIZATIONS); + } + + htmlCompressor.setJavaScriptCompressor(closureCompressor); + } + } + + public boolean render(InternalContextAdapter context, Writer writer, Node node) + throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { + + //render content + StringWriter content = new StringWriter(); + node.jjtGetChild(0).render(context, content); + + //compress + try { + writer.write(htmlCompressor.compress(content.toString())); + } catch (Exception e) { + writer.write(content.toString()); + String msg = "Failed to compress content: "+content.toString(); + log.error(msg, e); + throw new RuntimeException(msg, e); + + } + return true; + + } + +} diff --git a/src/main/java/com/googlecode/htmlcompressor/velocity/JavaScriptCompressorDirective.java b/src/main/java/com/googlecode/htmlcompressor/velocity/JavaScriptCompressorDirective.java new file mode 100644 index 0000000..cd812fc --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/velocity/JavaScriptCompressorDirective.java @@ -0,0 +1,137 @@ +package com.googlecode.htmlcompressor.velocity; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; + +import org.apache.velocity.context.InternalContextAdapter; +import org.apache.velocity.exception.MethodInvocationException; +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.exception.TemplateInitException; +import org.apache.velocity.runtime.RuntimeServices; +import org.apache.velocity.runtime.directive.Directive; +import org.apache.velocity.runtime.log.Log; +import org.apache.velocity.runtime.parser.node.Node; + +import com.google.javascript.jscomp.CompilationLevel; +import com.googlecode.htmlcompressor.compressor.ClosureJavaScriptCompressor; +import com.googlecode.htmlcompressor.compressor.HtmlCompressor; +import com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor; + +/** + * Velocity directive that compresses an JavaScript content within #compressJs ... #end block. + * All JavaScript-related properties from {@link HtmlCompressor} are supported. + * + * @see HtmlCompressor + * @see Yahoo YUI Compressor + * @see Google Closure Compiler + * + * @author Sergiy Kovalchuk + */ +public class JavaScriptCompressorDirective extends Directive { + + private Log log; + + private boolean enabled = true; + + private String jsCompressor = HtmlCompressor.JS_COMPRESSOR_YUI; + + //YUICompressor settings + private boolean yuiJsNoMunge = false; + private boolean yuiJsPreserveAllSemiColons = false; + private boolean yuiJsDisableOptimizations = false; + private int yuiJsLineBreak = -1; + + //Closure compressor settings + private String closureOptLevel = ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE; + + public String getName() { + return "compressJs"; + } + + public int getType() { + return BLOCK; + } + + @Override + public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException { + super.init(rs, context, node); + log = rs.getLog(); + + //set compressor properties + enabled = rs.getBoolean("userdirective.compressJs.enabled", true); + jsCompressor = rs.getString("userdirective.compressHtml.jsCompressor", HtmlCompressor.JS_COMPRESSOR_YUI); + yuiJsNoMunge = rs.getBoolean("userdirective.compressJs.yuiJsNoMunge", false); + yuiJsPreserveAllSemiColons = rs.getBoolean("userdirective.compressJs.yuiJsPreserveAllSemiColons", false); + yuiJsLineBreak = rs.getInt("userdirective.compressJs.yuiJsLineBreak", -1); + closureOptLevel = rs.getString("userdirective.compressHtml.closureOptLevel", ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE); + } + + public boolean render(InternalContextAdapter context, Writer writer, Node node) + throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { + + //render content + StringWriter content = new StringWriter(); + node.jjtGetChild(0).render(context, content); + + //compress + if(enabled) { + try { + String result = content.toString(); + + if(jsCompressor.equalsIgnoreCase(HtmlCompressor.JS_COMPRESSOR_CLOSURE)) { + //call Closure compressor + ClosureJavaScriptCompressor closureCompressor = new ClosureJavaScriptCompressor(); + if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_ADVANCED)) { + closureCompressor.setCompilationLevel(CompilationLevel.ADVANCED_OPTIMIZATIONS); + } else if(closureOptLevel.equalsIgnoreCase(ClosureJavaScriptCompressor.COMPILATION_LEVEL_WHITESPACE)) { + closureCompressor.setCompilationLevel(CompilationLevel.WHITESPACE_ONLY); + } else { + closureCompressor.setCompilationLevel(CompilationLevel.SIMPLE_OPTIMIZATIONS); + } + + result = closureCompressor.compress(result); + + } else { + //call YUICompressor + YuiJavaScriptCompressor yuiCompressor = new YuiJavaScriptCompressor(); + yuiCompressor.setDisableOptimizations(yuiJsDisableOptimizations); + yuiCompressor.setLineBreak(yuiJsLineBreak); + yuiCompressor.setNoMunge(yuiJsNoMunge); + yuiCompressor.setPreserveAllSemiColons(yuiJsPreserveAllSemiColons); + + result = yuiCompressor.compress(result); + } + + writer.write(result); + } catch (Exception e) { + writer.write(content.toString()); + String msg = "Failed to compress content: "+content.toString(); + log.error(msg, e); + throw new RuntimeException(msg, e); + + } + } else { + writer.write(content.toString()); + } + + return true; + + } + +} diff --git a/src/main/java/com/googlecode/htmlcompressor/velocity/XmlCompressorDirective.java b/src/main/java/com/googlecode/htmlcompressor/velocity/XmlCompressorDirective.java new file mode 100644 index 0000000..d4b7f10 --- /dev/null +++ b/src/main/java/com/googlecode/htmlcompressor/velocity/XmlCompressorDirective.java @@ -0,0 +1,87 @@ +package com.googlecode.htmlcompressor.velocity; + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; + +import org.apache.velocity.context.InternalContextAdapter; +import org.apache.velocity.exception.MethodInvocationException; +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.exception.TemplateInitException; +import org.apache.velocity.runtime.RuntimeServices; +import org.apache.velocity.runtime.directive.Directive; +import org.apache.velocity.runtime.log.Log; +import org.apache.velocity.runtime.parser.node.Node; + +import com.googlecode.htmlcompressor.compressor.XmlCompressor; + +/** + * Velocity directive that compresses an XML content within #compressXml ... #end block. + * Compression parameters are set by default. + * + * @see XmlCompressor + * + * @author Sergiy Kovalchuk + */ +public class XmlCompressorDirective extends Directive { + + private static final XmlCompressor xmlCompressor = new XmlCompressor(); + + private Log log; + + public String getName() { + return "compressXml"; + } + + public int getType() { + return BLOCK; + } + + @Override + public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException { + super.init(rs, context, node); + log = rs.getLog(); + + //set compressor properties + xmlCompressor.setEnabled(rs.getBoolean("userdirective.compressXml.enabled", true)); + xmlCompressor.setRemoveComments(rs.getBoolean("userdirective.compressXml.removeComments", true)); + xmlCompressor.setRemoveIntertagSpaces(rs.getBoolean("userdirective.compressXml.removeIntertagSpaces", true)); + } + + public boolean render(InternalContextAdapter context, Writer writer, Node node) + throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException { + + //render content + StringWriter content = new StringWriter(); + node.jjtGetChild(0).render(context, content); + + //compress + try { + writer.write(xmlCompressor.compress(content.toString())); + } catch (Exception e) { + writer.write(content.toString()); + String msg = "Failed to compress content: "+content.toString(); + log.error(msg, e); + throw new RuntimeException(msg, e); + + } + return true; + + } + +} diff --git a/src/main/java/jargs/gnu/CmdLineParser.java b/src/main/java/jargs/gnu/CmdLineParser.java new file mode 100644 index 0000000..320c7d5 --- /dev/null +++ b/src/main/java/jargs/gnu/CmdLineParser.java @@ -0,0 +1,525 @@ +package jargs.gnu; + +import java.text.NumberFormat; +import java.text.ParseException; +import java.util.Hashtable; +import java.util.Locale; +import java.util.Vector; + +/** + * Largely GNU-compatible command-line options parser. Has short (-v) and + * long-form (--verbose) option support, and also allows options with + * associated values (-d 2, --debug 2, --debug=2). Option processing + * can be explicitly terminated by the argument '--'. + * + * @author Steve Purcell + * @version $Revision$ + * @see jargs.examples.gnu.OptionTest + */ +public class CmdLineParser { + + /** + * Base class for exceptions that may be thrown when options are parsed + */ + public static abstract class OptionException extends Exception { + OptionException(String msg) { super(msg); } + } + + /** + * Thrown when the parsed command-line contains an option that is not + * recognised. getMessage() returns + * an error string suitable for reporting the error to the user (in + * English). + */ + public static class UnknownOptionException extends OptionException { + UnknownOptionException( String optionName ) { + this(optionName, "Unknown option '" + optionName + "'"); + } + + UnknownOptionException( String optionName, String msg ) { + super(msg); + this.optionName = optionName; + } + + /** + * @return the name of the option that was unknown (e.g. "-u") + */ + public String getOptionName() { return this.optionName; } + private String optionName = null; + } + + /** + * Thrown when the parsed commandline contains multiple concatenated + * short options, such as -abcd, where one is unknown. + * getMessage() returns an english human-readable error + * string. + * @author Vidar Holen + */ + public static class UnknownSuboptionException + extends UnknownOptionException { + private char suboption; + + UnknownSuboptionException( String option, char suboption ) { + super(option, "Illegal option: '"+suboption+"' in '"+option+"'"); + this.suboption=suboption; + } + public char getSuboption() { return suboption; } + } + + /** + * Thrown when the parsed commandline contains multiple concatenated + * short options, such as -abcd, where one or more requires a value. + * getMessage() returns an english human-readable error + * string. + * @author Vidar Holen + */ + public static class NotFlagException extends UnknownOptionException { + private char notflag; + + NotFlagException( String option, char unflaggish ) { + super(option, "Illegal option: '"+option+"', '"+ + unflaggish+"' requires a value"); + notflag=unflaggish; + } + + /** + * @return the first character which wasn't a boolean (e.g 'c') + */ + public char getOptionChar() { return notflag; } + } + + /** + * Thrown when an illegal or missing value is given by the user for + * an option that takes a value. getMessage() returns + * an error string suitable for reporting the error to the user (in + * English). + */ + public static class IllegalOptionValueException extends OptionException { + public IllegalOptionValueException( Option opt, String value ) { + super("Illegal value '" + value + "' for option " + + (opt.shortForm() != null ? "-" + opt.shortForm() + "/" : "") + + "--" + opt.longForm()); + this.option = opt; + this.value = value; + } + + /** + * @return the name of the option whose value was illegal (e.g. "-u") + */ + public Option getOption() { return this.option; } + + /** + * @return the illegal value + */ + public String getValue() { return this.value; } + private Option option; + private String value; + } + + /** + * Representation of a command-line option + */ + public static abstract class Option { + + protected Option( String longForm, boolean wantsValue ) { + this(null, longForm, wantsValue); + } + + protected Option( char shortForm, String longForm, + boolean wantsValue ) { + this(new String(new char[]{shortForm}), longForm, wantsValue); + } + + private Option( String shortForm, String longForm, boolean wantsValue ) { + if ( longForm == null ) + throw new IllegalArgumentException("Null longForm not allowed"); + this.shortForm = shortForm; + this.longForm = longForm; + this.wantsValue = wantsValue; + } + + public String shortForm() { return this.shortForm; } + + public String longForm() { return this.longForm; } + + /** + * Tells whether or not this option wants a value + */ + public boolean wantsValue() { return this.wantsValue; } + + public final Object getValue( String arg, Locale locale ) + throws IllegalOptionValueException { + if ( this.wantsValue ) { + if ( arg == null ) { + throw new IllegalOptionValueException(this, ""); + } + return this.parseValue(arg, locale); + } + else { + return Boolean.TRUE; + } + } + + /** + * Override to extract and convert an option value passed on the + * command-line + */ + protected Object parseValue( String arg, Locale locale ) + throws IllegalOptionValueException { + return null; + } + + private String shortForm = null; + private String longForm = null; + private boolean wantsValue = false; + + public static class BooleanOption extends Option { + public BooleanOption( char shortForm, String longForm ) { + super(shortForm, longForm, false); + } + public BooleanOption( String longForm ) { + super(longForm, false); + } + } + + /** + * An option that expects an integer value + */ + public static class IntegerOption extends Option { + public IntegerOption( char shortForm, String longForm ) { + super(shortForm, longForm, true); + } + public IntegerOption( String longForm ) { + super(longForm, true); + } + protected Object parseValue( String arg, Locale locale ) + throws IllegalOptionValueException { + try { + return new Integer(arg); + } + catch (NumberFormatException e) { + throw new IllegalOptionValueException(this, arg); + } + } + } + + /** + * An option that expects a long integer value + */ + public static class LongOption extends Option { + public LongOption( char shortForm, String longForm ) { + super(shortForm, longForm, true); + } + public LongOption( String longForm ) { + super(longForm, true); + } + protected Object parseValue( String arg, Locale locale ) + throws IllegalOptionValueException { + try { + return new Long(arg); + } + catch (NumberFormatException e) { + throw new IllegalOptionValueException(this, arg); + } + } + } + + /** + * An option that expects a floating-point value + */ + public static class DoubleOption extends Option { + public DoubleOption( char shortForm, String longForm ) { + super(shortForm, longForm, true); + } + public DoubleOption( String longForm ) { + super(longForm, true); + } + protected Object parseValue( String arg, Locale locale ) + throws IllegalOptionValueException { + try { + NumberFormat format = NumberFormat.getNumberInstance(locale); + Number num = (Number)format.parse(arg); + return new Double(num.doubleValue()); + } + catch (ParseException e) { + throw new IllegalOptionValueException(this, arg); + } + } + } + + /** + * An option that expects a string value + */ + public static class StringOption extends Option { + public StringOption( char shortForm, String longForm ) { + super(shortForm, longForm, true); + } + public StringOption( String longForm ) { + super(longForm, true); + } + protected Object parseValue( String arg, Locale locale ) { + return arg; + } + } + } + + /** + * Add the specified Option to the list of accepted options + */ + public final Option addOption( Option opt ) { + if ( opt.shortForm() != null ) + this.options.put("-" + opt.shortForm(), opt); + this.options.put("--" + opt.longForm(), opt); + return opt; + } + + /** + * Convenience method for adding a string option. + * @return the new Option + */ + public final Option addStringOption( char shortForm, String longForm ) { + return addOption(new Option.StringOption(shortForm, longForm)); + } + + /** + * Convenience method for adding a string option. + * @return the new Option + */ + public final Option addStringOption( String longForm ) { + return addOption(new Option.StringOption(longForm)); + } + + /** + * Convenience method for adding an integer option. + * @return the new Option + */ + public final Option addIntegerOption( char shortForm, String longForm ) { + return addOption(new Option.IntegerOption(shortForm, longForm)); + } + + /** + * Convenience method for adding an integer option. + * @return the new Option + */ + public final Option addIntegerOption( String longForm ) { + return addOption(new Option.IntegerOption(longForm)); + } + + /** + * Convenience method for adding a long integer option. + * @return the new Option + */ + public final Option addLongOption( char shortForm, String longForm ) { + return addOption(new Option.LongOption(shortForm, longForm)); + } + + /** + * Convenience method for adding a long integer option. + * @return the new Option + */ + public final Option addLongOption( String longForm ) { + return addOption(new Option.LongOption(longForm)); + } + + /** + * Convenience method for adding a double option. + * @return the new Option + */ + public final Option addDoubleOption( char shortForm, String longForm ) { + return addOption(new Option.DoubleOption(shortForm, longForm)); + } + + /** + * Convenience method for adding a double option. + * @return the new Option + */ + public final Option addDoubleOption( String longForm ) { + return addOption(new Option.DoubleOption(longForm)); + } + + /** + * Convenience method for adding a boolean option. + * @return the new Option + */ + public final Option addBooleanOption( char shortForm, String longForm ) { + return addOption(new Option.BooleanOption(shortForm, longForm)); + } + + /** + * Convenience method for adding a boolean option. + * @return the new Option + */ + public final Option addBooleanOption( String longForm ) { + return addOption(new Option.BooleanOption(longForm)); + } + + /** + * Equivalent to {@link #getOptionValue(Option, Object) getOptionValue(o, + * null)}. + */ + public final Object getOptionValue( Option o ) { + return getOptionValue(o, null); + } + + + /** + * @return the parsed value of the given Option, or the given default 'def' + * if the option was not set + */ + public final Object getOptionValue( Option o, Object def ) { + Vector v = (Vector)values.get(o.longForm()); + + if (v == null) { + return def; + } + else if (v.isEmpty()) { + return null; + } + else { + Object result = v.elementAt(0); + v.removeElementAt(0); + return result; + } + } + + + /** + * @return A Vector giving the parsed values of all the occurrences of the + * given Option, or an empty Vector if the option was not set. + */ + public final Vector getOptionValues( Option option ) { + Vector result = new Vector(); + + while (true) { + Object o = getOptionValue(option, null); + + if (o == null) { + return result; + } + else { + result.addElement((String)o); + } + } + } + + + /** + * @return the non-option arguments + */ + public final String[] getRemainingArgs() { + return this.remainingArgs; + } + + /** + * Extract the options and non-option arguments from the given + * list of command-line arguments. The default locale is used for + * parsing options whose values might be locale-specific. + */ + public final void parse( String[] argv ) + throws IllegalOptionValueException, UnknownOptionException { + + // It would be best if this method only threw OptionException, but for + // backwards compatibility with old user code we throw the two + // exceptions above instead. + + parse(argv, Locale.getDefault()); + } + + /** + * Extract the options and non-option arguments from the given + * list of command-line arguments. The specified locale is used for + * parsing options whose values might be locale-specific. + */ + public final void parse( String[] argv, Locale locale ) + throws IllegalOptionValueException, UnknownOptionException { + + // It would be best if this method only threw OptionException, but for + // backwards compatibility with old user code we throw the two + // exceptions above instead. + + Vector otherArgs = new Vector(); + int position = 0; + this.values = new Hashtable(10); + while ( position < argv.length ) { + String curArg = argv[position]; + if ( curArg.startsWith("-") ) { + if ( curArg.equals("--") ) { // end of options + position += 1; + break; + } + String valueArg = null; + if ( curArg.startsWith("--") ) { // handle --arg=value + int equalsPos = curArg.indexOf("="); + if ( equalsPos != -1 ) { + valueArg = curArg.substring(equalsPos+1); + curArg = curArg.substring(0,equalsPos); + } + } else if(curArg.length() > 2) { // handle -abcd + for(int i=1; i + + 1.1 + http://htmlcompressor.googlecode.com/taglib/compressor + + Compresses HTML content within tags. + html + com.googlecode.htmlcompressor.taglib.HtmlCompressorTag + JSP + + enabled + false + true + + + removeComments + false + true + + + removeMultiSpaces + false + true + + + removeIntertagSpaces + false + true + + + removeQuotes + false + true + + + compressJavaScript + false + true + + + compressCss + false + true + + + yuiJsNoMunge + false + true + + + yuiJsPreserveAllSemiColons + false + true + + + yuiJsDisableOptimizations + false + true + + + yuiJsLineBreak + false + true + + + yuiCssLineBreak + false + true + + + jsCompressor + false + true + + + closureOptLevel + false + true + + + simpleDoctype + false + true + + + removeScriptAttributes + false + true + + + removeStyleAttributes + false + true + + + removeLinkAttributes + false + true + + + removeFormAttributes + false + true + + + removeInputAttributes + false + true + + + simpleBooleanAttributes + false + true + + + removeJavaScriptProtocol + false + true + + + removeHttpProtocol + false + true + + + removeHttpsProtocol + false + true + + + preserveLineBreaks + false + true + + + + Compresses XML content within tags. + xml + com.googlecode.htmlcompressor.taglib.XmlCompressorTag + JSP + + enabled + false + true + + + removeComments + false + true + + + removeIntertagSpaces + false + true + + + + Compresses JavaScript content within tags. + js + com.googlecode.htmlcompressor.taglib.JavaScriptCompressorTag + JSP + + enabled + false + true + + + yuiJsNoMunge + false + true + + + yuiJsPreserveAllSemiColons + false + true + + + yuiJsDisableOptimizations + false + true + + + yuiJsLineBreak + false + true + + + jsCompressor + false + true + + + closureOptLevel + false + true + + + + Compresses CSS content within tags. + css + com.googlecode.htmlcompressor.taglib.CssCompressorTag + JSP + + enabled + false + true + + + yuiCssLineBreak + false + true + + + \ No newline at end of file diff --git a/src/test/java/com/googlecode/htmlcompressor/compressor/HtmlCompressorTest.java b/src/test/java/com/googlecode/htmlcompressor/compressor/HtmlCompressorTest.java new file mode 100644 index 0000000..684f86d --- /dev/null +++ b/src/test/java/com/googlecode/htmlcompressor/compressor/HtmlCompressorTest.java @@ -0,0 +1,330 @@ +package com.googlecode.htmlcompressor.compressor; + +import static org.junit.Assert.assertEquals; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.google.javascript.jscomp.CompilationLevel; + +public class HtmlCompressorTest { + + private static final String resPath = "./src/test/resources/html/"; + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + @Test + public void testEnabled() throws Exception { + String source = readResource("testEnabled.html"); + String result = readResource("testEnabledResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setEnabled(false); + + assertEquals(result, compressor.compress(source)); + + } + + @Test + public void testRemoveSpacesInsideTags() throws Exception { + String source = readResource("testRemoveSpacesInsideTags.html"); + String result = readResource("testRemoveSpacesInsideTagsResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveMultiSpaces(false); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveComments() throws Exception { + String source = readResource("testRemoveComments.html"); + String result = readResource("testRemoveCommentsResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveComments(true); + compressor.setRemoveIntertagSpaces(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveQuotes() throws Exception { + String source = readResource("testRemoveQuotes.html"); + String result = readResource("testRemoveQuotesResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveQuotes(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveMultiSpaces() throws Exception { + String source = readResource("testRemoveMultiSpaces.html"); + String result = readResource("testRemoveMultiSpacesResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveMultiSpaces(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveIntertagSpaces() throws Exception { + String source = readResource("testRemoveIntertagSpaces.html"); + String result = readResource("testRemoveIntertagSpacesResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveIntertagSpaces(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testPreservePatterns() throws Exception { + String source = readResource("testPreservePatterns.html"); + String result = readResource("testPreservePatternsResult.html"); + + List preservePatterns = new ArrayList(); + preservePatterns.add(HtmlCompressor.PHP_TAG_PATTERN); // blocks + preservePatterns.add(HtmlCompressor.SERVER_SCRIPT_TAG_PATTERN); //<% ... %> blocks + preservePatterns.add(HtmlCompressor.SERVER_SIDE_INCLUDE_PATTERN); // blocks + preservePatterns.add(Pattern.compile("", Pattern.DOTALL | Pattern.CASE_INSENSITIVE)); // tags + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setPreservePatterns(preservePatterns); + compressor.setRemoveComments(true); + compressor.setRemoveIntertagSpaces(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testCompressJavaScriptYui() throws Exception { + String source = readResource("testCompressJavaScript.html"); + String result = readResource("testCompressJavaScriptYuiResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setCompressJavaScript(true); + compressor.setRemoveIntertagSpaces(true); + + assertEquals(result, compressor.compress(source)); + } + @Test + public void testCompressJavaScriptClosure() throws Exception { + String source = readResource("testCompressJavaScript.html"); + String result = readResource("testCompressJavaScriptClosureResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setCompressJavaScript(true); + compressor.setJavaScriptCompressor(new ClosureJavaScriptCompressor(CompilationLevel.ADVANCED_OPTIMIZATIONS)); + compressor.setRemoveIntertagSpaces(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testCompressCss() throws Exception { + String source = readResource("testCompressCss.html"); + String result = readResource("testCompressCssResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setCompressCss(true); + compressor.setRemoveIntertagSpaces(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testCompress() throws Exception { + String source = readResource("testCompress.html"); + String result = readResource("testCompressResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testSimpleDoctype() throws Exception { + String source = readResource("testSimpleDoctype.html"); + String result = readResource("testSimpleDoctypeResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setSimpleDoctype(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveScriptAttributes() throws Exception { + String source = readResource("testRemoveScriptAttributes.html"); + String result = readResource("testRemoveScriptAttributesResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveScriptAttributes(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveStyleAttributes() throws Exception { + String source = readResource("testRemoveStyleAttributes.html"); + String result = readResource("testRemoveStyleAttributesResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveStyleAttributes(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveLinkAttributes() throws Exception { + String source = readResource("testRemoveLinkAttributes.html"); + String result = readResource("testRemoveLinkAttributesResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveLinkAttributes(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveFormAttributes() throws Exception { + String source = readResource("testRemoveFormAttributes.html"); + String result = readResource("testRemoveFormAttributesResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveFormAttributes(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveInputAttributes() throws Exception { + String source = readResource("testRemoveInputAttributes.html"); + String result = readResource("testRemoveInputAttributesResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveInputAttributes(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveJavaScriptProtocol() throws Exception { + String source = readResource("testRemoveJavaScriptProtocol.html"); + String result = readResource("testRemoveJavaScriptProtocolResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveJavaScriptProtocol(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveHttpProtocol() throws Exception { + String source = readResource("testRemoveHttpProtocol.html"); + String result = readResource("testRemoveHttpProtocolResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveHttpProtocol(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveHttpsProtocol() throws Exception { + String source = readResource("testRemoveHttpsProtocol.html"); + String result = readResource("testRemoveHttpsProtocolResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveHttpsProtocol(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testPreserveLineBreaks() throws Exception { + String source = readResource("testPreserveLineBreaks.html"); + String result = readResource("testPreserveLineBreaksResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setPreserveLineBreaks(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testSurroundingSpaces() throws Exception { + String source = readResource("testSurroundingSpaces.html"); + String result = readResource("testSurroundingSpacesResult.html"); + + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveIntertagSpaces(true); + compressor.setRemoveSurroundingSpaces("p,br"); + + assertEquals(result, compressor.compress(source)); + } + + private String readResource(String filename) { + + StringBuilder builder = new StringBuilder(); + try { + FileInputStream stream = new FileInputStream(new File(resPath + filename)); + try { + Reader reader = new BufferedReader(new InputStreamReader(stream)); + + char[] buffer = new char[8192]; + int read; + while ((read = reader.read(buffer, 0, buffer.length)) > 0) { + builder.append(buffer, 0, read); + } + + } finally { + stream.close(); + } + + } catch (IOException e) { + e.printStackTrace(); + } + + return builder.toString(); + + } + + private void writeResource(String filename, String content) { + try { + Writer output = new BufferedWriter(new FileWriter(new File(resPath + filename))); + try { + output.write(content); + } finally { + output.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/test/java/com/googlecode/htmlcompressor/compressor/XmlCompressorTest.java b/src/test/java/com/googlecode/htmlcompressor/compressor/XmlCompressorTest.java new file mode 100644 index 0000000..489cea1 --- /dev/null +++ b/src/test/java/com/googlecode/htmlcompressor/compressor/XmlCompressorTest.java @@ -0,0 +1,113 @@ +package com.googlecode.htmlcompressor.compressor; + +import static org.junit.Assert.*; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.Writer; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class XmlCompressorTest { + + private static final String resPath = "./src/test/resources/xml/"; + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testCompress() throws Exception { + String source = readResource("testCompress.xml"); + String result = readResource("testCompressResult.xml"); + + XmlCompressor compressor = new XmlCompressor(); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testEnabled() throws Exception { + String source = readResource("testEnabled.xml"); + String result = readResource("testEnabledResult.xml"); + + XmlCompressor compressor = new XmlCompressor(); + compressor.setEnabled(false); + + assertEquals(result, compressor.compress(source)); + + } + + @Test + public void testRemoveComments() throws Exception { + String source = readResource("testRemoveComments.xml"); + String result = readResource("testRemoveCommentsResult.xml"); + + XmlCompressor compressor = new XmlCompressor(); + compressor.setRemoveComments(true); + + assertEquals(result, compressor.compress(source)); + } + + @Test + public void testRemoveIntertagSpaces() throws Exception { + String source = readResource("testRemoveIntertagSpaces.xml"); + String result = readResource("testRemoveIntertagSpacesResult.xml"); + + XmlCompressor compressor = new XmlCompressor(); + compressor.setRemoveIntertagSpaces(true); + + assertEquals(result, compressor.compress(source)); + } + + private String readResource(String filename) { + + StringBuilder builder = new StringBuilder(); + try { + FileInputStream stream = new FileInputStream(new File(resPath + filename)); + try { + Reader reader = new BufferedReader(new InputStreamReader(stream)); + + char[] buffer = new char[8192]; + int read; + while ((read = reader.read(buffer, 0, buffer.length)) > 0) { + builder.append(buffer, 0, read); + } + + } finally { + stream.close(); + } + + } catch (IOException e) { + e.printStackTrace(); + } + + return builder.toString(); + + } + + private void writeResource(String filename, String content) { + try { + Writer output = new BufferedWriter(new FileWriter(new File(resPath + filename))); + try { + output.write(content); + } finally { + output.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/test/resources/html/testCompress.html b/src/test/resources/html/testCompress.html new file mode 100644 index 0000000..9c9f344 --- /dev/null +++ b/src/test/resources/html/testCompress.html @@ -0,0 +1,10 @@ + + +

           
+ + +
               
+ + + + \ No newline at end of file diff --git a/src/test/resources/html/testCompressCss.html b/src/test/resources/html/testCompressCss.html new file mode 100644 index 0000000..ecbc72b --- /dev/null +++ b/src/test/resources/html/testCompressCss.html @@ -0,0 +1,11 @@ + + +
+	
+
\ No newline at end of file diff --git a/src/test/resources/html/testCompressCssResult.html b/src/test/resources/html/testCompressCssResult.html new file mode 100644 index 0000000..ae54716 --- /dev/null +++ b/src/test/resources/html/testCompressCssResult.html @@ -0,0 +1,6 @@ +
+	
+
\ No newline at end of file diff --git a/src/test/resources/html/testCompressJavaScript.html b/src/test/resources/html/testCompressJavaScript.html new file mode 100644 index 0000000..9993f1b --- /dev/null +++ b/src/test/resources/html/testCompressJavaScript.html @@ -0,0 +1,24 @@ + + + + +
+	
+
+ + + \ No newline at end of file diff --git a/src/test/resources/html/testCompressJavaScriptClosureResult.html b/src/test/resources/html/testCompressJavaScriptClosureResult.html new file mode 100644 index 0000000..dc889fd --- /dev/null +++ b/src/test/resources/html/testCompressJavaScriptClosureResult.html @@ -0,0 +1,7 @@ +
+	
+
\ No newline at end of file diff --git a/src/test/resources/html/testCompressJavaScriptYuiResult.html b/src/test/resources/html/testCompressJavaScriptYuiResult.html new file mode 100644 index 0000000..d248f97 --- /dev/null +++ b/src/test/resources/html/testCompressJavaScriptYuiResult.html @@ -0,0 +1,7 @@ +
+	
+
\ No newline at end of file diff --git a/src/test/resources/html/testCompressResult.html b/src/test/resources/html/testCompressResult.html new file mode 100644 index 0000000..d8e5308 --- /dev/null +++ b/src/test/resources/html/testCompressResult.html @@ -0,0 +1 @@ +
           
               
\ No newline at end of file diff --git a/src/test/resources/html/testEnabled.html b/src/test/resources/html/testEnabled.html new file mode 100644 index 0000000..703f04e --- /dev/null +++ b/src/test/resources/html/testEnabled.html @@ -0,0 +1 @@ +html html \ No newline at end of file diff --git a/src/test/resources/html/testEnabledResult.html b/src/test/resources/html/testEnabledResult.html new file mode 100644 index 0000000..703f04e --- /dev/null +++ b/src/test/resources/html/testEnabledResult.html @@ -0,0 +1 @@ +html html \ No newline at end of file diff --git a/src/test/resources/html/testPreserveLineBreaks.html b/src/test/resources/html/testPreserveLineBreaks.html new file mode 100644 index 0000000..01a7250 --- /dev/null +++ b/src/test/resources/html/testPreserveLineBreaks.html @@ -0,0 +1,11 @@ +
+ + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/html/testPreserveLineBreaksResult.html b/src/test/resources/html/testPreserveLineBreaksResult.html new file mode 100644 index 0000000..eac0e8b --- /dev/null +++ b/src/test/resources/html/testPreserveLineBreaksResult.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/test/resources/html/testPreservePatterns.html b/src/test/resources/html/testPreservePatterns.html new file mode 100644 index 0000000..d74e874 --- /dev/null +++ b/src/test/resources/html/testPreservePatterns.html @@ -0,0 +1,7 @@ + + + ?> +<% %> + + + \ No newline at end of file diff --git a/src/test/resources/html/testPreservePatternsResult.html b/src/test/resources/html/testPreservePatternsResult.html new file mode 100644 index 0000000..1c5b776 --- /dev/null +++ b/src/test/resources/html/testPreservePatternsResult.html @@ -0,0 +1 @@ + ?><% %> \ No newline at end of file diff --git a/src/test/resources/html/testRemoveComments.html b/src/test/resources/html/testRemoveComments.html new file mode 100644 index 0000000..1e4f8d8 --- /dev/null +++ b/src/test/resources/html/testRemoveComments.html @@ -0,0 +1,17 @@ + + +
 aaa  bbb 
+ + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveCommentsResult.html b/src/test/resources/html/testRemoveCommentsResult.html new file mode 100644 index 0000000..3ba4ad1 --- /dev/null +++ b/src/test/resources/html/testRemoveCommentsResult.html @@ -0,0 +1,4 @@ +
 aaa  bbb 
\ No newline at end of file diff --git a/src/test/resources/html/testRemoveFormAttributes.html b/src/test/resources/html/testRemoveFormAttributes.html new file mode 100644 index 0000000..6c25789 --- /dev/null +++ b/src/test/resources/html/testRemoveFormAttributes.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/src/test/resources/html/testRemoveFormAttributesResult.html b/src/test/resources/html/testRemoveFormAttributesResult.html new file mode 100644 index 0000000..d2daefa --- /dev/null +++ b/src/test/resources/html/testRemoveFormAttributesResult.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveHttpProtocol.html b/src/test/resources/html/testRemoveHttpProtocol.html new file mode 100644 index 0000000..8d8f6a1 --- /dev/null +++ b/src/test/resources/html/testRemoveHttpProtocol.html @@ -0,0 +1 @@ +http://leave \ No newline at end of file diff --git a/src/test/resources/html/testRemoveHttpProtocolResult.html b/src/test/resources/html/testRemoveHttpProtocolResult.html new file mode 100644 index 0000000..b926981 --- /dev/null +++ b/src/test/resources/html/testRemoveHttpProtocolResult.html @@ -0,0 +1 @@ +http://leave \ No newline at end of file diff --git a/src/test/resources/html/testRemoveHttpsProtocol.html b/src/test/resources/html/testRemoveHttpsProtocol.html new file mode 100644 index 0000000..23c0522 --- /dev/null +++ b/src/test/resources/html/testRemoveHttpsProtocol.html @@ -0,0 +1 @@ +http://leave \ No newline at end of file diff --git a/src/test/resources/html/testRemoveHttpsProtocolResult.html b/src/test/resources/html/testRemoveHttpsProtocolResult.html new file mode 100644 index 0000000..83dd6b3 --- /dev/null +++ b/src/test/resources/html/testRemoveHttpsProtocolResult.html @@ -0,0 +1 @@ +http://leave \ No newline at end of file diff --git a/src/test/resources/html/testRemoveInputAttributes.html b/src/test/resources/html/testRemoveInputAttributes.html new file mode 100644 index 0000000..c806563 --- /dev/null +++ b/src/test/resources/html/testRemoveInputAttributes.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveInputAttributesResult.html b/src/test/resources/html/testRemoveInputAttributesResult.html new file mode 100644 index 0000000..435fe54 --- /dev/null +++ b/src/test/resources/html/testRemoveInputAttributesResult.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveIntertagSpaces.html b/src/test/resources/html/testRemoveIntertagSpaces.html new file mode 100644 index 0000000..5586f48 --- /dev/null +++ b/src/test/resources/html/testRemoveIntertagSpaces.html @@ -0,0 +1,5 @@ + + +
           
+ + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveIntertagSpacesResult.html b/src/test/resources/html/testRemoveIntertagSpacesResult.html new file mode 100644 index 0000000..28c5629 --- /dev/null +++ b/src/test/resources/html/testRemoveIntertagSpacesResult.html @@ -0,0 +1 @@ +
           
\ No newline at end of file diff --git a/src/test/resources/html/testRemoveJavaScriptProtocol.html b/src/test/resources/html/testRemoveJavaScriptProtocol.html new file mode 100644 index 0000000..293cdec --- /dev/null +++ b/src/test/resources/html/testRemoveJavaScriptProtocol.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/src/test/resources/html/testRemoveJavaScriptProtocolResult.html b/src/test/resources/html/testRemoveJavaScriptProtocolResult.html new file mode 100644 index 0000000..bb1ed16 --- /dev/null +++ b/src/test/resources/html/testRemoveJavaScriptProtocolResult.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveLinkAttributes.html b/src/test/resources/html/testRemoveLinkAttributes.html new file mode 100644 index 0000000..d70588a --- /dev/null +++ b/src/test/resources/html/testRemoveLinkAttributes.html @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveLinkAttributesResult.html b/src/test/resources/html/testRemoveLinkAttributesResult.html new file mode 100644 index 0000000..6684a3a --- /dev/null +++ b/src/test/resources/html/testRemoveLinkAttributesResult.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveMultiSpaces.html b/src/test/resources/html/testRemoveMultiSpaces.html new file mode 100644 index 0000000..66211af --- /dev/null +++ b/src/test/resources/html/testRemoveMultiSpaces.html @@ -0,0 +1 @@ +
           
\ No newline at end of file diff --git a/src/test/resources/html/testRemoveMultiSpacesResult.html b/src/test/resources/html/testRemoveMultiSpacesResult.html new file mode 100644 index 0000000..66211af --- /dev/null +++ b/src/test/resources/html/testRemoveMultiSpacesResult.html @@ -0,0 +1 @@ +
           
\ No newline at end of file diff --git a/src/test/resources/html/testRemoveQuotes.html b/src/test/resources/html/testRemoveQuotes.html new file mode 100644 index 0000000..1f28a89 --- /dev/null +++ b/src/test/resources/html/testRemoveQuotes.html @@ -0,0 +1,7 @@ +
+ + + + + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveQuotesResult.html b/src/test/resources/html/testRemoveQuotesResult.html new file mode 100644 index 0000000..ef91687 --- /dev/null +++ b/src/test/resources/html/testRemoveQuotesResult.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveScriptAttributes.html b/src/test/resources/html/testRemoveScriptAttributes.html new file mode 100644 index 0000000..e98e91c --- /dev/null +++ b/src/test/resources/html/testRemoveScriptAttributes.html @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveScriptAttributesResult.html b/src/test/resources/html/testRemoveScriptAttributesResult.html new file mode 100644 index 0000000..dfe19bf --- /dev/null +++ b/src/test/resources/html/testRemoveScriptAttributesResult.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveSpacesInsideTags.html b/src/test/resources/html/testRemoveSpacesInsideTags.html new file mode 100644 index 0000000..a513c93 --- /dev/null +++ b/src/test/resources/html/testRemoveSpacesInsideTags.html @@ -0,0 +1 @@ + qwe = eee
\ No newline at end of file diff --git a/src/test/resources/html/testRemoveSpacesInsideTagsResult.html b/src/test/resources/html/testRemoveSpacesInsideTagsResult.html new file mode 100644 index 0000000..6ed5581 --- /dev/null +++ b/src/test/resources/html/testRemoveSpacesInsideTagsResult.html @@ -0,0 +1 @@ +
qwe = eee
\ No newline at end of file diff --git a/src/test/resources/html/testRemoveStyleAttributes.html b/src/test/resources/html/testRemoveStyleAttributes.html new file mode 100644 index 0000000..4513b50 --- /dev/null +++ b/src/test/resources/html/testRemoveStyleAttributes.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/test/resources/html/testRemoveStyleAttributesResult.html b/src/test/resources/html/testRemoveStyleAttributesResult.html new file mode 100644 index 0000000..6db551b --- /dev/null +++ b/src/test/resources/html/testRemoveStyleAttributesResult.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/html/testSimpleBooleanAttributes.html b/src/test/resources/html/testSimpleBooleanAttributes.html new file mode 100644 index 0000000..3fcf120 --- /dev/null +++ b/src/test/resources/html/testSimpleBooleanAttributes.html @@ -0,0 +1 @@ + checked="checked" \ No newline at end of file diff --git a/src/test/resources/html/testSimpleBooleanAttributesResult.html b/src/test/resources/html/testSimpleBooleanAttributesResult.html new file mode 100644 index 0000000..5c72488 --- /dev/null +++ b/src/test/resources/html/testSimpleBooleanAttributesResult.html @@ -0,0 +1 @@ + checked="checked" \ No newline at end of file diff --git a/src/test/resources/html/testSimpleDoctype.html b/src/test/resources/html/testSimpleDoctype.html new file mode 100644 index 0000000..a4cbe2b --- /dev/null +++ b/src/test/resources/html/testSimpleDoctype.html @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/src/test/resources/html/testSimpleDoctypeResult.html b/src/test/resources/html/testSimpleDoctypeResult.html new file mode 100644 index 0000000..763b073 --- /dev/null +++ b/src/test/resources/html/testSimpleDoctypeResult.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/html/testSurroundingSpaces.html b/src/test/resources/html/testSurroundingSpaces.html new file mode 100644 index 0000000..be719e4 --- /dev/null +++ b/src/test/resources/html/testSurroundingSpaces.html @@ -0,0 +1 @@ +aaa

bbbb
ccccccc

ddddd eeeeeeee \ No newline at end of file diff --git a/src/test/resources/html/testSurroundingSpacesResult.html b/src/test/resources/html/testSurroundingSpacesResult.html new file mode 100644 index 0000000..b727f27 --- /dev/null +++ b/src/test/resources/html/testSurroundingSpacesResult.html @@ -0,0 +1 @@ +aaa

bbbb
ccccccc

ddddd eeeeeeee \ No newline at end of file diff --git a/src/test/resources/xml/testCompress.xml b/src/test/resources/xml/testCompress.xml new file mode 100644 index 0000000..4e57685 --- /dev/null +++ b/src/test/resources/xml/testCompress.xml @@ -0,0 +1,11 @@ +
+ + + + ]]> + + + + + aaa bbbb diff --git a/src/test/resources/xml/testCompressResult.xml b/src/test/resources/xml/testCompressResult.xml new file mode 100644 index 0000000..700a72d --- /dev/null +++ b/src/test/resources/xml/testCompressResult.xml @@ -0,0 +1,5 @@ + + + ]]> + aaa bbbb \ No newline at end of file diff --git a/src/test/resources/xml/testEnabled.xml b/src/test/resources/xml/testEnabled.xml new file mode 100644 index 0000000..fa19210 --- /dev/null +++ b/src/test/resources/xml/testEnabled.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/xml/testEnabledResult.xml b/src/test/resources/xml/testEnabledResult.xml new file mode 100644 index 0000000..fa19210 --- /dev/null +++ b/src/test/resources/xml/testEnabledResult.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/xml/testRemoveComments.xml b/src/test/resources/xml/testRemoveComments.xml new file mode 100644 index 0000000..fe1d296 --- /dev/null +++ b/src/test/resources/xml/testRemoveComments.xml @@ -0,0 +1,5 @@ + + +]]> + diff --git a/src/test/resources/xml/testRemoveCommentsResult.xml b/src/test/resources/xml/testRemoveCommentsResult.xml new file mode 100644 index 0000000..be1ff06 --- /dev/null +++ b/src/test/resources/xml/testRemoveCommentsResult.xml @@ -0,0 +1,4 @@ + + +]]> \ No newline at end of file diff --git a/src/test/resources/xml/testRemoveIntertagSpaces.xml b/src/test/resources/xml/testRemoveIntertagSpaces.xml new file mode 100644 index 0000000..4e57685 --- /dev/null +++ b/src/test/resources/xml/testRemoveIntertagSpaces.xml @@ -0,0 +1,11 @@ + + + + + ]]> + + + + + aaa bbbb diff --git a/src/test/resources/xml/testRemoveIntertagSpacesResult.xml b/src/test/resources/xml/testRemoveIntertagSpacesResult.xml new file mode 100644 index 0000000..700a72d --- /dev/null +++ b/src/test/resources/xml/testRemoveIntertagSpacesResult.xml @@ -0,0 +1,5 @@ + + + ]]> + aaa bbbb \ No newline at end of file