Methods Summary |
---|
public boolean | containsData()Queries whether the LinkMessage contains data, that is, a byte array.
return contents instanceof byte[];
|
public boolean | containsLink()Queries whether the LinkMessage contains a Link.
return contents instanceof Link;
|
public boolean | containsString()Queries whether the LinkMessage contains a String.
return contents instanceof String;
|
public java.lang.Object | extract()Returns the contents of the LinkMessage as an Object. The caller must
test the reference returned using instanceof and cast it
appropriately.
return contents;
|
public byte[] | extractData()Returns the contents of the LinkMessage if it contains a byte array. If
the message does not contain a byte array, throws IllegalStateException.
if (! (contents instanceof byte[])) {
throw new IllegalStateException();
}
byte[] data = (byte[])contents;
if (offset == 0 && length == data.length) {
return data;
}
// need to copy the subrange
byte[] newData = new byte[length];
System.arraycopy(data, offset, newData, 0, length);
return newData;
|
public Link | extractLink()Returns the contents of the LinkMessage if it contains is a Link. If
the message does not contain a Link, throws IllegalStateException.
if (contents instanceof Link) {
return (Link)contents;
} else {
throw new IllegalStateException();
}
|
public java.lang.String | extractString()Returns the contents of the LinkMessage if it contains is a String. If
the message does not contain a String, throws IllegalStateException.
if (contents instanceof String) {
return (String)contents;
} else {
throw new IllegalStateException();
}
|
public static com.sun.midp.links.LinkMessage | newDataMessage(byte[] data)
return new LinkMessage(data, 0, data.length);
|
public static com.sun.midp.links.LinkMessage | newDataMessage(byte[] data, int offset, int length)
if (offset < 0
|| offset > data.length
|| length < 0
|| offset + length < 0
|| offset + length > data.length) {
throw new IndexOutOfBoundsException();
}
return new LinkMessage(data, offset, length);
|
public static com.sun.midp.links.LinkMessage | newLinkMessage(Link link)
return new LinkMessage(link, 0, 0);
|
public static com.sun.midp.links.LinkMessage | newStringMessage(java.lang.String string)
return new LinkMessage(string, 0, 0);
|