org.alfresco.service.cmr.attributes
Interface AttributeService

All Known Implementing Classes:
AttributeServiceImpl, AttributeServiceRemote

@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

getAttribute

Attribute getAttribute(java.lang.String path)
Get an Attribute using a path.

Parameters:
path - The path of the Attribute
Returns:
The value of the attribute or null.

getAttribute

Attribute getAttribute(java.util.List keys)
Get an attribute using a list of keys.

Parameters:
keys - List of attribute path keys (path components).
Returns:
The value of the attribute or null.

setAttribute

void setAttribute(java.lang.String path,
                  java.lang.String name,
                  Attribute value)
Set an attribute, overwriting its prior value if it already existed.

Parameters:
name - The name of the Attribute.
value - The value to set.

setAttribute

void setAttribute(java.util.List keys,
                  java.lang.String name,
                  Attribute value)
Set an attribute, overwriting its prior value if it already existed.

Parameters:
keys - List of attribute path keys (path components).
name - The name of the attribute to set.
value - The Attribute to set.

setAttributes

void setAttributes(java.lang.String path,
                   java.util.Map entries)
Set a set of attributes on a map.

Parameters:
path - The path to the map.
entries - The entries to set.

setAttributes

void setAttributes(java.util.List keys,
                   java.util.Map entries)
Set a set of attributes on a map.

Parameters:
keys - The List of path keys to the map.
entries - The entries to set.

setAttribute

void setAttribute(java.lang.String path,
                  int index,
                  Attribute value)
Set an attribute in a list.

Parameters:
path - The path to the ListAttribute.
index - The list index.
value - The Attribute to set.

setAttribute

void setAttribute(java.util.List keys,
                  int index,
                  Attribute value)
Set an attribute in a list.

Parameters:
keys - List of attribute path keys (path components).
index - The list index.
value - The Attribute to set within the ListAttribute

addAttribute

void addAttribute(java.lang.String path,
                  Attribute value)
Add an attribute to a list.

Parameters:
path - The path to the list.
value - The Attribute to add to the ListAttribute

addAttribute

void addAttribute(java.util.List keys,
                  Attribute value)
Add an attribute to a list.

Parameters:
keys - List of attribute path keys (path components).
value - The Attribute to add to the ListAttribute

addAttributes

void addAttributes(java.lang.String path,
                   java.util.List values)
Add a list of attributes to the end of a list.

Parameters:
path - The path to the list.
values - The values to add.

addAttributes

void addAttributes(java.util.List keys,
                   java.util.List values)
Add a list of attributes to the end of a list.

Parameters:
keys - The List of path keys to the list.
values - The values to add.

removeAttribute

void removeAttribute(java.lang.String path,
                     java.lang.String name)
Remove an Attribute.

Parameters:
name - The name of the Attribute.

removeAttribute

void removeAttribute(java.util.List keys,
                     java.lang.String name)
Remove an Attribute.

Parameters:
keys - List of attribute path keys (path components).
name - The name of the attribute to remove.

removeAttribute

void removeAttribute(java.lang.String path,
                     int index)
Remove an attribute from a list.

Parameters:
path - The path to the list.
index - The index to remove from the ListAttribute

removeAttribute

void removeAttribute(java.util.List keys,
                     int index)
Remove an attribute from a list.

Parameters:
keys - List of attribute path keys (path components).
index - The index to remove from the ListAttribute

removeEntries

void removeEntries(java.util.List keys,
                   AttrQuery query)
Remove entries from the designated map which match the given query.

Parameters:
keys - The list of attribute path entries.
query - The attribute query.

removeEntries

void removeEntries(java.lang.String path,
                   AttrQuery query)
Remove entries from the designated map which match the given query.

Parameters:
path - The path to the map.
query - The attribute query.

query

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.

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")))
 

Parameters:
path -
query -
Returns:
A List of matching attributes.

query

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.

Parameters:
keys - List of attribute path keys (path components).
query -
Returns:
A list of matching attributes.

getKeys

java.util.List getKeys(java.lang.String path)
Get all the keys at a given attribute path. When prior call to 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
 

Parameters:
path - The attribute path.
Returns:
A list of all keys.

getKeys

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.

Parameters:
keys - List of attribute path keys (path components).
Returns:
A list of all keys at the specified Attribute location

getCount

int getCount(java.util.List keys)
Get the size of a map or list.

Parameters:
keys - List of attribute path keys.
Returns:
The size of of the list or map.

getCount

int getCount(java.lang.String path)
Get the size of a map or list.

Parameters:
path - The path to the map or list.
Returns:
The size of the list or map.

exists

boolean exists(java.util.List keys)
Does an attribute exist.

Parameters:
keys - List of attribute path keys.
Returns:
Whether the attribute exists.

exists

boolean exists(java.lang.String path)
Does an attribute exist.

Parameters:
path - The path to the attribute.
Returns:
Whether the attribute exists.


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.