Project JXTA

net.jxta.document
Class AdvertisementFactory

java.lang.Object
  |
  +--net.jxta.util.ClassFactory
        |
        +--net.jxta.document.AdvertisementFactory

public class AdvertisementFactory
extends ClassFactory

This class is a class factory for Advertisements. The class enables to hide the implementation used to represent and create advertisements.

Advertisements are core objects that are used to advertise a Peer, a PeerGroup, a Service, or a PipeService. 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.

Since:
JXTA 1.0
See Also:
Advertisement, Document, MimeMediaType, PeerGroup, PeerAdvertisement, PeerGroupAdvertisement, PipeAdvertisement

Constructor Summary
AdvertisementFactory()
           
 
Method Summary
protected  java.util.Hashtable getAssocTable()
          Used by ClassFactory methods to get the mapping of Mime Types to constructors.
protected  java.lang.Class getBaseClassForFactory()
          Used by ClassFactory methods to ensure that all of the instance classes which register with this factory have the correct base class
protected  java.lang.Class getClassForKey()
          Used by ClassFactory methods to ensure that all keys used with the mapping are of the correct type.
protected  java.lang.Class[][] getRequiredConstructors()
          Used by ClassFactory methods to determine the required set of constructors needed by the instance classes generated by this factory.
protected  java.lang.Object[][] getRequiredStaticMethods()
          Used by ClassFactory methods to determine the required set of static methods needed by classes registering with this factory.
static Advertisement newAdvertisement(MimeMediaType mimetype, java.io.InputStream stream)
          Constructs an instance of Advertisement matching the type specified by the advertisementType parameter.
static Advertisement newAdvertisement(MimeMediaType mimetype, java.io.InputStream stream, long timeout)
          Constructs an instance of Advertisement matching the type specified by the advertisementType parameter.
static Advertisement newAdvertisement(java.lang.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 advertisementType parameter.
static Advertisement newAdvertisement(TextElement root, long timeout)
          Constructs an instance of Advertisement matching the type specified by the advertisementType parameter.
static boolean registerAdvertisementInstance(java.lang.String rootType, java.lang.Class instanceClass)
          Register an array of constructor for an ID type to enable IDs of that type to be constructed.
protected  boolean registerAssoc(java.lang.String className)
          Register a class with the factory from its class name.
 
Methods inherited from class net.jxta.util.ClassFactory
callStaticMethod, newInstance, registerAssoc, registerFromResources, registerFromString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdvertisementFactory

public AdvertisementFactory()
Method Detail

getAssocTable

protected java.util.Hashtable getAssocTable()
Used by ClassFactory methods to get the mapping of Mime Types to constructors.
Overrides:
getAssocTable in class ClassFactory
Returns:
the hashtable containing the mappings.

getBaseClassForFactory

protected java.lang.Class getBaseClassForFactory()
Used by ClassFactory methods to ensure that all of the instance classes which register with this factory have the correct base class
Overrides:
getBaseClassForFactory in class ClassFactory
Returns:
Class object of the key type.

getClassForKey

protected java.lang.Class getClassForKey()
Used by ClassFactory methods to ensure that all keys used with the mapping are of the correct type.
Overrides:
getClassForKey in class ClassFactory
Returns:
Class object of the key type.

getRequiredConstructors

protected java.lang.Class[][] getRequiredConstructors()
Used by ClassFactory methods to determine the required set of constructors needed by the instance classes generated by this factory.
Overrides:
getRequiredConstructors in class ClassFactory
Returns:
Class object of the key type.

getRequiredStaticMethods

protected java.lang.Object[][] getRequiredStaticMethods()
Used by ClassFactory methods to determine the required set of static methods needed by classes registering with this factory.
Overrides:
getRequiredStaticMethods in class ClassFactory
Returns:
Object
Since:
JXTA 1.0

registerAssoc

protected boolean registerAssoc(java.lang.String className)
Register a class with the factory from its class name. We override the standard implementation to get the advertisement type from the class and use that as the key to register the class with the factory.
Overrides:
registerAssoc in class ClassFactory
Parameters:
className - The class name which will be regiestered.
Returns:
boolean true if the class was registered otherwise false.
Since:
JXTA 1.0

registerAdvertisementInstance

public static boolean registerAdvertisementInstance(java.lang.String rootType,
                                                    java.lang.Class instanceClass)
                                             throws java.lang.NoSuchMethodException,
                                                    java.lang.SecurityException
Register an array of constructor for an ID type to enable IDs of that type to be constructed.
Parameters:
rootType - the identifying value for this advertisement instance type
instanceClass - the constructors to use in constructing objects of this rootTypeIns type.
Returns:
boolean true if the rootType type is registered. If there is already a constructor for this type then false will be returned.
Throws:
java.lang.NoSuchMethodException - invalid registration
java.lang.SecurityException - security error
Since:
JXTA 1.0

newAdvertisement

public static Advertisement newAdvertisement(java.lang.String advertisementType)
                                      throws java.lang.reflect.InvocationTargetException
Constructs an instance of Advertisement matching the type specified by the advertisementType parameter.
Parameters:
advertisementType - Specifies the mime media type to be associated with the StructuredDocument to be created.
Returns:
The instance of Advertisement or null if it could not be created.
Throws:
java.lang.reflect.InvocationTargetException - error invoking target constructor
Since:
JXTA 1.0

newAdvertisement

public static Advertisement newAdvertisement(MimeMediaType mimetype,
                                             java.io.InputStream stream)
                                      throws java.lang.reflect.InvocationTargetException
Constructs an instance of Advertisement matching the type specified by the advertisementType parameter.
Parameters:
mimetype - Specifies the mime media type to be associated with the StructuredDocument to be created.
stream - imput stream used to read data to construct the advertisement
Returns:
The instance of Advertisement or null if it could not be created.
Throws:
java.lang.reflect.InvocationTargetException - error invoking target constructor
Since:
JXTA 1.0

newAdvertisement

public static Advertisement newAdvertisement(MimeMediaType mimetype,
                                             java.io.InputStream stream,
                                             long timeout)
                                      throws java.lang.reflect.InvocationTargetException
Constructs an instance of Advertisement matching the type specified by the advertisementType parameter.
Parameters:
mimetype - Specifies the mime media type to be associated with the StructuredDocument to be created.
stream - imput stream used to read data to construct the advertisement
Returns:
The instance of Advertisement or null if it could not be created.
Throws:
java.lang.reflect.InvocationTargetException - error invoking target constructor
Since:
JXTA 1.0

newAdvertisement

public static Advertisement newAdvertisement(TextElement root)
                                      throws java.lang.reflect.InvocationTargetException
Constructs an instance of Advertisement matching the type specified by the advertisementType parameter.
Parameters:
root - Specifies a portion of a StructuredDocument which will be converted into an Advertisement.
Returns:
The instance of Advertisement or null if it could not be created.
Throws:
java.lang.reflect.InvocationTargetException - error invoking target constructor
Since:
JXTA 1.0

newAdvertisement

public static Advertisement newAdvertisement(TextElement root,
                                             long timeout)
                                      throws java.lang.reflect.InvocationTargetException
Constructs an instance of Advertisement matching the type specified by the advertisementType parameter.
Parameters:
root - Specifies a portion of a StructuredDocument which will be converted into an Advertisement.
Returns:
The instance of Advertisement or null if it could not be created.
Throws:
java.lang.reflect.InvocationTargetException - error invoking target constructor
Since:
JXTA 1.0

Project JXTA