|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.xml.xmlc.deferredparsing.DocumentLoaderImpl
Default implementation of the DocumentBuilder
interface.
This implementation maintains a global cache of loaded DOM
objects. If a DOM object is found in cache and the cached copy is
up to date with regard to the source document and XMLC metadata
object, a copy of the cached object is handed out. Otherwise, the
document is reparsed from the source document, the DOM edits
specified in the document metadata are performed and the document
is stored in cache as a template. Note that the cache may be a
WeakHashMap
or a map with similar semantics that frees up
entries if memory gets low.
This class can be used as the basis for specialized document loaders.
Nested Class Summary | |
protected static class |
DocumentLoaderImpl.CacheEntry
Helper class for storing cached DOMs |
Constructor Summary | |
DocumentLoaderImpl()
Default constructor. |
|
DocumentLoaderImpl(java.util.Map cache)
Constructor. |
Method Summary | |
protected EditDOM |
createDOMEditor(java.lang.Class docClass,
MetaData metaData)
Create the DOM editor to use. |
protected Parse |
createParser(java.lang.Class docClass,
ErrorReporter errorReporter,
java.io.PrintWriter verboseOut)
Create the parser to use. |
protected java.io.File |
findSourceFile(java.lang.Class docClass)
Find the source file associated with docClass |
protected DocumentLoaderImpl.CacheEntry |
getCacheEntry(java.lang.Class docClass)
Get the cache entry for a document, initialize one of not already exists Note that the cache entry does not necessarily hold a template - it may need to be initialized first. |
static java.lang.Object |
getClassConstant(java.lang.Class xmlcBasedClass,
java.lang.String constName)
Get one of the compiled-in constants in a XMLC-generated class (or subclass). |
protected long |
getCurrentTimestamp(java.lang.Class docClass,
java.io.File src)
Get the current timestamp of the *ML template for docClass. |
org.w3c.dom.Document |
getDocument(java.lang.Class docClass)
Get a DOM instance representing the specified document. |
protected XMLCDeferredParsingFactory |
getFactory()
Get the associated factory |
protected XMLCLogger |
getLogger()
Get the associated logger |
protected java.lang.String |
getSourceFileName(java.lang.Class docClass)
Get the name of the source file associated with docClass |
void |
init(XMLCDeferredParsingFactory factory)
Bind to a factory. |
protected MetaData |
loadMetaData(java.lang.Class docClass,
ErrorReporter errorReporter)
Load the XMLC meta-data file. |
protected java.lang.String |
metaDataFileName(java.lang.Class docClass)
Get the meta-data file path. |
protected org.w3c.dom.Document |
parseDocument(java.lang.Class docClass,
java.io.File src)
Create a new template DOM for docClass |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DocumentLoaderImpl()
Cache
as template
DOM cache.
DocumentLoaderImpl(Map)
public DocumentLoaderImpl(java.util.Map cache)
cache
- the cache to use.Method Detail |
protected DocumentLoaderImpl.CacheEntry getCacheEntry(java.lang.Class docClass)
docClass
- the class to get the cache entry for.
public org.w3c.dom.Document getDocument(java.lang.Class docClass) throws XMLCRuntimeException
getDocument
in interface DocumentLoader
docClass
- the XMLC generated class to get the DOM for.
docClass
XMLCRuntimeException
public static java.lang.Object getClassConstant(java.lang.Class xmlcBasedClass, java.lang.String constName)
protected java.lang.String getSourceFileName(java.lang.Class docClass) throws XMLCRuntimeException
docClass
XMLCRuntimeException
protected java.io.File findSourceFile(java.lang.Class docClass) throws XMLCRuntimeException
docClass
XMLCRuntimeException
protected java.lang.String metaDataFileName(java.lang.Class docClass) throws XMLCRuntimeException
XMLCRuntimeException
protected MetaData loadMetaData(java.lang.Class docClass, ErrorReporter errorReporter) throws XMLCException
docClass
- the class to load the metadata forerrorReporter
- the error handler to use
XMLCException
protected long getCurrentTimestamp(java.lang.Class docClass, java.io.File src)
docClass
- the class to get the information forsrc
- the source file for this class, as returned by
findSourceFile(java.lang.Class)
protected org.w3c.dom.Document parseDocument(java.lang.Class docClass, java.io.File src)
docClass
- the class to laod the DOM forsrc
- the source file for this class, as returned by
findSourceFile(java.lang.Class)
protected Parse createParser(java.lang.Class docClass, ErrorReporter errorReporter, java.io.PrintWriter verboseOut)
protected EditDOM createDOMEditor(java.lang.Class docClass, MetaData metaData)
public void init(XMLCDeferredParsingFactory factory)
init
in interface DocumentLoader
factory
- Factory that is creating the object.protected XMLCDeferredParsingFactory getFactory()
protected XMLCLogger getLogger()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |