|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@PublicService public interface AttributeService
This provides services for reading, writing, and querying global attributes.
Attributes are organized hierarchically. Each segment within the hierarchy is referred to as a "key". Keys are indexed so that they may be queried efficiently. Because databases may impose length restrictions on index of primary keys, you are strongly advised to keep "large" strings in values, not keys. For example, http://dev.mysql.com/tech-resources/crash-me.php reports that the index length limit of MySQL-4.1.1pre InnoDB is 1024, bytes. Assuming keys are stored in UTF8, this means keys should be no longer 170 chars (170*6 + 1 = 1020 < 1024).
When an attribute within the hierarchy is represented as a "path", the set of keys used to reach it is concatenated using the '/' character. Thus, "a/b/c" refers to attribute "c" within "b" within "a". This "path" notation is merely a convenience; if you prefer, lower-level functions can also be used that allow you to supply the list of keys directly. If you need to create a "path" that includes a key with an embedded '/' character, you must escape it with '\' (e.g.: "silly\/example"). No such restriction applies when you use an API that accepts a list of keys directly.
Lookups for attributes never attempt to search any other leaf key (final path segment) than the one specified function call. Thus, if you have an attribute named "egg", but no attribute named "hen/egg", a lookup for "egg" will suceed, but a lookup for "hen/egg" will fail (i.e.: it will return null).
Method Summary | |
---|---|
void |
addAttribute(java.util.List keys,
Attribute value)
Add an attribute to a list. |
void |
addAttribute(java.lang.String path,
Attribute value)
Add an attribute to a list. |
void |
addAttributes(java.util.List keys,
java.util.List values)
Add a list of attributes to the end of a list. |
void |
addAttributes(java.lang.String path,
java.util.List values)
Add a list of attributes to the end of a list. |
boolean |
exists(java.util.List keys)
Does an attribute exist. |
boolean |
exists(java.lang.String path)
Does an attribute exist. |
Attribute |
getAttribute(java.util.List keys)
Get an attribute using a list of keys. |
Attribute |
getAttribute(java.lang.String path)
Get an Attribute using a path. |
int |
getCount(java.util.List keys)
Get the size of a map or list. |
int |
getCount(java.lang.String path)
Get the size of a map or list. |
java.util.List |
getKeys(java.util.List keys)
Get all the keys at a given attribute path as specified by a list of path components. |
java.util.List |
getKeys(java.lang.String path)
Get all the keys at a given attribute path. |
java.util.List |
query(java.util.List keys,
AttrQuery query)
Query for a list of attributes which are contained in a map defined by the given path and meet the query criteria. |
java.util.List |
query(java.lang.String path,
AttrQuery query)
Query for the list of attributes that is contained in the map defined by the given path and meet the query criteria. |
void |
removeAttribute(java.util.List keys,
int index)
Remove an attribute from a list. |
void |
removeAttribute(java.util.List keys,
java.lang.String name)
Remove an Attribute. |
void |
removeAttribute(java.lang.String path,
int index)
Remove an attribute from a list. |
void |
removeAttribute(java.lang.String path,
java.lang.String name)
Remove an Attribute. |
void |
removeEntries(java.util.List keys,
AttrQuery query)
Remove entries from the designated map which match the given query. |
void |
removeEntries(java.lang.String path,
AttrQuery query)
Remove entries from the designated map which match the given query. |
void |
setAttribute(java.util.List keys,
int index,
Attribute value)
Set an attribute in a list. |
void |
setAttribute(java.util.List keys,
java.lang.String name,
Attribute value)
Set an attribute, overwriting its prior value if it already existed. |
void |
setAttribute(java.lang.String path,
int index,
Attribute value)
Set an attribute in a list. |
void |
setAttribute(java.lang.String path,
java.lang.String name,
Attribute value)
Set an attribute, overwriting its prior value if it already existed. |
void |
setAttributes(java.util.List keys,
java.util.Map entries)
Set a set of attributes on a map. |
void |
setAttributes(java.lang.String path,
java.util.Map entries)
Set a set of attributes on a map. |
Method Detail |
---|
Attribute getAttribute(java.lang.String path)
path
- The path of the Attribute
Attribute getAttribute(java.util.List keys)
keys
- List of attribute path keys (path components).
void setAttribute(java.lang.String path, java.lang.String name, Attribute value)
name
- The name of the Attribute.value
- The value to set.void setAttribute(java.util.List keys, java.lang.String name, Attribute value)
keys
- List of attribute path keys (path components).name
- The name of the attribute to set.value
- The Attribute to set.void setAttributes(java.lang.String path, java.util.Map entries)
path
- The path to the map.entries
- The entries to set.void setAttributes(java.util.List keys, java.util.Map entries)
keys
- The List of path keys to the map.entries
- The entries to set.void setAttribute(java.lang.String path, int index, Attribute value)
path
- The path to the ListAttribute
.index
- The list index.value
- The Attribute to set.void setAttribute(java.util.List keys, int index, Attribute value)
keys
- List of attribute path keys (path components).index
- The list index.value
- The Attribute to set within the ListAttribute
void addAttribute(java.lang.String path, Attribute value)
path
- The path to the list.value
- The Attribute to add to the ListAttribute
void addAttribute(java.util.List keys, Attribute value)
keys
- List of attribute path keys (path components).value
- The Attribute to add to the ListAttribute
void addAttributes(java.lang.String path, java.util.List values)
path
- The path to the list.values
- The values to add.void addAttributes(java.util.List keys, java.util.List values)
keys
- The List of path keys to the list.values
- The values to add.void removeAttribute(java.lang.String path, java.lang.String name)
name
- The name of the Attribute.void removeAttribute(java.util.List keys, java.lang.String name)
keys
- List of attribute path keys (path components).name
- The name of the attribute to remove.void removeAttribute(java.lang.String path, int index)
path
- The path to the list.index
- The index to remove from the
ListAttribute
void removeAttribute(java.util.List keys, int index)
keys
- List of attribute path keys (path components).index
- The index to remove from the
ListAttribute
void removeEntries(java.util.List keys, AttrQuery query)
keys
- The list of attribute path entries.query
- The attribute query.void removeEntries(java.lang.String path, AttrQuery query)
path
- The path to the map.query
- The attribute query.java.util.List query(java.lang.String path, AttrQuery query)
Example 1:
Find all attributes within the nested namespace "a/b"
that are lexically greater than or equal to the string "v":
query("a/b", new AttrQueryGTE("v"))
Example 2:
Find all attributes within the namespace "xyz" that are
either lexically less than the string "d" or greater than
the string "w":
query("xyz", new AttrOrQuery(new AttrQueryLT("d"), new AttrQueryGT("w")))
path
- query
-
java.util.List query(java.util.List keys, AttrQuery query)
keys
- List of attribute path keys (path components).query
-
java.util.List getKeys(java.lang.String path)
setAttribute
has associated a path with a
MAP
, you can fetch the
keys for that map via this function.
Example:
Suppose AttribSvc
is an attribute service object:
MapAttribute x = new MapAttributeValue(); x.put("cow", new StringAttributeValue("moo"); x.put("bird", new StringAttributeValue("tweet"); MapAttribute y = new MapAttributeValue(); y.put("pekingese", new StringAttributeValue("yip-yip-yip"); y.put("blood hound", new StringAttributeValue("Aroooooooooooo"); y.put("labrador", new StringAttributeValue("Hello, kind stranger!"); AttribSvc.setAttribute("", "x", x); AttribSvc.setAttribute("x", "y", y); List<String> x_keys = AttribSvc.getKeys("x"); // cow, bird List<String> y_keys = AttribSvc.getKeys("x/y"); // pekingese, blood hound, labrador
path
- The attribute path.
java.util.List getKeys(java.util.List keys)
keys
- List of attribute path keys (path components).
int getCount(java.util.List keys)
keys
- List of attribute path keys.
int getCount(java.lang.String path)
path
- The path to the map or list.
boolean exists(java.util.List keys)
keys
- List of attribute path keys.
boolean exists(java.lang.String path)
path
- The path to the attribute.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |