You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ov...@apache.org on 2002/03/17 22:45:00 UTC

cvs commit: xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow ScriptSource.java

ovidiu      02/03/17 13:45:00

  Added:       src/scratchpad/schecoon/src/org/apache/cocoon/components/flow
                        ScriptSource.java
  Log:
  Representation of script source. Maintains the timestamp of the last
  modification, together with the Source object, but caches access to
  the timestamp for efficiency.
  
  Revision  Changes    Path
  1.1                  xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/ScriptSource.java
  
  Index: ScriptSource.java
  ===================================================================
  package org.apache.cocoon.components.flow;
  
  import org.apache.cocoon.environment.Environment;
  import org.apache.cocoon.environment.ModifiableSource;
  import org.apache.cocoon.environment.Source;
  import org.apache.cocoon.environment.SourceResolver;
  
  /**
   * Representation of a source in a scripting language. Loosely modeled
   * after Source and ModifiableSource, but doesn't carry all the XML
   * baggage which is not needed here.
   *
   * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
   * @since March 16, 2002
   */
  public class ScriptSource
  {
    Interpreter interp;
    String sourceName;
    Source source;
    boolean isModifiable;
  
    public ScriptSource(Interpreter interp, String sourceName)
    {
      this.interp = interp;
      this.sourceName = sourceName;
    }
  
    public String getSourceName()
    {
      return sourceName;
    }
  
    public long getLastModified()
    {
      if (isModifiable)
        ((ModifiableSource)source).refresh();
  
      return source == null ? 0 : source.getLastModified();
    }
  
    public void refresh(Environment environment)
      throws Exception
    {
      System.out.println("ScriptSource: sourceName = " + sourceName);
      source = interp.readScript(environment, sourceName);
      isModifiable = source instanceof ModifiableSource;
    }
  }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org