Project JXTA

net.jxta.endpoint
Class MessageElement

java.lang.Object
  |
  +--net.jxta.endpoint.MessageElement

public abstract class MessageElement
extends java.lang.Object

This abstract class defines the Message Element.

See Also:
Message

Constructor Summary
MessageElement()
           
 
Method Summary
abstract  java.lang.Object clone()
          make a clone of this element.
abstract  boolean equals(java.lang.Object target)
          Compare this MessageElement against another.
abstract  byte[] getBytesOffset()
          Returns the byte array which contains the element data.
abstract  int getLength()
          Returns the number of bytes used in the array returned by getBytes().
abstract  java.lang.String getName()
          Returns the name of the MessageElement.
abstract  int getOffset()
          Returns the offset into the array returned by getBytes() of where data use by this element starts.
abstract  java.io.InputStream getStream()
          Returns a stream containing the element data.
abstract  MimeMediaType getType()
          Returns the type of the MessageElement.
static java.lang.String[] parseName(java.lang.String name)
          Parse a name in to its two colon separated components.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageElement

public MessageElement()
Method Detail

getOffset

public abstract int getOffset()
Returns the offset into the array returned by getBytes() of where data use by this element starts.
Returns:
int the offset.

getLength

public abstract int getLength()
Returns the number of bytes used in the array returned by getBytes(). This may or may not be the entire length of the array returned by getBytes().

post:
0 <= getLength() <= getBytes().length

Returns:
int the number of bytes of the element data.
Since:
JXTA 1.0

getBytesOffset

public abstract byte[] getBytesOffset()
Returns the byte array which contains the element data. The portion of the array which is used as the element data starts at getOffset() and continues up to but not including the byte at getOffset()+getLength().

The byte array returned is not a copy of the element content.

Returns:
byte[] Contents of message element.

getStream

public abstract java.io.InputStream getStream()
Returns a stream containing the element data. This stream contains the segment of bytes in the array returned by getBytes() from getOffset() to getOffset() + getLength()-1;
Returns:
InputStream of the stream containing element data.
Since:
JXTA 1.0

getName

public abstract java.lang.String getName()
Returns the name of the MessageElement.
Returns:
String containing the name of the MessageElement.
Since:
JXTA 1.0

getType

public abstract MimeMediaType getType()
Returns the type of the MessageElement.
Returns:
MimeMediaType containing a copy of the type of the element. Will return "Application/Octet-Stream" if no type was originally specified.
Since:
JXTA 1.0

clone

public abstract java.lang.Object clone()
make a clone of this element. Since element are immutable, this returns the same object.
Overrides:
clone in class java.lang.Object
Returns:
Object a copy of the MessageElement.
Since:
JXTA 1.0

equals

public abstract boolean equals(java.lang.Object target)
Compare this MessageElement against another. They are equal if the namespace, name, type, data are equal.
Overrides:
equals in class java.lang.Object
Parameters:
target - The to compare against.
Returns:
boolean true if the elements are identical.
Since:
JXTA 1.0

parseName

public static java.lang.String[] parseName(java.lang.String name)
Parse a name in to its two colon separated components. The namespace is to the left of the colon. The simple name is to the right of the colon. If no colon is present The namespace is the empty namespace, and the simple name is the same as the name arg.

parseName returns an arrary of String defined as follow:

String[0] contains the namespace.
String[1] contains the simple name.

Parameters:
name - is the name to parse.
Returns:
String[] the array of String containing the name space and the simple name.

Project JXTA