01: /*--------------------------------------------------------------------------*
02: | Copyright (C) 2006 Christopher Kohlhaas |
03: | |
04: | This program is free software; you can redistribute it and/or modify |
05: | it under the terms of the GNU General Public License as published by the |
06: | Free Software Foundation. A copy of the license has been included with |
07: | these distribution in the COPYING file, if not go to www.fsf.org |
08: | |
09: | As a special exception, you are granted the permissions to link this |
10: | program with every library, which license fulfills the Open Source |
11: | Definition as published by the Open Source Initiative (OSI). |
12: *--------------------------------------------------------------------------*/
13: package org.rapla.entities;
14:
15: import java.util.Locale;
16:
17: /** Hierarchical categorization of information.
18: * Categories can be used as attribute values.
19: * @see org.rapla.entities.dynamictype.Attribute
20: */
21: public interface Category extends MultiLanguageNamed, Entity,
22: RaplaObject, Annotatable {
23: final RaplaType TYPE = new RaplaType(Category.class, "category");
24:
25: /** add a sub-category.
26: * This category is set as parent of the passed category.*/
27: void addCategory(Category category);
28:
29: /** remove a sub-category */
30: void removeCategory(Category category);
31:
32: /** returns all subcategories */
33: Category[] getCategories();
34:
35: /** returns the subcategory with the specified key.
36: * null if subcategory was not found. */
37: Category getCategory(String key);
38:
39: /** find a sub-category in that equals the specified category. */
40: Category findCategory(Category copy);
41:
42: /** Returns the parent of this category or null if the category has no parent.*/
43: Category getParent();
44:
45: /** returns true if the passed category is a direct child of this category */
46: boolean hasCategory(Category category);
47:
48: /** set the key of the category. The can be used in the getCategory() method for lookup. */
49: void setKey(String key);
50:
51: /** returns the key of the category */
52: String getKey();
53:
54: /** returns true this category is an ancestor
55: * (parent or parent of parent, ...) of the specified
56: * category */
57: boolean isAncestorOf(Category category);
58:
59: /** returns the path form the rootCategory to this category.
60: * Path elements are the category-names in the selected locale separated
61: * with the / operator. If the rootCategory is null the path will be calculated
62: * to the top-most parent.
63: * Example: <strong>area51/aliencell</strong>
64: */
65: String getPath(Category rootCategory, Locale locale);
66:
67: /** returns the number of ancestors.
68: * (How many Time you must call getParent() until you receive null) */
69: int getDepth();
70:
71: Category[] CATEGORY_ARRAY = new Category[0];
72: }
|