## org.plovr
Class AbstractJsInput

    java.lang.Object
      org.plovr.AbstractJsInput

All Implemented Interfaces:
  SourceFile.Generator, JsInput

Direct Known Subclasses:
  LocalFileJsInput, ResourceJsInput

    public abstract class AbstractJsInput

extends Object
implements JsInput

`AbstractJsInput` provides the default logic for extracting `goog.provide()` and `goog.require()` information.

Author:
  bolinfest@gmail.com (Michael Bolin)

Nested Class Summary

Nested classes/interfaces inherited from interface org.plovr.JsInput
`JsInput.CodeWithEtag`

Field Summary
`protected List<String>` `provides`
`protected List<String>` `requires`

Method Summary
`protected String` `calculateEtagFor(String code)` Must return a stable ETag for the supplied code.
`abstract String` `getCode()`
`JsInput.CodeWithEtag` `getCodeWithEtag()` If `JsInput.supportsEtags()` returns `true`, then this returns the value returned by `JsInput.getCode()` along with an ETag; otherwise, it throws an `UnsupportedOperationException`.
`String` `getName()`
`List<String>` `getProvides()`
`List<String>` `getRequires()`
`String` `getTemplateCode()`
`protected boolean` `hasInputChanged()`
`boolean` `isSoyFile()`
`protected void` `processProvidesAndRequires()`
`boolean` `supportsEtags()` Whether this input can calculate a stable ETag value for itself.
`String` `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### provides

    protected List<String> provides

### requires

    protected List<String> requires

Method Detail

### getCode

    public abstract String getCode()

  Specified by:
    `getCode` in interface `SourceFile.Generator`
  Specified by:
    `getCode` in interface `JsInput`
  Returns:
    JavaScript code

### supportsEtags

    public boolean supportsEtags()

  Description copied from interface: `JsInput`
  Whether this input can calculate a stable ETag value for itself.

  Specified by:
    `supportsEtags` in interface `JsInput`
  See Also:
    `JsInput.getCodeWithEtag()`

### getCodeWithEtag

    public JsInput.CodeWithEtag getCodeWithEtag()

  Description copied from interface: `JsInput`
  If `JsInput.supportsEtags()` returns `true`, then this returns the value returned by `JsInput.getCode()` along with an ETag; otherwise, it throws an `UnsupportedOperationException`.

  This is generally used as a performance optimization to prevent plovr from going to disk twice: once to read the code for `JsInput.getCode()` and then again to read the code and calculate its ETag. This ensures that the code and ETag are produced atomically.

  Specified by:
    `getCodeWithEtag` in interface `JsInput`

### calculateEtagFor

    protected final String calculateEtagFor(String code)

  Must return a stable ETag for the supplied code. Note that for some JsInputs, such as Soy and CoffeeScript files, the ETag should be a function of the source code (the .soy or .coffee rather than the JS) as well as the options used to translate the source code to JS. For example, if a user loads a Soy file and an ETag is returned based on the content of the .soy, then the user modifies the Soy options in the plovr config and reloads, then the generated JS as well as the ETag must be different to reflect that change.

### getName

    public String getName()

  Specified by:
    `getName` in interface `JsInput`
  Returns:
    name of a `JsInput` must be unique among the other inputs included in a compilation so that warnings and errors can be reported appropriately.

### getProvides

    public List<String> getProvides()

  Specified by:
    `getProvides` in interface `JsInput`
  Returns:
    a list of the values passed to goog.provide() in this input

### getRequires

    public List<String> getRequires()

  Specified by:
    `getRequires` in interface `JsInput`
  Returns:
    a list of the values passed to goog.require() in this input

### hasInputChanged

    protected boolean hasInputChanged()

### isSoyFile

    public boolean isSoyFile()

  Specified by:
    `isSoyFile` in interface `JsInput`
  Returns:
    a boolean indicating whether this is a Soy file. If true, then `JsInput.getTemplateCode()` must return the original Soy content.

### getTemplateCode

    public String getTemplateCode()

  Specified by:
    `getTemplateCode` in interface `JsInput`
  Returns:
    the underlying template code if this is a Soy file

### processProvidesAndRequires

    protected void processProvidesAndRequires()

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`