EchoPoint
1.0

echopoint.ui.template
Class SGMLPageParser

java.lang.Object
  extended byechopoint.ui.template.SGMLPageParser
All Implemented Interfaces:
java.io.Serializable

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

SGMLPageParser parses SGML markup'd pages and executes active tags within. Returns its output through a Element (given in a ParseContext).

Active Tags are handled with SpecialTagHandlers which can be registered for a specific Tag name.

The parsing is done via a two pass method. The first pass reads the input and keeps track of the positions and lengths of each active tag. If there is a tag handler for the tag, then the parseTag method is called.

The second pass involves executing the active tags. The static content is copied until the remembered position of a tag is encountered. Then the executeTag method is called for each stored active tag. The tag handler is then responsible for generating the output to be placed in that position.

DataSource objects will be cached to ensure the fast execution. The DataSource will be re-parsed if the lastModified data exceeds the stored time.

If a DataSource has already been broken into parts (step 1 parse) then this step will be skipped (as long as the last modified time is the same) and hence the template output will be rendered much faster.

See Also:
Serialized Form

Constructor Summary
SGMLPageParser()
          Constructs a new SGMLPageParser.
 
Method Summary
 CompilationUnit compileDS(CompilationContext context, DataSource source, boolean forceCompilation)
          Compiles a DataSource and returns a CompilationUnit representing the compiled data.
static SGMLPageParser getInstance()
          Returns a singleton instance of this PageParser.
 java.util.Iterator getRegisteredTags()
           
 void process(DataSource source, CompilationContext compilationContext, ParseContext parseContext)
          Process a general DataStore representing a Template
 void process(java.io.File file, CompilationContext compilationContext, ParseContext parseContext)
          Processes a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SGMLPageParser

public SGMLPageParser()
Constructs a new SGMLPageParser.

Method Detail

compileDS

public CompilationUnit compileDS(CompilationContext context,
                                 DataSource source,
                                 boolean forceCompilation)
                          throws java.io.IOException
Compiles a DataSource and returns a CompilationUnit representing the compiled data.

If DataSource has changed or has not yet been loaded, load it and chop into sections, storing result for future use. Otherwise, return stored preprocessed page.

If the Component properties have not been set, according to the CompilationContext, then they will be set during this call.

Throws:
java.io.IOException

getRegisteredTags

public java.util.Iterator getRegisteredTags()
Returns:
Iterator of all Tags which are special to this PageParser

process

public void process(DataSource source,
                    CompilationContext compilationContext,
                    ParseContext parseContext)
             throws java.io.IOException
Process a general DataStore representing a Template

Throws:
java.io.IOException

process

public void process(java.io.File file,
                    CompilationContext compilationContext,
                    ParseContext parseContext)
             throws java.io.IOException
Processes a file.

Throws:
java.io.IOException

getInstance

public static SGMLPageParser getInstance()
Returns a singleton instance of this PageParser. You usually want to use the singleton instance to make use of a central cache.


EchoPoint
1.0