Project JXTA

net.jxta.document
Class Advertisement

java.lang.Object
  |
  +--net.jxta.document.Advertisement
Direct Known Subclasses:
EndpointAdvertisement, PeerGroupAdvertisement, PeerInfoAdvertisement, PipeAdvertisement, RdvAdvertisement, ServiceAdvertisement, TransportAdvertisement

public abstract class Advertisement
extends java.lang.Object

This abstract class defines an advertisement. Advertisements are core JXTA objects that are used to advertise a Peer, a PeerGroup, a Service, or a PipeService. Advertisements provide a platform independent representation of a core platform objects that can be exchanged between different platform implementations (Java, C).

Each advertisement holds a document that represents the advertisement. Advertisements are typically represented as a text document (XML). The getDocument method of the class enables to get a representation of the advertisement into different format via the requested MimeMediaType. Typical mime types are "text/xml" or "txt/plain" that generate different text representations for the document.

Advertisements are created via an advertisement factory to hide their implementation.

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

Constructor Summary
Advertisement()
           
 
Method Summary
static java.lang.String getAdvertisementType()
          Returns the identifying type of this Advertisement.
abstract  Document getDocument(MimeMediaType asMimeType)
          Write advertisement into a document.
 long getLocalExpirationTime()
           
 void setExpiration(long timeout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Advertisement

public Advertisement()
Method Detail

getLocalExpirationTime

public long getLocalExpirationTime()

setExpiration

public void setExpiration(long timeout)

getAdvertisementType

public static java.lang.String getAdvertisementType()
Returns the identifying type of this Advertisement.
Returns:
String the type of advertisement
Since:
JXTA 1.0

getDocument

public abstract Document getDocument(MimeMediaType asMimeType)
                              throws java.lang.IllegalStateException,
                                     java.lang.Exception
Write advertisement into a document. asMimeType is a mime media-type specification and provides the form of the document which is being requested. Two standard document forms are defined. "text/plain" encodes the document in "pretty-print" format for human viewing and "text/xml" which provides an XML format.
Parameters:
asMimeType - MimeMediaType format representation requested
Returns:
Document the document to be used in the construction
Throws:
java.lang.IllegalStateException - the Advertisement cannot be converted to a document because it is incomplete
java.lang.Exception - error generating the document
Since:
JXTA 1.0

Project JXTA