ModuleSource (rhino 1.7.14 API)

org.mozilla.javascript.commonjs.module.provider

## Class ModuleSource

- java.lang.Object
- - org.mozilla.javascript.commonjs.module.provider.ModuleSource

- All Implemented Interfaces:
    java.io.Serializable

      public class ModuleSource
      extends java.lang.Object
      implements java.io.Serializable

  Represents the source text of the module as a tuple of a reader, a URI, a security domain, and a cache validator.

  # Cache validators

  Validators are used by caches subclassed from `CachingModuleScriptProviderBase` to avoid repeated loading of unmodified resources as well as automatic reloading of modified resources. Such a validator can be any value that can be used to detect modification or non-modification of the resource that provided the source of the module. It can be as simple as a tuple of a URI or a file path, and a last-modified date, or an ETag (in case of HTTP). It is left to the implementation. It is also allowed to carry expiration information (i.e. in case of HTTP expiration header, or if a default expiration is used by the source provider to avoid too frequent lookup of the resource), and to short-circuit the validation in case the validator indicates the cached representation has not yet expired. All these are plainly recommendations; the validators are considered opaque and should only make sure to implement `Object.equals(Object)` as caches themselves can rely on it to compare them semantically. Also, it is advisable to have them be serializable.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ModuleSource(java.io.Reader reader, java.lang.Object securityDomain, java.net.URI uri, java.net.URI base, java.lang.Object validator)` Creates a new module source.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.net.URI` | `getBase()` Returns the base URI from which this module source was loaded, or null if it was loaded from an absolute URI.
    `java.io.Reader` | `getReader()` Returns the reader returning the source text of the module.
    `java.lang.Object` | `getSecurityDomain()` Returns the object representing the security domain for the module's source.
    `java.net.URI` | `getUri()` Returns the URI of the module source text.
    `java.lang.Object` | `getValidator()` Returns the validator that can be used for subsequent cache validation of the source text.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ModuleSource

          public ModuleSource(java.io.Reader reader,
                              java.lang.Object securityDomain,
                              java.net.URI uri,
                              java.net.URI base,
                              java.lang.Object validator)

      Creates a new module source.
      Parameters:
        `reader` - the reader returning the source text of the module.
        `securityDomain` - the object representing the security domain for the module's source (passed to Rhino script compiler).
        `uri` - the URI of the module's source text
        `validator` - a validator that can be used for subsequent cache validation of the source text.

  - ### Method Detail

    - #### getReader

          public java.io.Reader getReader()

      Returns the reader returning the source text of the module. Note that subsequent calls to this method return the same object, thus it is not possible to read the source twice.
      Returns:
        the reader returning the source text of the module.

    - #### getSecurityDomain

          public java.lang.Object getSecurityDomain()

      Returns the object representing the security domain for the module's source.
      Returns:
        the object representing the security domain for the module's source.

    - #### getUri

          public java.net.URI getUri()

      Returns the URI of the module source text.
      Returns:
        the URI of the module source text.

    - #### getBase

          public java.net.URI getBase()

      Returns the base URI from which this module source was loaded, or null if it was loaded from an absolute URI.
      Returns:
        the base URI, or null.

    - #### getValidator

          public java.lang.Object getValidator()

      Returns the validator that can be used for subsequent cache validation of the source text.
      Returns:
        the validator that can be used for subsequent cache validation of the source text.