|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.util.ClassFactory<String,AdvertisementFactory.Instantiator>
net.jxta.document.AdvertisementFactory
public class AdvertisementFactory
A Factory class for constructing 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, a Pipe, etc. 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 advertisements into an internal table. The factory is called with the Advertisement type requested to create the corresponding advertisement type. The set of Advertisements types supported is loaded from the JXTA classpath via the service provider interface.
Advertisement
,
Document
,
MimeMediaType
,
PeerGroup
,
PeerAdvertisement
,
PeerGroupAdvertisement
,
PipeAdvertisement
Nested Class Summary | |
---|---|
static interface |
AdvertisementFactory.Instantiator
Interface for instantiators of Advertisements |
Method Summary | |
---|---|
protected Map<String,AdvertisementFactory.Instantiator> |
getAssocTable()
Used by ClassFactory methods to get the mapping of keys to constructors. |
Class<String> |
getClassForKey()
Used by ClassFactory methods to ensure that all keys used with the mapping are of the correct type. |
Class<AdvertisementFactory.Instantiator> |
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)
Deprecated. Please convert your code to construct an XMLDocument
using StructuredDocumentFactory and then call
newAdvertisement(XMLElement) . For example :
XMLDocument xml = (XMLDocument) StructuredDocumentFactory.newStructuredDocument( MimeMediaType.XMLUTF8, is );or frequently: XMLDocument xml = (XMLDocument) StructuredDocumentFactory.newStructuredDocument( msgElement );followed by: Advertisement adv = AdvertisementFactory.newAdvertisement(xml); |
static Advertisement |
newAdvertisement(MimeMediaType mimetype,
Reader source)
Deprecated. Please convert your code to construct an XMLDocument
using StructuredDocumentFactory and then call
newAdvertisement(XMLElement) . For example :
XMLDocument xml = (XMLDocument) StructuredDocumentFactory.newStructuredDocument( MimeMediaType.XMLUTF8, reader );or frequently: XMLDocument xml = (XMLDocument) StructuredDocumentFactory.newStructuredDocument( msgElement );followed by: Advertisement adv = AdvertisementFactory.newAdvertisement(xml); |
static Advertisement |
newAdvertisement(String advertisementType)
Constructs a new instance of Advertisement matching the type
specified by the advertisementType parameter. |
static Advertisement |
newAdvertisement(TextElement root)
Deprecated. Advertisements must be encoded in XML. This is a legacy static constructor. You should convert your code to use the XMLElement
version. |
static Advertisement |
newAdvertisement(XMLElement root)
Reconstructs 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. |
Methods inherited from class net.jxta.util.ClassFactory |
---|
getAvailableKeys, getEntrySet, getInstantiator, registerAssoc, registerFromFile, registerFromResources, registerFromString, registerProviders |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
protected Map<String,AdvertisementFactory.Instantiator> getAssocTable()
getAssocTable
in class ClassFactory<String,AdvertisementFactory.Instantiator>
public Class<AdvertisementFactory.Instantiator> getClassOfInstantiators()
getClassOfInstantiators
in class ClassFactory<String,AdvertisementFactory.Instantiator>
public Class<String> getClassForKey()
getClassForKey
in class ClassFactory<String,AdvertisementFactory.Instantiator>
protected boolean registerAssoc(String className)
registerAssoc
in class ClassFactory<String,AdvertisementFactory.Instantiator>
className
- The class name which will be registered.
public static boolean registerAdvertisementInstance(String rootType, AdvertisementFactory.Instantiator instantiator)
rootType
- the identifying value for this advertisement instance
type.instantiator
- 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.@Deprecated public static Advertisement newAdvertisement(MimeMediaType mimetype, InputStream stream) throws IOException
XMLDocument
using StructuredDocumentFactory
and then call
newAdvertisement(XMLElement)
. For example :
XMLDocument xml = (XMLDocument) StructuredDocumentFactory.newStructuredDocument( MimeMediaType.XMLUTF8, is );or frequently:
XMLDocument xml = (XMLDocument) StructuredDocumentFactory.newStructuredDocument( msgElement );followed by:
Advertisement adv = AdvertisementFactory.newAdvertisement(xml);
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
- input 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.@Deprecated public static Advertisement newAdvertisement(MimeMediaType mimetype, Reader source) throws IOException
XMLDocument
using StructuredDocumentFactory
and then call
newAdvertisement(XMLElement)
. For example :
XMLDocument xml = (XMLDocument) StructuredDocumentFactory.newStructuredDocument( MimeMediaType.XMLUTF8, reader );or frequently:
XMLDocument xml = (XMLDocument) StructuredDocumentFactory.newStructuredDocument( msgElement );followed by:
Advertisement adv = AdvertisementFactory.newAdvertisement(xml);
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.@Deprecated public static Advertisement newAdvertisement(TextElement root)
XMLElement
version.
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.public static Advertisement newAdvertisement(XMLElement root)
Advertisement
matching the type
specified by the root
parameter.
root
- Specifies a portion of an XMLElement which will be
converted into an Advertisement.
Advertisement
.
NoSuchElementException
- if there is no advertisement type
matching the type of the root node.
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |