|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.schmant.support.AbstractArgumentChecker org.schmant.support.xml.XmlCatalogResolver
public class XmlCatalogResolver
This is an EntityResolver
and a URIResolver
that uses
internal mappings between systemId, publicId or URI and objects that can be
interpreted as ReadableFile
:s by
InterpretAsReadableFileStrategy
.
This can for instance be used to handle relative paths in external entities. That can be difficult in Java, otherwise.
The catalog resolver is case sensitive.
The resolve methods log their results to level debug, unless
setVerbose(boolean)
is set to true
, in which case all
results are logged to level info.
Instances of this class are thread safe.
Constructor Summary | |
---|---|
XmlCatalogResolver()
|
Method Summary | |
---|---|
XmlCatalogResolver |
addPublicId(String pid,
Object o)
Add one entity with the supplied public ID to the catalog. |
XmlCatalogResolver |
addPublicIds(Map<String,?> m)
Add a map with public ID:s and their corresponding entities. |
XmlCatalogResolver |
addSystemId(String sid,
Object o)
Add one entity with the supplied system ID to the catalog. |
XmlCatalogResolver |
addSystemIds(Map<String,?> m)
Add a map with system ID:s and their corresponding entities. |
XmlCatalogResolver |
addUri(String uri,
Object o)
Add one entity with the supplied URI to the catalog. |
XmlCatalogResolver |
addUris(Map<String,?> m)
Add a map with URI:s and their corresponding entities. |
Map<String,Object> |
getPublicIdMap()
Get (a copy of) all the public id mappings in the catalog resolver. |
Map<String,Object> |
getSystemIdMap()
Get (a copy of) all the system id mappings in the catalog resolver. |
Map<String,Object> |
getUriMap()
Get (a copy of) all the URI mappings in the catalog resolver. |
Source |
resolve(String href,
String base)
This methods resolves entities in the URI map. |
InputSource |
resolveEntity(String publicId,
String systemId)
|
XmlCatalogResolver |
setPreferPublic(boolean preferPublic)
When resolving entities, should publicId names be used before systemId names? The default is to use systemId names before publicId ( false ). |
XmlCatalogResolver |
setUseFilesInsteadOfStreamsForUris(boolean b)
Should java.io.File -based javax.xml.transform.Source
objects be created instead of java.io.InputStream -based when
resolving URI:s? Doing so probably makes the Source object
reusable and vaguely aware of the entity's location, which seems to be
required by some XML applications. |
XmlCatalogResolver |
setVerbose(boolean b)
Should the catalog resolver be verbose? If it is, it logs an info message to the current thread's Report every time it tries to resolve an
entity. |
String |
toString()
|
Methods inherited from class org.schmant.support.AbstractArgumentChecker |
---|
check, check, check, check |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public XmlCatalogResolver()
Method Detail |
---|
public XmlCatalogResolver setPreferPublic(boolean preferPublic)
false
).
preferPublic
- Should publicId names be preferred?
this
public XmlCatalogResolver setVerbose(boolean b)
Report
every time it tries to resolve an
entity.
b
- Should the resolver be verbose?
this
public XmlCatalogResolver setUseFilesInsteadOfStreamsForUris(boolean b)
java.io.File
-based javax.xml.transform.Source
objects be created instead of java.io.InputStream
-based when
resolving URI:s? Doing so probably makes the Source
object
reusable and vaguely aware of the entity's location, which seems to be
required by some XML applications. (Docbook XSL stylesheets, for
instance.) On the other hand, setting this to true requires that all
resolved entities are java.io.File
-backed.
The default is to use stream-based Source
objects. (false
)
b
- Should Source
objects be File
-based?
this
public Source resolve(String href, String base)
resolve
in interface URIResolver
public InputSource resolveEntity(String publicId, String systemId)
resolveEntity
in interface EntityResolver
public XmlCatalogResolver addSystemId(String sid, Object o)
XmlCatalog
addSystemId
in interface XmlCatalog<XmlCatalogResolver>
sid
- The system ID.o
- An entity that can be interpreted by
InterpretAsReadableFileStrategy
.
this
.public XmlCatalogResolver addSystemIds(Map<String,?> m)
XmlCatalog
addSystemIds
in interface XmlCatalog<XmlCatalogResolver>
m
- A mapping between system ID:s and entities.
this
public Map<String,Object> getSystemIdMap()
public XmlCatalogResolver addPublicId(String pid, Object o)
XmlCatalog
addPublicId
in interface XmlCatalog<XmlCatalogResolver>
pid
- The public ID.o
- An entity that can be interpreted by
InterpretAsReadableFileStrategy
.
this
.public XmlCatalogResolver addPublicIds(Map<String,?> m)
XmlCatalog
addPublicIds
in interface XmlCatalog<XmlCatalogResolver>
m
- A mapping between public ID:s and entities.
this
public Map<String,Object> getPublicIdMap()
public XmlCatalogResolver addUri(String uri, Object o)
XmlCatalog
addUri
in interface XmlCatalog<XmlCatalogResolver>
uri
- The URI.o
- An entity that can be interpreted by
InterpretAsReadableFileStrategy
.
this
.public XmlCatalogResolver addUris(Map<String,?> m)
XmlCatalog
addUris
in interface XmlCatalog<XmlCatalogResolver>
m
- A mapping between URI:s and entities.
this
public Map<String,Object> getUriMap()
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |