JXTA

net.jxta.document
Class ExtendableAdvertisement

java.lang.Object
  extended by net.jxta.document.Advertisement
      extended by net.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
protected ExtendableAdvertisement()
          Default constructor.
protected ExtendableAdvertisement(boolean formatted)
           
 
Method Summary
abstract  String getBaseAdvType()
          Returns the base type of this advertisement hierarchy.
 Document getDocument(MimeMediaType encodeAs)
          Write this advertisement into a document of the requested type.
protected  boolean handleAttribute(Attribute attrib)
          Process an individual attribute from the document root node.
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

protected ExtendableAdvertisement()
Default constructor. The advertisement will *not* be pretty-printed when it is output as XML.


ExtendableAdvertisement

protected ExtendableAdvertisement(boolean formatted)
Parameters:
formatted - If true then the advertisement will be pretty print formatted when it is output as XML.
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 advertisements a chance to handle the element before attempting to 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.

handleAttribute

protected boolean handleAttribute(Attribute attrib)
Process an individual attribute from the document root node. Normally, implementations will allow the base advertisements a chance to handle the attribute before attempting to handle the element themselves. ie.


  protected boolean handleAttribute( Attribute elem ) {
 

if (super.handleAttribute()) { // it's been handled. return true; } ... handle attributes here ... // we don't know how to handle the attribute return false; }

Parameters:
attrib - The attribute to be processed.
Returns:
true if the attribute was recognized, otherwise false.

getDocument

public Document getDocument(MimeMediaType encodeAs)
Write this advertisement into a document of the requested type. 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:
The Advertisement represented as a Document of the requested MIME Media Type.

JXSE