/* * Copyright (C) 2005-2007 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * As a special exception to the terms and conditions of version 2.0 of * the GPL, you may redistribute this Program in connection with Free/Libre * and Open Source Software ("FLOSS") applications as described in Alfresco's * FLOSS exception. You should have received a copy of the text describing * the FLOSS exception, and it is also available here: * http://www.alfresco.com/legal/licensing" */ package org.alfresco.service.cmr.attributes; import java.util.List; import java.util.Map; import org.alfresco.repo.attributes.Attribute; import org.alfresco.util.Pair; /** * 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).  
 *
 * @author britt
 */
public interface AttributeService 
{
    /**
     * Get an Attribute using a path.
     *
     * @param path The path of the Attribute
     * @return The value of the attribute or null.
     */
    public Attribute getAttribute(String path);
    
    /**
     * Get an attribute using a list of keys.
     *
     * @param keys List of attribute path keys (path components).
     * @return The value of the attribute or null.
     */
    public Attribute getAttribute(List 
     * Example 1: 
     * Example 2: 
     * Example:
     * 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"))
     * 
     * 
     * 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")))
     * 
     *
     * @param path
     * @param query
     * @return A List of matching attributes.
     */
    public List
     * 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
     * 
     * 
     * @param path The attribute path.
     * @return A list of all keys.
     */
    public List