public abstract class DocumentFactory extends Service
DocumentFactory
interface is responsible for creating
intances of Document
s.
The type of Document
that gets created depends on the
URI
that is passed into the findOrCreate(URI)
method.
The DocumentFactory
makes use of registered Recognizer
instances to determine
what Document
class corresponds to a particular URI
.
JSR-198 specifies a number of ways to recognize documents:
URI
,
URI
to a document interface.For case 2. extension writers can map the XML namespace, doctype, or root element to a document interface.
For case3. extension writers can introduce their own custom
Recognizer
.
Every Document
instance created by the DocumentFactory
is cached. An instance of an already created Document
can be
retrieved from the cache by calling the find(URI)
method.
Document
Constructor and Description |
---|
DocumentFactory() |
Modifier and Type | Method and Description |
---|---|
abstract Document |
find(java.net.URI uri)
Find the
Document associated with the URI . |
abstract Document |
findOrCreate(java.net.URI uri)
Returns the
Document associated with the URI . |
abstract java.util.Collection |
getCachedDocuments()
Returns a
Collection of the Document instances that
are currently cached. |
static DocumentFactory |
getDocumentFactory()
Get the DocumentFactory implementation for this IDE.
|
abstract Document |
recache(java.net.URI oldURI,
java.net.URI newURI)
Removes the
oldURI from the cache and puts the
newURI in the cache so that it is associated
with the original Document oldURI pointed at. |
abstract Document |
uncache(java.net.URI uri)
Remove the specified URI from the cache.
|
cloneLoadedServices, getService, initialize, resetAllServices, setLoadedServices
public abstract Document findOrCreate(java.net.URI uri) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.ClassNotFoundException
Document
associated with the URI
. If the
Document
does not exist and the URI corresponds to a resource
that does exists, a new Document
of the correct
type is created.uri
- unique URI
identifying the document. Must not be null.java.lang.IllegalAccessException
- When the Document
interface or
its initializer is not accessible.java.lang.InstantiationException
- When the document is an abstract
class, an interface, an array class, a primitive type,
or void; or if the instantiation fails for some other reason.java.lang.ClassNotFoundException
- When the Class
is not found.public abstract Document find(java.net.URI uri)
public abstract Document recache(java.net.URI oldURI, java.net.URI newURI)
oldURI
from the cache and puts the
newURI
in the cache so that it is associated
with the original Document
oldURI
pointed at.oldURI
- the old URI of the document. Must not be null.newURI
- the new URI of the document. Must not be null.public abstract Document uncache(java.net.URI uri)
uri
- the uri to remove from the cache. Must not be null.public abstract java.util.Collection getCachedDocuments()
Collection
of the Document
instances that
are currently cached. The iteration order of the returned collection is
not guaranteed.Document
s. Never returns null, may return
an empty collection. The collection is immutable.public static DocumentFactory getDocumentFactory()