|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.livetribe.slp.Attributes
public class Attributes
Attributes are key-value pairs that describe a service.
The attribute key is called tag, and the attribute value can be non-valued (the tag as no value),
single-valued (the tag as only one value) or multi-valued (the tag has more values).
Depending on the value(s) of the tag, the attribute has a type; there are four defined types:
Attribute values should be homogeneous: the attribute a=1,true,\FF\00
is illegal, because it's not
clear if the type is long, boolean, or opaque.
Attributes can be used by UserAgents during service lookup to select appropriate services that match required
conditions.
Attributes can be described using a string representation, for example:
String attributesString = "(a=1,2),(b=true),(bytes=\FF\CA\FE\BA\BE),(present),(description=Something Interesting)";
Attributes attributes = new Attributes(attributesString);
The example defines 5 attributes:
Nested Class Summary | |
---|---|
static class |
Attributes.Entry
Represent the attribute value within the Attributes class. |
Constructor Summary | |
---|---|
Attributes()
Creates an empty Attributes object. |
|
Attributes(String attributeList)
Creates an Attributes object parsing the given attributeList string. |
Method Summary | |
---|---|
String |
asString()
Returns a string representation of this Attributes object, that can be passed to
Attributes(String) to be parsed. |
static String |
bytesToOpaque(byte[] bytes)
Returns an opaque string containing the escaped sequence of the given bytes, including the initial opaque prefix \FF. |
boolean |
equals(Object obj)
|
Attributes.Entry |
getEntry(String tag)
Returns the Entry for the given tag. |
Object |
getValue(String tag)
Returns the value for the given tag. |
Object[] |
getValues(String tag)
Returns the values for the given tag. |
int |
hashCode()
|
boolean |
isEmpty()
Returns true if this Attributes object is empty. |
boolean |
isTagPresent(String tag)
Returns true if the given tag is present in this Attributes object. |
Attributes |
merge(Attributes that)
Merges the attributes of this Attributes object with the attributes of the given Attributes
object into a new Attributes object. |
static byte[] |
opaqueToBytes(String opaqueString)
Returns a byte array containing the bytes parsed from the given opaque string, except the initial opaque prefix \FF. |
void |
put(String tag)
Puts a presence tag. |
void |
put(String tag,
String value)
Puts a tag with the specified value. |
void |
put(String tag,
String[] values)
Puts a tag with the specified values |
String |
toString()
|
Attributes |
unmerge(Attributes that)
Unmerges the attributes of this Attributes object with the attributes of the given Attributes
object into a new Attributes object. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Attributes()
Attributes
object.
public Attributes(String attributeList) throws ServiceLocationException
Attributes
object parsing the given attributeList
string.
attributeList
- The string containing the attributes to parse
ServiceLocationException
- If the parsing failsMethod Detail |
---|
public void put(String tag)
tag
- The tag to addpublic void put(String tag, String value)
tag
- The tag to addvalue
- The value of the tagpublic void put(String tag, String[] values) throws ServiceLocationException
tag
- The tag to addvalues
- The values of the tag
ServiceLocationException
- If the values are not of the same typepublic Attributes.Entry getEntry(String tag)
Entry
for the given tag.
public Object getValue(String tag)
isTagPresent(String)
,
getValues(String)
public Object[] getValues(String tag)
isTagPresent(String)
,
getValue(String)
public boolean isEmpty()
Attributes
object is empty.
public boolean isTagPresent(String tag)
Attributes
object.
Attributes.Entry.isPresenceType()
public static byte[] opaqueToBytes(String opaqueString) throws ServiceLocationException
opaqueString
- The opaque string containing the bytes to parse
ServiceLocationException
- If the parsing failsbytesToOpaque(byte[])
public static String bytesToOpaque(byte[] bytes)
bytes
- The bytes to escape into an opaque stringopaqueToBytes(String)
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String asString()
Attributes
object, that can be passed to
Attributes(String)
to be parsed.
public String toString()
toString
in class Object
asString()
public Attributes merge(Attributes that)
Attributes
object with the attributes of the given Attributes
object into a new Attributes
object.
If the given Attributes
is null, a clone of this Attributes
object will be returned.
If this Attributes
contains a tag that exists in the given Attributes
, the merged
Attributes
will contain the entry from the given Attributes
object (overwriting the one
from this Attributes
object).
that
- The Attributes
to merge with
Attributes
object containing the merged attributes.public Attributes unmerge(Attributes that)
Attributes
object with the attributes of the given Attributes
object into a new Attributes
object.
If the given Attributes
is null, a clone of this Attributes
object will be returned.
The unmerged Attributes
will contain only the attributes present in this Attributes
object
but not in the given Attributes
object.
that
- The Attributes
to unmerge with
Attributes
object containing the unmerged attributes.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |