Package com.google.gwt.core.ext

## Class DelegatingGeneratorContext

- java.lang.Object
- - com.google.gwt.core.ext.DelegatingGeneratorContext

- All Implemented Interfaces:
    `GeneratorContext`
  Direct Known Subclasses:
    `NonIncrementalGeneratorContext`

      public abstract class DelegatingGeneratorContext
      extends java.lang.Object
      implements GeneratorContext

  An abstract generator context class which delegates all methods to a provided baseContext. Implementing classes can selectively override individual methods.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DelegatingGeneratorContext​(GeneratorContext baseContext)` | Get a new instance wrapped from a base `GeneratorContext` implementation.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `checkRebindRuleAvailable​(java.lang.String sourceTypeName)` | Checks whether a rebind rule is available for a given sourceTypeName, such as can appear in a replace-with or generate-with rule.
    `void` | `commit​(TreeLogger logger, java.io.PrintWriter pw)` | Commits source generation begun with `GeneratorContext.tryCreate(TreeLogger, String, String)`.
    `void` | `commitArtifact​(TreeLogger logger, Artifact<?> artifact)` | Add an Artifact to the `ArtifactSet` that will be presented to the `Linker` chain at the end of the compilation cycle.
    `GeneratedResource` | `commitResource​(TreeLogger logger, java.io.OutputStream os)` | Commits resource generation begun with `GeneratorContext.tryCreateResource(TreeLogger, String)`.
    `CachedGeneratorResult` | `getCachedGeneratorResult()` | Get the cached rebind result that has been provided to the context, if available.
    `PropertyOracle` | `getPropertyOracle()` | Gets the property oracle for the current generator context.
    `com.google.gwt.dev.resource.ResourceOracle` | `getResourcesOracle()` | Returns a resource oracle containing all resources that are mapped into the module's source (or super-source) paths.
    `TypeOracle` | `getTypeOracle()` | Gets the type oracle for the current generator context.
    `boolean` | `isGeneratorResultCachingEnabled()` | Check whether generator result caching is currently enabled.
    `boolean` | `isProdMode()` | Returns true if generators are being run to produce code for a production compile.
    `java.io.PrintWriter` | `tryCreate​(TreeLogger logger, java.lang.String packageName, java.lang.String simpleName)` | Attempts to get a `PrintWriter` so that the caller can generate the source code for the named type.
    `java.io.OutputStream` | `tryCreateResource​(TreeLogger logger, java.lang.String partialPath)` | Attempts to get an `OutputStream` so that the caller can write file contents into the named file underneath the compilation output directory.
    `boolean` | `tryReuseTypeFromCache​(java.lang.String typeName)` | Mark a type to be reused from the generator result cache, if available.

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

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

- - ### Constructor Detail

    - #### DelegatingGeneratorContext

          public DelegatingGeneratorContext​(GeneratorContext baseContext)

      Get a new instance wrapped from a base `GeneratorContext` implementation.

  - ### Method Detail

    - #### checkRebindRuleAvailable

          public boolean checkRebindRuleAvailable​(java.lang.String sourceTypeName)

      Description copied from interface: `GeneratorContext`
      Checks whether a rebind rule is available for a given sourceTypeName, such as can appear in a replace-with or generate-with rule.
      Specified by:
        `checkRebindRuleAvailable` in interface `GeneratorContext`
      Parameters:
        `sourceTypeName` - the name of a type to check for rebind rule availability.
      Returns:
        true if a rebind rule is available

    - #### commit

          public void commit​(TreeLogger logger,
                             java.io.PrintWriter pw)

      Description copied from interface: `GeneratorContext`
      Commits source generation begun with `GeneratorContext.tryCreate(TreeLogger, String, String)`.
      Specified by:
        `commit` in interface `GeneratorContext`

    - #### commitArtifact

          public void commitArtifact​(TreeLogger logger,
                                     Artifact<?> artifact)
                              throws UnableToCompleteException

      Description copied from interface: `GeneratorContext`
      Add an Artifact to the `ArtifactSet` that will be presented to the `Linker` chain at the end of the compilation cycle. Custom sub-classes of Artifact can be used to write cooperating Generator and Linker combinations. This method is semantically equivalent to calling `ArtifactSet.replace(Artifact)` if an equivalent Artifact had previously been committed.
      Specified by:
        `commitArtifact` in interface `GeneratorContext`
      Parameters:
        `logger` - a logger; normally the logger passed into the currently invoked generator or a branch thereof
        `artifact` - the Artifact to provide to the Linker chain.
      Throws:
        `UnableToCompleteException`

    - #### commitResource

          public GeneratedResource commitResource​(TreeLogger logger,
                                                  java.io.OutputStream os)
                                           throws UnableToCompleteException

      Description copied from interface: `GeneratorContext`
      Commits resource generation begun with `GeneratorContext.tryCreateResource(TreeLogger, String)`.
      Specified by:
        `commitResource` in interface `GeneratorContext`
      Returns:
        the GeneratedResource that was created as a result of committing the OutputStream.
      Throws:
        `UnableToCompleteException` - if the resource cannot be written to disk, if the specified stream is unknown, or if the stream has already been committed

    - #### getCachedGeneratorResult

          public CachedGeneratorResult getCachedGeneratorResult()

      Description copied from interface: `GeneratorContext`
      Get the cached rebind result that has been provided to the context, if available. The provided result will be the most recent previously generated result for the currently active rebind rule and requested type name.
      Specified by:
        `getCachedGeneratorResult` in interface `GeneratorContext`
      Returns:
        A `CachedGeneratorResult` object, if one has been provided to the context. Null is returned if there is no previous result available.

    - #### getPropertyOracle

          public PropertyOracle getPropertyOracle()

      Description copied from interface: `GeneratorContext`
      Gets the property oracle for the current generator context. Generators can use the property oracle to query deferred binding properties.
      Specified by:
        `getPropertyOracle` in interface `GeneratorContext`

    - #### getResourcesOracle

          public com.google.gwt.dev.resource.ResourceOracle getResourcesOracle()

      Description copied from interface: `GeneratorContext`
      Returns a resource oracle containing all resources that are mapped into the module's source (or super-source) paths. Conceptually, this resource oracle exposes resources which are "siblings" to GWT-compatible Java classes. For example, if the module includes `com.google.gwt.core.client` as a source package, then a resource at `com/google/gwt/core/client/Foo.properties` would be exposed by this resource oracle.
      Specified by:
        `getResourcesOracle` in interface `GeneratorContext`

    - #### getTypeOracle

          public TypeOracle getTypeOracle()

      Description copied from interface: `GeneratorContext`
      Gets the type oracle for the current generator context. Generators can use the type oracle to ask questions about the entire translatable code base.
      Specified by:
        `getTypeOracle` in interface `GeneratorContext`
      Returns:
        a TypeOracle over all the relevant translatable compilation units in the source path

    - #### isGeneratorResultCachingEnabled

          public boolean isGeneratorResultCachingEnabled()

      Description copied from interface: `GeneratorContext`
      Check whether generator result caching is currently enabled.
      Specified by:
        `isGeneratorResultCachingEnabled` in interface `GeneratorContext`

    - #### isProdMode

          public boolean isProdMode()

      Description copied from interface: `GeneratorContext`
      Returns true if generators are being run to produce code for a production compile. Returns false for dev mode. Generators can use this information to produce code optimized for the target.
      Specified by:
        `isProdMode` in interface `GeneratorContext`

    - #### tryCreate

          public java.io.PrintWriter tryCreate​(TreeLogger logger,
                                               java.lang.String packageName,
                                               java.lang.String simpleName)

      Description copied from interface: `GeneratorContext`
      Attempts to get a `PrintWriter` so that the caller can generate the source code for the named type. If the named types already exists, `null` is returned to indicate that no work needs to be done. The file is not committed until `GeneratorContext.commit(TreeLogger, PrintWriter)` is called.
      Specified by:
        `tryCreate` in interface `GeneratorContext`
      Parameters:
        `logger` - a logger; normally the logger passed into the currently invoked generator, or a branch thereof
        `packageName` - the name of the package to which the create type belongs
        `simpleName` - the unqualified source name of the type being generated
      Returns:
        `null` if the package and class already exists, otherwise a `PrintWriter` is returned.

    - #### tryCreateResource

          public java.io.OutputStream tryCreateResource​(TreeLogger logger,
                                                        java.lang.String partialPath)
                                                 throws UnableToCompleteException

      Description copied from interface: `GeneratorContext`
      Attempts to get an `OutputStream` so that the caller can write file contents into the named file underneath the compilation output directory. The file is not committed until `GeneratorContext.commitResource(TreeLogger, OutputStream)` is called.
      Specified by:
        `tryCreateResource` in interface `GeneratorContext`
      Parameters:
        `logger` - a logger; normally the logger passed into the currently invoked generator, or a branch thereof
        `partialPath` - the name of the file whose contents are to be written; the name can include subdirectories separated by forward slashes ('/')
      Returns:
        an `OutputStream` into which file contents can be written, or `null` if a resource by that name is already pending or already exists
      Throws:
        `UnableToCompleteException` - if the resource could not be initialized for some reason, such as if the specified partial path is invalid

    - #### tryReuseTypeFromCache

          public boolean tryReuseTypeFromCache​(java.lang.String typeName)

      Description copied from interface: `GeneratorContext`
      Mark a type to be reused from the generator result cache, if available. Calling this method with a successful response indicates that the calling generator will not re-generate this type. A cached version of this type will be added to the context once the calling generator returns from `IncrementalGenerator.generateIncrementally(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)`, with a result containing `RebindMode.USE_PARTIAL_CACHED`.
      Specified by:
        `tryReuseTypeFromCache` in interface `GeneratorContext`
      Parameters:
        `typeName` - the fully qualified source name of a type.
      Returns:
        true if the requested type is available from the generator result cache, false otherwise.