com.googlecode.htmlcompressor.compressor

## Class YuiJavaScriptCompressor

- java.lang.Object
- - 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

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `YuiJavaScriptCompressor.DefaultErrorReporter` Default `ErrorReporter` implementation that uses `System.err` stream for error reporting.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `YuiJavaScriptCompressor()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `compress(String source)` The main method that compresses the given source and returns a compressed result.
    `org.mozilla.javascript.ErrorReporter` | `getErrorReporter()` Returns `ErrorReporter` used by YUI Compressor to log error messages during JavasSript compression.
    `int` | `getLineBreak()` Returns number of symbols per line Yahoo YUI Compressor will use during JavaScript compression.
    `boolean` | `isDisableOptimizations()` Returns `true` if Yahoo YUI Compressor will disable all the built-in micro optimizations during JavaScript compression.
    `boolean` | `isNoMunge()` Returns `true` if Yahoo YUI Compressor will only minify javascript without obfuscating local symbols.
    `boolean` | `isPreserveAllSemiColons()` Returns `true` if Yahoo YUI Compressor will preserve unnecessary semicolons during JavaScript compression.
    `void` | `setDisableOptimizations(boolean disableOptimizations)` Tells Yahoo YUI Compressor to disable all the built-in micro optimizations during JavaScript compression.
    `void` | `setErrorReporter(org.mozilla.javascript.ErrorReporter errorReporter)` Sets `ErrorReporter` that YUI Compressor will use for reporting errors during JavaScript compression.
    `void` | `setLineBreak(int lineBreak)` Tells Yahoo YUI Compressor to break lines after the specified number of symbols during JavaScript compression.
    `void` | `setNoMunge(boolean noMunge)` Tells Yahoo YUI Compressor to only minify javascript without obfuscating local symbols.
    `void` | `setPreserveAllSemiColons(boolean preserveAllSemiColons)` Tells Yahoo YUI Compressor to preserve unnecessary semicolons during JavaScript compression.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, 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–2020 Jeremy Landis. All rights reserved.