Class DefaultSourceFactory

java.lang.Object
ch.grengine.source.DefaultSourceFactory
All Implemented Interfaces:
SourceFactory

public class DefaultSourceFactory extends Object implements SourceFactory
Default implementation of the SourceFactory interface.

Generally used by default within Grengine, unless a different source factory has been explicitly indicated.

If the builder's URL content tracking is set, Source.getLastModified() will be updated based on the URL content, within the latency period and only if queried. For this purpose, a hash of the URL content is cached internally for each URL source.

Since:
1.0
Author:
Alain Stalder, Made in Switzerland.
  • Constructor Details

    • DefaultSourceFactory

      protected DefaultSourceFactory(DefaultSourceFactory.Builder builder)
      constructor from builder.
      Parameters:
      builder - builder
      Since:
      1.0
    • DefaultSourceFactory

      public DefaultSourceFactory()
      constructor from default builder (no URL tracking).
      Since:
      1.0
  • Method Details

    • fromText

      public Source fromText(String text)
      Description copied from interface: SourceFactory
      gets source from script text.
      Specified by:
      fromText in interface SourceFactory
      Parameters:
      text - script text
      Returns:
      source
    • fromText

      public Source fromText(String text, String desiredClassName)
      Description copied from interface: SourceFactory
      gets source from script text and desired class name.
      Specified by:
      fromText in interface SourceFactory
      Parameters:
      text - script text
      desiredClassName - desired class name
      Returns:
      source
    • fromFile

      public Source fromFile(File file)
      Description copied from interface: SourceFactory
      gets source from script file.
      Specified by:
      fromFile in interface SourceFactory
      Parameters:
      file - script file
      Returns:
      source
    • fromUrl

      public Source fromUrl(URL url)
      Description copied from interface: SourceFactory
      gets source from script URL.
      Specified by:
      fromUrl in interface SourceFactory
      Parameters:
      url - script URL
      Returns:
      source
    • clearCache

      public void clearCache()
      clears the cache of URL content hashes.
      Since:
      1.0
    • getBuilder

      public DefaultSourceFactory.Builder getBuilder()
      gets the builder.
      Returns:
      builder
      Since:
      1.0