|
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.AdvertisementFactory
A Factory class for Advertisements. This class abstracts the the implementations used to represent and create advertisements.
Advertisements are core objects that are used to advertise a Peer, a PeerGroup, a Service, or a PipeServiceImpl. The Advertisement class provides a platform independent representation of core objects that can be exchanged between different implementations (Java, C). The AdvertisementFactory extends the ClassFactory to register the various types of adverstisements into a static hastable. The factory is called with the Advertisement type requested to create the corresponding advertisement type. The initial set of Advertisement instances is loaded from the java property "net.jxta.impl.config.AdvertisementInstanceTypes" It would be nice to have "newAdvertisement" methods for "Document" and "TextDocument", but this is not feasible because "TextElement" got there first.
Advertisement
,
Document
,
MimeMediaType
,
PeerGroup
,
PeerAdvertisement
,
PeerGroupAdvertisement
,
PipeAdvertisement
Nested Class Summary | |
static interface |
AdvertisementFactory.Instantiator
Interface for instantiators of Advertisements |
Method Summary | |
protected Map |
getAssocTable()
Used by ClassFactory methods to get the mapping of keys to constructors. |
Class |
getClassForKey()
Used by ClassFactory methods to ensure that all keys used with the mapping are of the correct type. |
Class |
getClassOfInstantiators()
Used by ClassFactory methods to ensure that all of the instance classes which register with this factory have the correct base class |
static Advertisement |
newAdvertisement(MimeMediaType mimetype,
InputStream stream)
Constructs an instance of Advertisement from the provided
InputStream . |
static Advertisement |
newAdvertisement(MimeMediaType mimetype,
Reader source)
Constructs an instance of Advertisement from the provided
Reader . |
static Advertisement |
newAdvertisement(String advertisementType)
Constructs an instance of Advertisement matching the type
specified by the advertisementType parameter. |
static Advertisement |
newAdvertisement(TextElement root)
Constructs an instance of Advertisement matching the type
specified by the root parameter. |
static boolean |
registerAdvertisementInstance(String rootType,
AdvertisementFactory.Instantiator instantiator)
Register an instantiator for and advertisement type to allow instances of that type to be created. |
protected boolean |
registerAssoc(String className)
Register a class with the factory from its class name. Since class name doesn't tell us much, we just load the class and hope that something happens as a result of the class loading. This class is often overridden in class factories to interogate the instance class before registering the instance class. |
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
public Class getClassOfInstantiators()
getClassOfInstantiators
in class ClassFactory
public Class getClassForKey()
getClassForKey
in class ClassFactory
protected boolean registerAssoc(String className)
registerAssoc
in class ClassFactory
className
- The class name which will be regiestered.
public static boolean registerAdvertisementInstance(String rootType, AdvertisementFactory.Instantiator instantiator)
rootType
- the identifying value for this advertisement instance
typeinstantiator
- the instantiator to use in constructing objects
of this rootType.
public static Advertisement newAdvertisement(String advertisementType)
Advertisement
matching the type
specified by the advertisementType
parameter.
advertisementType
- Specifies the type of advertisement to create.
Advertisement
.
NoSuchElementException
- if there is no matching advertisement type.public static Advertisement newAdvertisement(MimeMediaType mimetype, InputStream stream) throws IOException
Advertisement
from the provided
InputStream
. The content type of the stream is declared via
the mimetype
parameter.
mimetype
- Specifies the mime media type of the stream being read.stream
- imput stream used to read data to construct the advertisement
Advertisement
IOException
- error reading message from input stream
NoSuchElementException
- if there is no matching advertisement type
for the type of document read in.
UnsupportedOperationException
- if the specified mime type is not
associated with a text oriented document type.public static Advertisement newAdvertisement(MimeMediaType mimetype, Reader source) throws IOException
Advertisement
from the provided
Reader
. The content type of the reader is declared via the
mimetype
parameter.
mimetype
- Specifies the mime media type of the stream being read.source
- used to read data to construct the advertisement.
Advertisement
IOException
- error reading message from input stream
NoSuchElementException
- if there is no matching advertisement type
for the type of document read in.
UnsupportedOperationException
- if the specified mime type is not
associated with a text oriented document type.public static Advertisement newAdvertisement(TextElement root)
Advertisement
matching the type
specified by the root
parameter.
root
- Specifies a portion of a StructuredDocument which will be
converted into an Advertisement.
Advertisement
.
NoSuchElementException
- if there is no advertisement type
matching the type of the root node.
|
JXTA J2SE | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |