Holger's
Java API

com.antelmann.db
Class Category.Adapter<T>

java.lang.Object
  extended by com.antelmann.db.Category.Adapter<T>
All Implemented Interfaces:
Category<T>, DetailedString, Serializable
Direct Known Subclasses:
MutableCategory.Adapter
Enclosing interface:
Category<T>

public static class Category.Adapter<T>
extends Object
implements Category<T>, DetailedString, Serializable

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.antelmann.db.Category
Category.Adapter<T>, Category.Entry
 
Constructor Summary
Category.Adapter(String name, Category<T> parent, Collection<? extends Category<T>> children)
           
 
Method Summary
static
<T> ArrayList<Category<T>>
addAllChildrenFrom(Category<T> category, T context, ArrayList<Category<T>> list)
          works recursively; does not include the given category itself
static void checkForCircularReferenceInParent(Category<?> category, Category<?> parent)
           
 boolean equals(Object obj)
           
static
<T> ArrayList<Category<T>>
getAllChildren(Category<T> category, T context)
          does not include the given category itself
 String getCategoryName()
          returns the name for this category
 Category<T> getParentCategory()
          returns the super category that this category belongs to - or null if it is a top-level category
static
<T> ArrayList<Category<T>>
getPath(Category<T> c)
           
static String getPathName(Category<?> c)
           
static String getPathName(Category<?> c, String separator)
           
 List<? extends Category<T>> getSubCategories(T context)
          the returned list by this implementation allows direct modifications; the context parameter is ignored and may be null
static Category<?> getTopCategory(Category<?> c)
           
 int hashCode()
           
static
<T> boolean
isParent(Category<T> parent, Category<T> child)
           
static
<T> Iterator<Category<T>>
iterate(Category<T> category, T context)
          iterates over all children recursively
static
<T> Iterator<Category<T>>
iterate(List<? extends Category<T>> categoryList, T context)
          iterates over the list itself and all children recursively
static
<T> List<Category<T>>
listAll(Collection<? extends Category<T>> topCategories, T context)
           
protected  void setCategoryName(String name)
           
 void setChildren(Collection<Category<T>> col)
           
protected  void setParentCategory(Category<T> parent)
           
 String toDetailedString()
          provides full details of this instance in a String.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Category.Adapter

public Category.Adapter(String name,
                        Category<T> parent,
                        Collection<? extends Category<T>> children)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

toDetailedString

public String toDetailedString()
Description copied from interface: DetailedString
provides full details of this instance in a String. In case the String contains multiple lines, it is recommended to use '\n' rather than the platform specific line-break for better compatibility.

Specified by:
toDetailedString in interface DetailedString
Returns:
a (potentially multi-line) String providing full details on this object instance

setCategoryName

protected void setCategoryName(String name)

setParentCategory

protected void setParentCategory(Category<T> parent)
                          throws IllegalArgumentException
Throws:
IllegalArgumentException

getCategoryName

public String getCategoryName()
Description copied from interface: Category
returns the name for this category

Specified by:
getCategoryName in interface Category<T>

getParentCategory

public Category<T> getParentCategory()
Description copied from interface: Category
returns the super category that this category belongs to - or null if it is a top-level category

Specified by:
getParentCategory in interface Category<T>

getSubCategories

public List<? extends Category<T>> getSubCategories(T context)
                                             throws IOException
the returned list by this implementation allows direct modifications; the context parameter is ignored and may be null

Specified by:
getSubCategories in interface Category<T>
Parameters:
context - the object (typically a database, a file, a URL, etc.) that provides the information required to derive the children from.
Returns:
a list of Category objects that have this instance as a parent
Throws:
IOException - if the categories could not be retrieved

setChildren

@Warning(value="if this instance of the given elements are not mutable, you must ensure yourself that the parent of the elements is this instance.")
public void setChildren(Collection<Category<T>> col)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getPathName

public static String getPathName(Category<?> c)

getTopCategory

public static Category<?> getTopCategory(Category<?> c)

getPathName

public static String getPathName(Category<?> c,
                                 String separator)

getPath

public static <T> ArrayList<Category<T>> getPath(Category<T> c)

checkForCircularReferenceInParent

public static void checkForCircularReferenceInParent(Category<?> category,
                                                     Category<?> parent)

listAll

public static <T> List<Category<T>> listAll(Collection<? extends Category<T>> topCategories,
                                            T context)

iterate

public static <T> Iterator<Category<T>> iterate(Category<T> category,
                                                T context)
iterates over all children recursively


iterate

public static <T> Iterator<Category<T>> iterate(List<? extends Category<T>> categoryList,
                                                T context)
iterates over the list itself and all children recursively


getAllChildren

public static <T> ArrayList<Category<T>> getAllChildren(Category<T> category,
                                                        T context)
                                             throws IOException
does not include the given category itself

Throws:
IOException

addAllChildrenFrom

public static <T> ArrayList<Category<T>> addAllChildrenFrom(Category<T> category,
                                                            T context,
                                                            ArrayList<Category<T>> list)
                                                 throws IOException
works recursively; does not include the given category itself

Throws:
IOException

isParent

public static <T> boolean isParent(Category<T> parent,
                                   Category<T> child)


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads