org.cdlib.xtf.dynaXML
Class DefaultDocLocator

Object
  extended by DefaultDocLocator
All Implemented Interfaces:
DocLocator

public class DefaultDocLocator
extends Object
implements DocLocator

Provides local filesystem-based access to lazy and non-lazy versions of a source XML document.

Author:
Martin Haye

Nested Class Summary
private static class DefaultDocLocator.LazyPassthru
          Passes SAX events to a ContentHandler.
 
Field Summary
private  TextServlet servlet
          Servlet we are part of
 
Constructor Summary
DefaultDocLocator()
           
 
Method Summary
private  void buildLazyStore(File lazyFile, String sourcePath, Templates preFilter, boolean removeDoctypeDecl, boolean stripWhitespace)
          Create a lazy document by loading the original, building the lazy tree, and writing it out.
 InputSource getInputSource(String sourcePath, boolean removeDoctypeDecl)
          Retrieve the data stream for an XML source document.
 StructuredStore getLazyStore(String indexConfigPath, String indexName, String sourcePath, Templates preFilter, boolean removeDoctypeDecl)
          Search for a StructuredStore containing the "lazy" or persistent representation of a given document.
private  boolean isPostIndexLazyFile(File f)
          Check if the given lazy file was created after the indexing process (i.e. by this doc locator)
 void setServlet(TextServlet servlet)
          Attach to a servlet
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

servlet

private TextServlet servlet
Servlet we are part of

Constructor Detail

DefaultDocLocator

public DefaultDocLocator()
Method Detail

setServlet

public void setServlet(TextServlet servlet)
Attach to a servlet

Specified by:
setServlet in interface DocLocator
Parameters:
servlet - Servlet to attach to

getLazyStore

public StructuredStore getLazyStore(String indexConfigPath,
                                    String indexName,
                                    String sourcePath,
                                    Templates preFilter,
                                    boolean removeDoctypeDecl)
                             throws IOException
Search for a StructuredStore containing the "lazy" or persistent representation of a given document. Index parameters are specified, since often the lazy file is stored along with the index. This method is called first, and if it returns null, then getInputSource(String, boolean) will be called as a fall-back.

Specified by:
getLazyStore in interface DocLocator
Parameters:
indexConfigPath - Path to the index configuration file
indexName - Name of the index being searched
sourcePath - Path to the source document
preFilter - Prefilter stylesheet to run (or null for none)
removeDoctypeDecl - Set to true to remove DOCTYPE declaration from the XML document.
Returns:
Store containing the tree, or null if none could be found.
Throws:
IOException

getInputSource

public InputSource getInputSource(String sourcePath,
                                  boolean removeDoctypeDecl)
                           throws IOException
Retrieve the data stream for an XML source document.

Specified by:
getInputSource in interface DocLocator
Parameters:
sourcePath - Path to the source document
removeDoctypeDecl - Set to true to remove DOCTYPE declaration from the XML document.
Returns:
Data stream for the document.
Throws:
IOException

buildLazyStore

private void buildLazyStore(File lazyFile,
                            String sourcePath,
                            Templates preFilter,
                            boolean removeDoctypeDecl,
                            boolean stripWhitespace)
                     throws IOException
Create a lazy document by loading the original, building the lazy tree, and writing it out.

Parameters:
lazyFile - Lazy file to create
sourcePath - Path to the source document
preFilter - A prefilter stylesheet (or null for no pre-filtering.)
removeDoctypeDecl - true to remove DOCTYPE declarations from the XML document
stripWhitespace - If set, whitespace will be removed between elements in the lazy file.
Throws:
IOException

isPostIndexLazyFile

private boolean isPostIndexLazyFile(File f)
Check if the given lazy file was created after the indexing process (i.e. by this doc locator)