Project JXTA

net.jxta.document
Class ExtendableAdvertisement

java.lang.Object
  extended bynet.jxta.document.Advertisement
      extended bynet.jxta.document.ExtendableAdvertisement
Direct Known Subclasses:
AccessPointAdvertisement, ConfigParams, ModuleClassAdvertisement, ModuleImplAdvertisement, ModuleSpecAdvertisement, PeerAdvertisement, PeerGroupAdvertisement, PipeAdvertisement, RdvAdvertisement, RouteAdvertisement, SignedAdvertisement, TransportAdvertisement

public abstract class ExtendableAdvertisement
extends Advertisement

Extendable advertisements provide features for allowing inheritance of advertisement types. The core and standard JXTA advertisements all allow extension by extending this class.

See Also:
Advertisement, AdvertisementFactory, Document, MimeMediaType

Constructor Summary
ExtendableAdvertisement()
           
 
Method Summary
abstract  String getBaseAdvType()
          Returns the base type of this advertisement hierarchy.
 Document getDocument(MimeMediaType encodeAs)
          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 a "pretty-print" format for human viewing and "text/xml" which provides an XML format.

We don't have any content to add, just build the document instance and return it to implementations that actually do something with it.

protected  boolean handleElement(Element elem)
          Process an individual element from the document during parse.
 
Methods inherited from class net.jxta.document.Advertisement
clone, getAdvertisementType, getAdvType, getID, getIndexFields, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExtendableAdvertisement

public ExtendableAdvertisement()
Method Detail

getBaseAdvType

public abstract String getBaseAdvType()
Returns the base type of this advertisement hierarchy. Typically, only the most basic advertisement of a type will implement this method and declare it as final.

Returns:
String the base type of advertisements in this hierarchy.

handleElement

protected boolean handleElement(Element elem)
Process an individual element from the document during parse. Normally, implementations will allow the base advertisments a chance to handle the element before attempting ot handle the element themselves. ie.


  protected boolean handleElement( Element elem ) {

      if ( super.handleElement() ) {
           // it's been handled.
           return true;
           }

      ... handle elements here ...

      // we don't know how to handle the element
      return false;
      }
  

Parameters:
elem - the element to be processed.
Returns:
true if the element was recognized, otherwise false.

getDocument

public Document getDocument(MimeMediaType encodeAs)
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 a "pretty-print" format for human viewing and "text/xml" which provides an XML format.

We don't have any content to add, just build the document instance and return it to implementations that actually do something with it.

Specified by:
getDocument in class Advertisement
Parameters:
encodeAs - MimeMediaType format representation requested
Returns:
Document the document to be used in the construction

JXTA J2SE