|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.merlotxml.util.xml.DTDCache
This singleton class is responsible for loading and caching all DTD's required by the system. This manager can load DTD's from the filesystem, URL's, and zip/jar files (not currently implemented).
Apps should use this class to retrieve all their DTD's for valid documents (non-validating apps usually ignore the DTD anyway, so they don't really need to use this, but if they do get a DTD, it might be a good idea to call into this class.
Here's an example of getting a dtd:
DTDCacheEntry dtdentry = DTDCache.getSharedInstance().findDTD(publicId,
systemId);
where publicId is the DOCTYPE's given public identifier (can be
null), and systemId is a system designator (file path or URL)
This can also cache DTD's from other entity resolvers via the resolveDTD method.
Field Summary | |
protected java.util.Map |
_dtdEntries
List of unique dtd entries. |
protected java.util.Map |
_filepathCache
key is the file path (including a ! and the path within a jar), val is a DTDCacheEntry |
protected static DTDCache |
_instance
singleton instance |
protected java.util.Properties |
_properties
Properties for getting dtd path, etc. |
protected java.util.Map |
_publicIdCache
key is the public id, val is a DTDCacheEntry, e.g. |
protected static java.lang.Object |
_synchronizer
synch object for creating the instance |
protected java.util.Map |
_systemIdCache
key is the system id, val is a DTDCacheEntry, e.g. |
protected static java.lang.String |
FILE_PROTOCOL_NAME
url prefix to know we're working with a local file |
Constructor Summary | |
protected |
DTDCache()
Constructor for the DTDCache object |
Method Summary | |
void |
checkCacheEntryTimestamp(DTDCacheEntry entry)
Checks the timestamp associated with a cache entry and reloads the dtd file if it has changed. |
protected void |
debug(java.lang.String s)
simple debugging print routine |
protected DTDCacheEntry |
findCacheEntryBySystemID(java.lang.String systemID)
|
DTDCacheEntry |
findDTD(java.lang.String pubid,
java.lang.String sysid,
java.lang.String fileLocation)
find a DTD based on the public id and system id |
DTDCacheEntry |
findDTDbyPublicId(java.lang.String publicId,
java.lang.String systemId)
Looks in our cache for a file with a given public ID |
DTDCacheEntry |
findDTDbySystemId(java.lang.String publicId,
java.lang.String systemId,
java.lang.String fileLocation)
Finds a dtd given a system identifier. |
protected java.io.InputStream |
findDTDFromClassLoader(java.lang.String publicID,
java.lang.String systemID)
|
protected java.io.InputStream |
findDTDFromDTDPath(java.lang.String publicID,
java.lang.String systemID)
|
protected java.io.InputStream |
findDTDFromFile(java.lang.String systemID)
see if the systemID exists as-is (is the absolute path embedded in the xml?) |
protected java.io.InputStream |
findDTDFromFile(java.lang.String systemID,
java.lang.String fileLocation)
|
protected java.io.InputStream |
findDTDFromURL(java.lang.String publicID,
java.lang.String systemID)
|
protected java.lang.String |
fixslashes(java.lang.String s)
Deprecated. use fixSlashes instead |
protected java.lang.String |
fixSlashes(java.lang.String s)
make all slashes forward slashes cause windows sucks |
protected java.lang.String |
formatFileName(java.lang.String originalFileName)
|
java.util.Collection |
getCachedDTDEntries()
Gets the cachedDTDEntries attribute of the DTDCache object |
protected java.lang.String |
getDTDPath()
Gets the dTDPath attribute of the DTDCache object |
static DTDCache |
getSharedInstance()
gets the singleton instance. |
void |
loadDTDIntoCache(java.io.InputStream is,
DTDCacheEntry entry)
Loads a dtd into a DTDCacheEntry. |
void |
loadDTDIntoCache(java.io.Reader r,
DTDCacheEntry entry)
Loads a dtd into a DTDCacheEntry. |
void |
printCache()
Description of the Method |
DTDCacheEntry |
resolveDTD(java.lang.String publicId,
java.lang.String systemId,
org.xml.sax.EntityResolver resolver,
java.lang.String fileLocation)
resolve a dtd from another resolver. |
void |
setProperties(java.util.Properties props)
set the properties. |
protected DTDCacheEntry |
setupCacheEntryFromClassLoader(java.lang.String publicID,
java.lang.String systemID)
|
protected DTDCacheEntry |
setupCacheEntryFromFile(java.lang.String publicID,
java.lang.String systemID)
|
protected DTDCacheEntry |
setupCacheEntryFromURL(java.lang.String publicID,
java.lang.String systemID)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.Map _publicIdCache
protected java.util.Map _systemIdCache
protected java.util.Map _filepathCache
protected java.util.Map _dtdEntries
protected java.util.Properties _properties
protected static DTDCache _instance
protected static final java.lang.Object _synchronizer
protected static final java.lang.String FILE_PROTOCOL_NAME
Constructor Detail |
protected DTDCache()
Method Detail |
public static DTDCache getSharedInstance()
public void setProperties(java.util.Properties props)
props
- The new properties valueprotected DTDCacheEntry findCacheEntryBySystemID(java.lang.String systemID)
systemID
- ba
protected DTDCacheEntry setupCacheEntryFromFile(java.lang.String publicID, java.lang.String systemID)
publicID
- systemID
-
protected DTDCacheEntry setupCacheEntryFromClassLoader(java.lang.String publicID, java.lang.String systemID)
publicID
- systemID
-
protected DTDCacheEntry setupCacheEntryFromURL(java.lang.String publicID, java.lang.String systemID)
publicID
- Description of the ParametersystemID
- Description of the Parameter
protected java.io.InputStream findDTDFromFile(java.lang.String systemID)
systemID
- Description of the Parameter
protected java.io.InputStream findDTDFromFile(java.lang.String systemID, java.lang.String fileLocation)
systemID
- Description of the ParameterfileLocation
- Description of the Parameter
protected java.io.InputStream findDTDFromURL(java.lang.String publicID, java.lang.String systemID)
publicID
- systemID
-
protected java.io.InputStream findDTDFromClassLoader(java.lang.String publicID, java.lang.String systemID)
publicID
- systemID
-
protected java.io.InputStream findDTDFromDTDPath(java.lang.String publicID, java.lang.String systemID)
publicID
- systemID
-
public DTDCacheEntry findDTDbySystemId(java.lang.String publicId, java.lang.String systemId, java.lang.String fileLocation)
publicId
- systemId
- can be a URL, and absolute filepath, or a filepath
relative to the current documentfileLocation
- the location of the file which includes the given
DTD
public DTDCacheEntry findDTDbyPublicId(java.lang.String publicId, java.lang.String systemId)
publicId
- Description of the ParametersystemId
- Description of the Parameter
public DTDCacheEntry findDTD(java.lang.String pubid, java.lang.String sysid, java.lang.String fileLocation)
pubid
- Description of the Parametersysid
- Description of the ParameterfileLocation
- Description of the Parameter
public DTDCacheEntry resolveDTD(java.lang.String publicId, java.lang.String systemId, org.xml.sax.EntityResolver resolver, java.lang.String fileLocation) throws org.xml.sax.SAXException, java.io.IOException
publicId
- Description of the ParametersystemId
- Description of the Parameterresolver
- Description of the ParameterfileLocation
- Description of the Parameter
org.xml.sax.SAXException
- Description of the Exception
java.io.IOException
- Description of the Exceptionpublic void loadDTDIntoCache(java.io.InputStream is, DTDCacheEntry entry) throws java.io.IOException
is
- Description of the Parameterentry
- Description of the Parameter
java.io.IOException
- Description of the Exceptionpublic void loadDTDIntoCache(java.io.Reader r, DTDCacheEntry entry) throws java.io.IOException
r
- Description of the Parameterentry
- Description of the Parameter
java.io.IOException
- Description of the Exceptionpublic void checkCacheEntryTimestamp(DTDCacheEntry entry)
entry
- Description of the Parameterpublic java.util.Collection getCachedDTDEntries()
public void printCache()
protected java.lang.String fixslashes(java.lang.String s)
s
- Description of the Parameter
protected java.lang.String fixSlashes(java.lang.String s)
s
- Description of the Parameter
protected void debug(java.lang.String s)
s
- Description of the Parameterprotected java.lang.String formatFileName(java.lang.String originalFileName)
originalFileName
- - systemID
protected java.lang.String getDTDPath()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |