|
Project JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.util.ClassFactory
net.jxta.document.StructuredDocumentFactory
public final class StructuredDocumentFactory
A factory for constructing instances of StructuredDocument
.
Behind the scenes, it also provides for the registration of the mime-types
and constructors needed to accomplish the construction. All supported
mime-types will need to register their implementation in this factory.
The configuration is done via the property net.jxta.impl.config.StructuredDocumentInstanceTypes
Document
,
StructuredTextDocument
,
StructuredDocument
,
MimeMediaType
Nested Class Summary | |
---|---|
static interface |
StructuredDocumentFactory.Instantiator
Interface for instantiators of StructuredDocuments |
static interface |
StructuredDocumentFactory.TextInstantiator
Interface for instantiators of StructuredTextDocuments |
Method Summary | |
---|---|
protected Map |
getAssocTable()
Used by ClassFactory methods to get the mapping of Mime Types to constructors. |
protected Class |
getClassForKey()
Used by ClassFactory methods to ensure that all keys used with the mapping are of the correct type. |
protected Class |
getClassOfInstantiators()
Used by ClassFactory methods to ensure that all of the instantiators which are registered with this factory have the correct interface. |
static String |
getFileExtensionForMimeType(MimeMediaType mimetype)
Returns the prefered extension for a given mime-type. |
static MimeMediaType |
getMimeTypeForFileExtension(String extension)
Returns the prefered mime-type for a given file extension. |
static StructuredDocument |
newStructuredDocument(MimeMediaType mimetype,
InputStream stream)
Constructs an instance of StructuredDocument matching
the mime-type specified by the mimetype parameter. |
static StructuredDocument |
newStructuredDocument(MimeMediaType mimetype,
Reader reader)
Constructs an instance of StructuredDocument matching
the mime-type specified by the mimetype parameter. |
static StructuredDocument |
newStructuredDocument(MimeMediaType mimetype,
String doctype)
Constructs an instance of StructuredDocument matching
the mime-type specified by the mimetype parameter. |
static StructuredDocument |
newStructuredDocument(MimeMediaType mimetype,
String doctype,
String value)
Constructs an instance of StructuredDocument matching
the mime-type specified by the mimetype parameter. |
protected boolean |
registerAssoc(String className)
Register a class with the factory from its class name. |
static boolean |
registerInstantiator(MimeMediaType mimetype,
StructuredDocumentFactory.Instantiator instantiator)
Register an instantiator object a mime-type of documents to be constructed. |
Methods inherited from class net.jxta.util.ClassFactory |
---|
getAvailableKeys, getEntrySet, getInstantiator, registerAssoc, registerFromResources, registerFromString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
protected Map getAssocTable()
getAssocTable
in class ClassFactory
protected Class getClassForKey()
getClassForKey
in class ClassFactory
protected Class getClassOfInstantiators()
getClassOfInstantiators
in class ClassFactory
protected boolean registerAssoc(String className)
registerAssoc
in class ClassFactory
className
- The class name which will be regiestered.
public static String getFileExtensionForMimeType(MimeMediaType mimetype)
mimetype
- the MimeMediaType we wish to know the file extension for.
public static MimeMediaType getMimeTypeForFileExtension(String extension)
extension
- The extension we wish to know the mime-type for.
public static boolean registerInstantiator(MimeMediaType mimetype, StructuredDocumentFactory.Instantiator instantiator)
mimetype
- the mime-type associated.instantiator
- the instantiator that wants to be registered..
SecurityException
- there were permission problems registering
the instantiator.public static StructuredDocument newStructuredDocument(MimeMediaType mimetype, String doctype)
StructuredDocument
matching
the mime-type specified by the mimetype
parameter. The
doctype
parameter identifies the base type of the
StructuredDocument
.
mimetype
- Specifies the mime media type to be associated with
the StructuredDocument
to be created.doctype
- Specifies the root type of the StructuredDocument
to be created.
StructuredDocument
or null if it could not be created.
NoSuchElementException
- invalid mime-media-typepublic static StructuredDocument newStructuredDocument(MimeMediaType mimetype, String doctype, String value)
StructuredDocument
matching
the mime-type specified by the mimetype
parameter. The
doctype
parameter identifies the base type of the
StructuredDocument
. Value supplies a value for the root
element.
mimetype
- Specifies the mime media type to be associated with
the StructuredDocument
to be created.doctype
- Specifies the root type of the StructuredDocument
to be created.value
- Specifies a value for the root element.
StructuredDocument
or null if it could not be created.
NoSuchElementException
- if the mime-type has not been registerd.public static StructuredDocument newStructuredDocument(MimeMediaType mimetype, InputStream stream) throws IOException
StructuredDocument
matching
the mime-type specified by the mimetype
parameter. The
doctype
parameter identifies the base type of the
StructuredDocument
.
mimetype
- Specifies the mime media type to be associated with the
StructuredDocument
to be created.stream
- Contains an InputStream from which the document will be
constructed.
StructuredDocument
or null if it could not be created.
IOException
- If there is a problem reading from the stream.
NoSuchElementException
- if the mime-type has not been registerd.public static StructuredDocument newStructuredDocument(MimeMediaType mimetype, Reader reader) throws IOException
StructuredDocument
matching
the mime-type specified by the mimetype
parameter. The
doctype
parameter identifies the base type of the
StructuredDocument
.
mimetype
- Specifies the mime media type to be associated with the
StructuredDocument
to be created.reader
- A Reader from which the document will be constructed.
StructuredDocument
or null if it could not be created.
IOException
- If there is a problem reading from the stream.
NoSuchElementException
- if the mime-type has not been registerd.
UnsupportedOperationException
- if the mime-type provided is not
a text oriented mimetype.
|
JXTA J2SE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |