|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.xml.xmlc.deferredparsing.DocumentLoaderImpl
Default implementation of the DocumentLoader
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 re-parsed 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.
Inner Class Summary | |
protected static class |
DocumentLoaderImpl.CacheEntry
Helper class for storing cached DOMs |
Constructor Summary | |
DocumentLoaderImpl()
Default constructor. |
|
DocumentLoaderImpl(Map cache)
Constructor. |
Method Summary | |
protected EditDOM |
createDOMEditor(Class docClass,
MetaData metaData)
Create the DOM editor to use. |
protected Parse |
createParser(Class docClass,
ErrorReporter errorReporter,
PrintWriter verboseOut)
Create the parser to use. |
protected URL |
findSourceUrl(Class docClass)
Find the URL of the source document associated with docClass . |
protected DocumentLoaderImpl.CacheEntry |
getCacheEntry(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 Object |
getClassConstant(Class xmlcBasedClass,
String constName)
Get one of the compiled-in constants in a XMLC-generated class (or subclass). |
protected long |
getCurrentTimestamp(Class docClass,
URL src)
Get the current timestamp of the *ML template for docClass. |
Document |
getDocument(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 String |
getSourceFileName(Class docClass)
Get the name of the source file associated with docClass |
void |
init(XMLCDeferredParsingFactory factory)
Bind to a factory. |
protected MetaData |
loadMetaData(Class docClass,
ErrorReporter errorReporter)
Load the XMLC metadata file. |
protected String |
makeCacheKey(Class docClass)
Generates a cache key for the given document class. |
protected String |
metaDataFileName(Class docClass)
Get the meta-data file path. |
protected Document |
parseDocument(Class docClass,
URL src)
Create a new template DOM for docClass |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public DocumentLoaderImpl()
Cache
as template
DOM cache.DocumentLoaderImpl(Map)
public DocumentLoaderImpl(Map cache)
cache
- the cache to use.Method Detail |
protected String makeCacheKey(Class docClass)
docClass
- the class to generate the cache key forprotected DocumentLoaderImpl.CacheEntry getCacheEntry(Class docClass)
docClass
- the class to get the cache entry for.public Document getDocument(Class docClass) throws XMLCRuntimeException
getDocument
in interface DocumentLoader
docClass
- the XMLC generated class to get the DOM for.docClass
public static Object getClassConstant(Class xmlcBasedClass, String constName)
protected String getSourceFileName(Class docClass) throws XMLCRuntimeException
docClass
protected URL findSourceUrl(Class docClass)
docClass
.
If the source file cannot be found, an exception is thrown.
Resource dirs are searched first, then the classloader.
Package prefix paths are taken into account.docClass
- the class for which to load the source docXMLCRuntimeException
- if the source doc cannot be foundprotected String metaDataFileName(Class docClass)
protected MetaData loadMetaData(Class docClass, ErrorReporter errorReporter) throws XMLCException
docClass
- the class for which to load the metadataerrorReporter
- the error handler to useXMLCRuntimeException
- if the metadata cannot be foundXMLCException
- if the found metadata cannot be parsedprotected long getCurrentTimestamp(Class docClass, URL src)
docClass
- the class to get the information forsrc
- the source URL for this class, as returned by
findSourceUrl(Class)
protected Document parseDocument(Class docClass, URL src)
docClass
- the class to load the DOM forsrc
- the source file for this class, as returned by
#findSourceFile
protected Parse createParser(Class docClass, ErrorReporter errorReporter, PrintWriter verboseOut)
protected EditDOM createDOMEditor(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: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |