p2pMapReduce.impl.networkModule.jxta
Class NodeAdvertisement

java.lang.Object
  extended by net.jxta.document.Advertisement
      extended by p2pMapReduce.impl.networkModule.jxta.NodeAdvertisement
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<NodeAdvertisement>

public class NodeAdvertisement
extends net.jxta.document.Advertisement
implements java.lang.Comparable<NodeAdvertisement>, java.lang.Cloneable, java.io.Serializable

Create a advertisement totally describing a node //TODO if possible make this Advertisement to handle generic properties like a Properties object, and implementing Externalizable to serialize all key,value pairs

See Also:
Serialized Form

Nested Class Summary
static class NodeAdvertisement.Instantiator
          Instantiator
 
Field Summary
static java.lang.String ADV_TYPE
           
static java.lang.String AVAILABLE_TAG
           
static java.lang.String FTP_PORT_TAG
           
static java.lang.String ID_TAG
           
static java.lang.String IP_ADDRESS_TAG
           
static java.lang.String LOAD_TAG
           
static java.lang.String PEER_ID_TAG
           
static java.lang.String PIPE_ID_TAG
           
static java.lang.String PREFIX
           
static java.lang.String ROLE_TAG
           
static java.lang.String TYPE_TAG
           
static java.lang.String VERSION_TAG
           
 
Fields inherited from class net.jxta.document.Advertisement
authenticated, xmlSignature, xmlSignatureElement, xmlSignatureInfoElement
 
Constructor Summary
NodeAdvertisement()
          Default Constructor
NodeAdvertisement(net.jxta.document.Element root)
          Construct from a StructuredDocument
NodeAdvertisement(net.jxta.id.ID id)
           
NodeAdvertisement(java.io.InputStream stream)
          Construct a doc from InputStream
NodeAdvertisement(NodeAdvertisement nodeADV)
           
 
Method Summary
 NodeAdvertisement clone()
           
 int compareTo(NodeAdvertisement other)
           
 boolean equals(java.lang.Object obj)
          Equals if same ID and same version
static java.lang.String getAdvertisementType()
          All messages have a type (in xml this is !doctype) which identifies the message
 java.lang.String getAdvType()
           
 net.jxta.document.Document getDocument(net.jxta.document.MimeMediaType asMimeType)
          
 int getFtpPort()
           
 net.jxta.id.ID getID()
          returns the id of the device
 java.lang.String[] getIndexFields()
          
 java.lang.String getIpAddress()
           
 double getLoad()
           
 java.lang.String getPeerID()
           
 java.lang.String getPipeID()
           
 int getRole()
           
 long getVersion()
           
protected  boolean handleElement(net.jxta.document.TextElement elem)
          Process an individual element from the document.
 int hashCode()
           
 void incrVersion()
          Utility method to increment version number
protected  void initialize(net.jxta.document.Element root)
          Initialize a System advertisement from a portion of a structured document.
 boolean isAvailable()
           
 void setAvailable(boolean available)
           
 void setFtpPort(int ftpPort)
           
 void setID(net.jxta.id.ID id)
          sets the unique id
 void setIpAddress(java.lang.String ipAddress)
           
 void setLoad(double load)
           
 void setPeerID(java.lang.String peerID)
           
 void setPipeID(java.lang.String pipeID)
           
 void setRole(int role)
           
 void setVersion(long version)
           
 
Methods inherited from class net.jxta.document.Advertisement
getSignature, getSignedDocument, isAuthenticated, isCorrectMembershipKey, isMember, sign, toString, verify
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ADV_TYPE

public static final java.lang.String ADV_TYPE
See Also:
Constant Field Values

PREFIX

public static final java.lang.String PREFIX
See Also:
Constant Field Values

ID_TAG

public static final java.lang.String ID_TAG
See Also:
Constant Field Values

VERSION_TAG

public static final java.lang.String VERSION_TAG
See Also:
Constant Field Values

AVAILABLE_TAG

public static final java.lang.String AVAILABLE_TAG
See Also:
Constant Field Values

TYPE_TAG

public static final java.lang.String TYPE_TAG
See Also:
Constant Field Values

ROLE_TAG

public static final java.lang.String ROLE_TAG
See Also:
Constant Field Values

LOAD_TAG

public static final java.lang.String LOAD_TAG
See Also:
Constant Field Values

PEER_ID_TAG

public static final java.lang.String PEER_ID_TAG
See Also:
Constant Field Values

PIPE_ID_TAG

public static final java.lang.String PIPE_ID_TAG
See Also:
Constant Field Values

IP_ADDRESS_TAG

public static final java.lang.String IP_ADDRESS_TAG
See Also:
Constant Field Values

FTP_PORT_TAG

public static final java.lang.String FTP_PORT_TAG
See Also:
Constant Field Values
Constructor Detail

NodeAdvertisement

public NodeAdvertisement()
Default Constructor


NodeAdvertisement

public NodeAdvertisement(NodeAdvertisement nodeADV)

NodeAdvertisement

public NodeAdvertisement(net.jxta.id.ID id)

NodeAdvertisement

public NodeAdvertisement(net.jxta.document.Element root)
Construct from a StructuredDocument

Parameters:
root - Root element

NodeAdvertisement

public NodeAdvertisement(java.io.InputStream stream)
                  throws java.io.IOException
Construct a doc from InputStream

Parameters:
stream - the underlying input stream.
Throws:
java.io.IOException - if an I/O error occurs.
Method Detail

getDocument

public net.jxta.document.Document getDocument(net.jxta.document.MimeMediaType asMimeType)

Specified by:
getDocument in class net.jxta.document.Advertisement
Parameters:
asMimeType - Document encoding
Returns:
The document value

getID

public net.jxta.id.ID getID()
returns the id of the device

Specified by:
getID in class net.jxta.document.Advertisement
Returns:
ID the device id

setID

public void setID(net.jxta.id.ID id)
sets the unique id

Parameters:
id - The id

getVersion

public long getVersion()

setVersion

public void setVersion(long version)

isAvailable

public boolean isAvailable()

setAvailable

public void setAvailable(boolean available)

getLoad

public double getLoad()

setLoad

public void setLoad(double load)

getRole

public int getRole()

setRole

public void setRole(int role)

getPeerID

public java.lang.String getPeerID()

setPeerID

public void setPeerID(java.lang.String peerID)

getPipeID

public java.lang.String getPipeID()

setPipeID

public void setPipeID(java.lang.String pipeID)

getFtpPort

public int getFtpPort()

setFtpPort

public void setFtpPort(int ftpPort)

getIpAddress

public java.lang.String getIpAddress()

setIpAddress

public void setIpAddress(java.lang.String ipAddress)

handleElement

protected boolean handleElement(net.jxta.document.TextElement elem)
Process an individual element from the document.

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

initialize

protected void initialize(net.jxta.document.Element root)
Initialize a System advertisement from a portion of a structured document.

Parameters:
root - document root

getIndexFields

public final java.lang.String[] getIndexFields()

Specified by:
getIndexFields in class net.jxta.document.Advertisement

equals

public boolean equals(java.lang.Object obj)
Equals if same ID and same version

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(NodeAdvertisement other)
Specified by:
compareTo in interface java.lang.Comparable<NodeAdvertisement>

clone

public NodeAdvertisement clone()
                        throws java.lang.CloneNotSupportedException
Overrides:
clone in class net.jxta.document.Advertisement
Throws:
java.lang.CloneNotSupportedException

getAdvertisementType

public static java.lang.String getAdvertisementType()
All messages have a type (in xml this is !doctype) which identifies the message

Returns:
String "jxta:NodeAdvertisement"

getAdvType

public java.lang.String getAdvType()
Overrides:
getAdvType in class net.jxta.document.Advertisement

incrVersion

public void incrVersion()
Utility method to increment version number