fleXplorer.Taxonomies
Interface ITaxonomy<Type extends FacetsType>

Type Parameters:
Type - Generic Type. Taxonomy can include only one type of Terms. Type can be int, String, Date, Interval ...
All Known Implementing Classes:
Taxonomy

public interface ITaxonomy<Type extends FacetsType>

Version:
1.1
Author:
Nikos

Method Summary
 int addHead(FacetsType head)
          Add a head term at the taxonomy.
 boolean checkRel()
          Return the value of variable that defines when will be the check for cycles and redundant relationships.
 void clear()
          Removes all relationships and terms from the taxonomy.
 boolean containsChild(int parentId, FacetsType childValue)
          Return true if the term with the specified id has a direct child with the specified value.
 boolean containsChild(int parentId, int childId)
          Return true if the term with the specified id has a direct child with the specified id.
 boolean containsParent(int childId, FacetsType parentValue)
          Return true if the term with the specified id has a direct parent with the specified value.
 boolean containsParent(int childId, int parentId)
          Return true if the term with the specified id has a direct parent with the specified id.
 int directChildrenSize(int parentId)
          Returns the number of the direct children of the Term with the specified id.
 int directChildrenSize(Term<FacetsType> parent)
          Returns the number of the direct children of the specified term.
 int directParentsSize(int childId)
          Returns the number of the direct parents of the Term with the specified id.
 int directParentsSize(Term<FacetsType> child)
          Returns the number of the direct parents of the specified Term.
 void elimRR()
          Eliminates redundant relationships.
 java.util.ArrayList<Term<FacetsType>> getAllChildren(Term<FacetsType> parent)
          Returns all children of the specified term.
 java.util.HashSet<java.lang.Integer> getAllIds(int termId)
          Returns all ids of the documents that is indexed to the term with the specified id and all its descendants.
 java.util.HashSet<java.lang.Integer> getAllIds(Term<FacetsType> term)
          Returns all ids of the documents that is indexed to the specified term and all its descendants.
 java.util.Collection<Term<FacetsType>> getAllParents(int childId)
          Returns all parents of the specified term.
 java.util.ArrayList<Term<FacetsType>> getAllParents(Term<FacetsType> child)
          Returns all parents of the specified term.
 java.util.HashMap<java.lang.Integer,java.util.Collection<Term<FacetsType>>> getAllParentsWithHierarchy(Term<FacetsType> child)
          Returns a HashMap with all parents of the specified term using hierarchy.
 java.util.Map<Term<FacetsType>,java.util.Collection<Term<FacetsType>>> getAllRelations()
          Returns a Map with all relationships of the taxonomy.
 int getChildId(int parentId, FacetsType childValue)
          Returns the id of the child term with the specified value of the parent term with the specified id.
 java.util.HashMap<Term<FacetsType>,java.lang.Integer> getCount(java.util.HashSet<java.lang.Integer> indexes)
          Returns the count information for all Terms of the flat Taxonomy according to the indexes.
 int getCount(int termId, java.util.HashSet<java.lang.Integer> indexes)
          Returns the count information of the Term with the specified id according to the indexes.
 int getCount(Term<FacetsType> term, java.util.HashSet<java.lang.Integer> indexes)
          Returns the count information of the specified Term according to the indexes.
 java.util.Collection<Term<FacetsType>> getDirectChildren(int parentId)
          Returns the direct children of the Term with the specified id.
 java.util.Collection<Term<FacetsType>> getDirectChildren(Term<FacetsType> parent)
          Returns the direct children of the specified Term.
 java.util.Collection<Term<FacetsType>> getDirectParents(int childId)
          Returns the direct parents of the Term with the specified id.
 java.util.Collection<Term<FacetsType>> getDirectParents(Term<FacetsType> child)
          Returns the direct parents of the specified Term.
 Term<FacetsType> getHead()
          Returns the head term of the taxonomy.
 java.lang.String getName()
          Returns the name of Taxonomy.
 int getNumOfRelations()
          Returns the number of relations of the taxonomy.
 Term<FacetsType> getTopElement()
          Returns the top element.
 int getTopElementId()
          Returns the id of the top element.
 java.lang.String getType()
          Returns the Java type of the Terms of the Taxonomy.
 Validation getValidation()
          Returns if taxonomy is valid.
 boolean hasLists()
          Returns the value of variable that defines if Taxonomy's Terms have lists for its parents and children.
 boolean isChild(Term<FacetsType> parent, Term<FacetsType> child)
          Checks if the second argument is a child of the first one.
 boolean isCycle(Term<FacetsType> parent, Term<FacetsType> child)
          Checks if this relationship parent - child causes a cycle to Taxonomy's graph.
 boolean isDirectChild(Term<FacetsType> parent, Term<FacetsType> child)
          Checks if the second argument is direct child of the first one.
 boolean isDirectParent(Term<FacetsType> child, Term<FacetsType> parent)
          Checks if the second argument is direct parent of the first one.
 boolean isParent(Term<FacetsType> child, Term<FacetsType> parent)
          Checks if the second term is a parent of the first one.
 boolean isRR(Term<FacetsType> parent, Term<FacetsType> child)
          Checks if this relationship parent - child is redundant.
 boolean isValid()
          Search for cycles in Taxonomy.
 boolean isZP(int termId, java.util.HashSet<java.lang.Integer> indexes)
          Returns true if the term with the specified id is a legal term according the list of documents(objects) that have to be presented(indexes).
 void printDirectChildren(Term<Type> parent)
          Prints the direct children of the specified term.
 void printDirectParents(Term<Type> child)
          Prints the direct parents of the specified term.
 void removeAllTheOtherIndexes(int termId)
          If the taxonomy is not flat, removes the indexes of all terms of the taxonomy except the indexes of the term with the specified id and all of its descendants.
 boolean removeDirectChild(Term<FacetsType> parent, Term<FacetsType> child)
          Removes the child Term of the specified parent Term with the specified value.
 boolean removeDirectParent(Term<FacetsType> child, Term<FacetsType> parent)
          Removes the parent Term of the specified child Term with the specified value.
 boolean removeRelship(int parentId, int childId)
          Removes the relationship between two terms.
 boolean removeRelship(Term<FacetsType> parent, Term<FacetsType> child)
          Removes the relationship between two terms.
 void setCheckRel(CheckRel checkRel)
          Sets the value of variable that defines when will be the check for cycles and redundant relationships.
 void setHasLists(HasLists value)
          Sets the value of variable that defines if the taxonomy is flat or there is a hierarchy.
 void setName(java.lang.String name)
          Defines the name of Taxonomy.
 java.util.HashMap<java.lang.String,java.lang.Integer> setRelship(FacetsType parentValue, FacetsType childValue)
          Creates and inserts two Terms with specified values into Taxonomy and creates a relationship between them.
 boolean setRelship(FacetsType parentValue, int parentId, FacetsType childValue, int childId)
          Create the terms and sets the relationship parent - child between the two Terms.
 int setRelship(int parentId, FacetsType childValue)
          Set a relationship between two terms.
 boolean setRelship(Term<FacetsType> parent, Term<FacetsType> child)
          Sets relationship parent - child between two Terms.
 boolean setRelshipsMaterialization(Materialization toDo)
          Materializes or cancels relationships if Terms are comparable.
 void setTaxonomy(Taxonomy<?> tx)
          Clears the taxonomy and gives to the Taxonomy the properties of the argument.
 void setType(java.lang.String type)
          Defines the Java type of the Terms of the Taxonomy.
 void setValidation(Validation value)
          Sets the value of variable that defines if taxonomy is valid.
 java.lang.String toString()
          Returns a string representation of all materialized relationships.
 

Method Detail

getType

java.lang.String getType()
Returns the Java type of the Terms of the Taxonomy. Preconditions: Always true.
Postconditions: Returns the value of private variable type.

Returns:
the Java type of the Terms of the Taxonomy.

setType

void setType(java.lang.String type)
Defines the Java type of the Terms of the Taxonomy. Preconditions: Argument must not be null.
Postconditions: Sets the value of private variable type.


setHasLists

void setHasLists(HasLists value)
Sets the value of variable that defines if the taxonomy is flat or there is a hierarchy.
Preconditions: The argument must not be null.
Postconditions: Changes the value of private variable hasLists. If argument is false then, to be hasLists false must private variable comparability be true.

Parameters:
value - the new value for private variable hasLists.

setTaxonomy

void setTaxonomy(Taxonomy<?> tx)
Clears the taxonomy and gives to the Taxonomy the properties of the argument. Preconditions: The argument must not be null.
Postconditions: Clears the taxonomy and gives to the Taxonomy the properties of the argument.

Parameters:
tx - the taxonomy that from which this Taxonomy will take the properties.

hasLists

boolean hasLists()
Returns the value of variable that defines if Taxonomy's Terms have lists for its parents and children.
Preconditions: Always true.
Postconditions: Returns true if the value of private variable hasLists is TRUE.

Returns:
true if the taxonomy has hierarchy; false otherwise.

setName

void setName(java.lang.String name)
Defines the name of Taxonomy.
Preconditions: Taxonomy's name must not be null.
Postconditions: Defines as value of private variable name the argument.

Parameters:
name - the new name of Taxonomy.

getName

java.lang.String getName()
Returns the name of Taxonomy.
Preconditions: Always true.
Postconditions: Returns the value of private variable name.

Returns:
the name of Taxonomy.

checkRel

boolean checkRel()
Return the value of variable that defines when will be the check for cycles and redundant relationships.
Preconditions: Always true.
Postconditions: Returns true if the value of private variable checkRel is TRUE.

Returns:
true if the taxonomy checks for cycles and redundant relationships; false otherwise.

setCheckRel

void setCheckRel(CheckRel checkRel)
Sets the value of variable that defines when will be the check for cycles and redundant relationships.
Preconditions: The argument must not be null.
Postconditions: Changes the value of private variable checkRel.

Parameters:
check - the new value for check.

printDirectChildren

void printDirectChildren(Term<Type> parent)
Prints the direct children of the specified term. Preconditions: The argument must not be null and the Taxonomy must not be flat.
Postconditions: Prints the direct children of the specified term. It finds the direct parents of term from parents list.

Parameters:
term - the parent term

printDirectParents

void printDirectParents(Term<Type> child)
Prints the direct parents of the specified term. Preconditions: The argument must not be null and the Taxonomy must not be flat.
Postconditions: Prints the direct parents of the specified term. It finds the direct children of term from parents list.

Parameters:
term - the child term

setValidation

void setValidation(Validation value)
Sets the value of variable that defines if taxonomy is valid.
Preconditions: The argument must not be null.
Postconditions: Changes the value of private variable validation.

Parameters:
value - the new value for validation.

getValidation

Validation getValidation()
Returns if taxonomy is valid. Preconditions: Always true.
Postconditions: Returns the value of private variable validation.

Returns:
Validation.TRUE if Taxonomy is valid.

removeDirectChild

boolean removeDirectChild(Term<FacetsType> parent,
                          Term<FacetsType> child)
Removes the child Term of the specified parent Term with the specified value.
Preconditions: The arguments must not be null and the Taxonomy must not be flat.
Postconditions: Checks if parent Term has a child with the specified value. If yes removes it from the list of children and returns true; false otherwise.

Parameters:
parent - The Term that will be removed its child.
child - The child Term to be removed.
Returns:
true if child removed successfully; false otherwise.

removeDirectParent

boolean removeDirectParent(Term<FacetsType> child,
                           Term<FacetsType> parent)
Removes the parent Term of the specified child Term with the specified value.
Preconditions: The arguments must not be null and the Taxonomy must not be flat.
Postconditions: Checks if child term has a parent with the specified value. If yes removes it from the list of parents and returns true; false otherwise.

Parameters:
child - The Term that will be removed its parent.
parent - The parent Term to be removed.
Returns:
true if parent removed successfully; false otherwise.

directChildrenSize

int directChildrenSize(Term<FacetsType> parent)
Returns the number of the direct children of the specified term.
Preconditions: The argument must not be null and the Taxonomy must not be flat.
Postconditions: Returns the number of the direct children of the specified term. If list is null, returns zero.

Parameters:
parent - The Term whose the size of children list will be returned.
Returns:
the number of children of the specified term.

containsChild

boolean containsChild(int parentId,
                      FacetsType childValue)
Return true if the term with the specified id has a direct child with the specified value. Preconditions: The childValue must not be null, the Taxonomy must not be flat and the parentId must not be negative.
Postconditions: Return true if the list of children contains the specified pair.

Parameters:
parentId - the id of parent term
childValue - the value of child term
Returns:
true if the term with the specified id has a direct child with the specified value

containsChild

boolean containsChild(int parentId,
                      int childId)
Return true if the term with the specified id has a direct child with the specified id. Preconditions: The Taxonomy must not be flat and the ids must not be negatives.
Postconditions: Return true if the list of children contains the specified pair.

Parameters:
parentId - the id of parent term.
childId - the id of child term.
Returns:
true if the term with the specified id has a direct child with the specified id.

containsParent

boolean containsParent(int childId,
                       FacetsType parentValue)
Return true if the term with the specified id has a direct parent with the specified value. Preconditions: The Taxonomy must not be flat and the ids must not be negative.
Postconditions: Return true if the list of parents contains the specified pair.

Parameters:
childId - the id of child term
parentValue - the value of parent term
Returns:
true if the term with the specified id has a direct parent with the specified value

containsParent

boolean containsParent(int childId,
                       int parentId)
Return true if the term with the specified id has a direct parent with the specified id. Preconditions: The Taxonomy must not be flat and the ids must not be negatives.
Postconditions: Return true if the list of parents contains the specified pair.

Parameters:
childId - the id of child term.
parentId - the id of parent term.
Returns:
true if the term with the specified id has a direct parent with the specified id.

directParentsSize

int directParentsSize(Term<FacetsType> child)
Returns the number of the direct parents of the specified Term.
Preconditions: Argument must not be null. The Taxonomy must not be flat.
Postconditions: Returns the size of argument's list of parents. If list is null, returns zero.

Parameters:
term - The Term whose the number of parents will be returned.
Returns:
the number of parents of the specified Term.

directParentsSize

int directParentsSize(int childId)
Returns the number of the direct parents of the Term with the specified id.
Preconditions: The child id must not be negative. The Taxonomy must not be flat.
Postconditions: Returns the size of argument's list of parents. If list is null, returns zero.

Parameters:
childId - The id of Term whose the number of parents will be returned.
Returns:
the number of parents of the Term with the specified id.

directChildrenSize

int directChildrenSize(int parentId)
Returns the number of the direct children of the Term with the specified id.
Preconditions: The parent id must not be negative. The Taxonomy must not be flat.
Postconditions: Returns the size of argument's list of children. If list is null, returns zero.

Parameters:
childId - The id of Term whose the number of children will be returned.
Returns:
the number of children of the Term with the specified id.

getNumOfRelations

int getNumOfRelations()
Returns the number of relations of the taxonomy. Preconditions: Always true.
Postconditions: Calculate the number of relations of the taxonomy and returns the number.

Returns:
the number of relations of the taxonomy.

getAllRelations

java.util.Map<Term<FacetsType>,java.util.Collection<Term<FacetsType>>> getAllRelations()
Returns a Map with all relationships of the taxonomy. Preconditions: The Taxonomy must not be flat.
Postconditions: Returns the parents map.

Returns:
a Map with all relationships of the taxonomy.

getDirectChildren

java.util.Collection<Term<FacetsType>> getDirectChildren(Term<FacetsType> parent)
Returns the direct children of the specified Term.
Preconditions: The Taxonomy must not be flat. Argument must not be null.
Postconditions: Returns a Collection that contains the direct children of Term.

Parameters:
parent - The Term whose the direct children Terms will be returned.
Returns:
the list that contains the direct children of the specified term.

getDirectChildren

java.util.Collection<Term<FacetsType>> getDirectChildren(int parentId)
Returns the direct children of the Term with the specified id.
Preconditions: The Taxonomy must not be flat. Argument must not be null.
Postconditions: Returns a Collection that contains the direct children of Term.

Parameters:
parentId - The id of Term whose the direct children Terms will be returned.
Returns:
the list that contains the direct children of the Term with the specified id.

getDirectParents

java.util.Collection<Term<FacetsType>> getDirectParents(Term<FacetsType> child)
Returns the direct parents of the specified Term.
Preconditions: The Taxonomy must not be flat. Argument must not be null.
Postconditions: Returns a Collection that contains the direct parents of Term.

Parameters:
child - The Term whose the direct parents Terms will be returned.
Returns:
the list that contains the direct parents of the specified term.

getDirectParents

java.util.Collection<Term<FacetsType>> getDirectParents(int childId)
Returns the direct parents of the Term with the specified id.
Preconditions: The Taxonomy must not be flat. The childId must not be negative.
Postconditions: Returns a Collection that contains the direct parents of Term.

Parameters:
childId - The id of Term whose the direct parents Terms will be returned.
Returns:
the list that contains the direct parents of the Term with the specified id.

isDirectChild

boolean isDirectChild(Term<FacetsType> parent,
                      Term<FacetsType> child)
Checks if the second argument is direct child of the first one.
Preconditions: The Taxonomy must not be flat. Arguments must not be null.
Postconditions: Checks if first argument is included in children's list of second one. If yes returns true; false otherwise.

Parameters:
term - The Term that will be checked if second argument is one of its direct children.
child - The Term that will be checked if it is direct child of first argument.
Returns:
true if the second argument is direct child of the first one; false otherwise.

isDirectParent

boolean isDirectParent(Term<FacetsType> child,
                       Term<FacetsType> parent)
Checks if the second argument is direct parent of the first one.
Preconditions: The Taxonomy must not be flat. Arguments must not be null.
Postconditions: Checks if the first argument included in parents list of the second one. If yes returns true; false otherwise.

Parameters:
term - The Term that will be checked if second argument is one of its direct parents.
parent - The Term that will be checked if it is direct parent of first argument.
Returns:
true if the second argument is direct parent of the first one; false otherwise.

getHead

Term<FacetsType> getHead()
Returns the head term of the taxonomy. Preconditions: Always true.
Postconditions: Returns the term of terminology that is not included in the list of parents.

Returns:
the head term of the taxonomy.

getTopElementId

int getTopElementId()
Returns the id of the top element. Preconditions: Always true.
Postconditions: Returns zero, because when we create new Taxonomy we create the top element and give it the id 0.

Returns:
the id of the top element.

getTopElement

Term<FacetsType> getTopElement()
Returns the top element. Preconditions: Always true.
Postconditions: Returns the top element

Returns:
the top element.

isZP

boolean isZP(int termId,
             java.util.HashSet<java.lang.Integer> indexes)
Returns true if the term with the specified id is a legal term according the list of documents(objects) that have to be presented(indexes). This method usually used in the case we have disable the counter information. Preconditions: The Taxonomy must not be flat. The id must not be negative and the indexes must not be null.
Postconditions: Returns true if this term or at least one term of its descendants have a legal id.

Parameters:
termId - The id of the Term.
indexes - a HashSet with the ids of documents that have to be displayed.
Returns:
true if the term with the specified id is a legal term according the list of documents(objects) that have to be presented(indexes); false otherwise.

getCount

int getCount(int termId,
             java.util.HashSet<java.lang.Integer> indexes)
Returns the count information of the Term with the specified id according to the indexes. Preconditions: The Taxonomy must not be flat. The id must not be negative and the indexes must not be null.
Postconditions: Returns the intersection of the indexes the term and all its descendants with the specified indexes.

Parameters:
termId - The id of the Term.
indexes - a HashSet with the ids of documents that have to be displayed.
Returns:
the count information of the Term with the specified id according to the indexes.

getCount

int getCount(Term<FacetsType> term,
             java.util.HashSet<java.lang.Integer> indexes)
Returns the count information of the specified Term according to the indexes. Preconditions: The Taxonomy must not be flat. The arguments must not be null.
Postconditions: Returns the intersection of the indexes the term and all its descendants with the specified indexes.

Parameters:
term - The Term.
indexes - a HashSet with the ids of documents that have to be displayed.
Returns:
the count information of the specified Term according to the indexes.

getCount

java.util.HashMap<Term<FacetsType>,java.lang.Integer> getCount(java.util.HashSet<java.lang.Integer> indexes)
Returns the count information for all Terms of the flat Taxonomy according to the indexes. Preconditions: The Taxonomy must be flat. The argument must not be null.
Postconditions: For each term of terminology check if it is a legal zoom-in point

Parameters:
indexes - a HashSet with the ids of documents that have to be displayed.
Returns:
the count information for all Terms of the flat Taxonomy according to the indexes.

getAllIds

java.util.HashSet<java.lang.Integer> getAllIds(int termId)
Returns all ids of the documents that is indexed to the term with the specified id and all its descendants. Preconditions: The Taxonomy must not be flat. The id must not be negative.
Postconditions: Adds to a hashset all ids of the indexed documents of each descendant term of the term with the specified id.

Parameters:
indexes - a HashSet with the ids of documents that have to be displayed.
Returns:
all ids of the documents that is indexed to the term with the specified id and all its descendants.

getAllIds

java.util.HashSet<java.lang.Integer> getAllIds(Term<FacetsType> term)
Returns all ids of the documents that is indexed to the specified term and all its descendants. Preconditions: The Taxonomy must not be flat. The id must not be negative.
Postconditions: Adds to a hashset all ids of the indexed documents of each descendant term of the specified term.

Parameters:
indexes - a HashSet with the ids of documents that have to be displayed.
Returns:
all ids of the documents that is indexed to the specified term and all its descendants.

getAllChildren

java.util.ArrayList<Term<FacetsType>> getAllChildren(Term<FacetsType> parent)
Returns all children of the specified term.
Preconditions: The Taxonomy must be flat. The argument must not be null.
Postconditions: Starts from the direct children of the term and get all descendants of the term

Parameters:
parent - Term of which list of children will be returned.
Returns:
a Collection that contains all children of the specified Term.

removeAllTheOtherIndexes

void removeAllTheOtherIndexes(int termId)
If the taxonomy is not flat, removes the indexes of all terms of the taxonomy except the indexes of the term with the specified id and all of its descendants. In case it is flat, removes the all the indexes except the indexes of the term with the specified id. Preconditions: The id must not be negative.
Postconditions: If the taxonomy is not flat, removes the indexes of all terms of the taxonomy except the indexes of the term with the specified id and all of its descendants. In case it is flat, removes the all the indexes except the indexes of the term with the specified id.

Parameters:
termId - the id of the term

removeRelship

boolean removeRelship(int parentId,
                      int childId)
Removes the relationship between two terms. It doesn't removes the terms from the terminology. Preconditions: The ids must not be negative, the taxonomy must not be flat and the one term must be direct child or direct parent of the other.
Postconditions: Removes from the list of children of the parent term the child term and the opposite.

Parameters:
parentId - the id of the parent term
childId - the id of the child term
Returns:
true if the relationship is removed successfully; false otherwise.

removeRelship

boolean removeRelship(Term<FacetsType> parent,
                      Term<FacetsType> child)
Removes the relationship between two terms. It doesn't removes the terms from the terminology. Preconditions: The terms must not be null, the taxonomy must not be flat and the one term must be direct child or direct parent of the other.
Postconditions: Removes from the list of children of the parent term the child term and the opposite.

Parameters:
parent - the parent term of the relationship.
child - the child term of the re
Returns:
true if the relationship is removed successfully; false otherwise.

getAllParents

java.util.ArrayList<Term<FacetsType>> getAllParents(Term<FacetsType> child)
Returns all parents of the specified term.
Preconditions: The Taxonomy must not be flat. The argument must not be null.
Postconditions: Starts from the direct parents of the term and get all ancestors of the term.

Parameters:
child - Term of which list of parents will be returned.
Returns:
a Collection that contains all parents of the specified Term.

getAllParentsWithHierarchy

java.util.HashMap<java.lang.Integer,java.util.Collection<Term<FacetsType>>> getAllParentsWithHierarchy(Term<FacetsType> child)
Returns a HashMap with all parents of the specified term using hierarchy. The HasMap includes the pairs (depth, parents). The key of this HashMap is an Integer that specifies level in hierarchy of the a parent. Preconditions: The Taxonomy must not be flat and the argument must not be null.
Postconditions: Starts from the direct parents of the term and add them to the hasmap giving the depth using an integer.

Parameters:
child - the child term
Returns:
a HashMap with all parents of the specified term using hierarchy.

getAllParents

java.util.Collection<Term<FacetsType>> getAllParents(int childId)
Returns all parents of the specified term.
Preconditions: The Taxonomy must not be flat and the id must not be negative.
Postconditions: Returns all parents of the specified terms. Starts from the direct parents and goes to all ancestors.

Parameters:
term - The Term of which list of parents will be returned.
Returns:
an Collection that contains all parents of the specified Term.

isChild

boolean isChild(Term<FacetsType> parent,
                Term<FacetsType> child)
Checks if the second argument is a child of the first one.
Preconditions: The Taxonomy must not be flat and the terms must not be null.
Postconditions: Checks if first argument included in children list of second one. If yes returns true; false otherwise.

Parameters:
parent - The Term that will be checked if second argument is one of its children.
child - The Term that will be checked if it is child of the first term.
Returns:
true if the second argument is a child of the first one; false otherwise.

isParent

boolean isParent(Term<FacetsType> child,
                 Term<FacetsType> parent)
Checks if the second term is a parent of the first one.
Preconditions: The Taxonomy must not be flat and the terms must not be null.
Postconditions: Checks if the first argument included in the parents list of the second one. If yes returns true; false otherwise.

Parameters:
child - The Term that will be checked if the second argument is one of its parents.
parent - The Term that will be checked if it is parent of the first argument.
Returns:
true if the second argument is a parent of the first one; false otherwise.

setRelship

boolean setRelship(Term<FacetsType> parent,
                   Term<FacetsType> child)
Sets relationship parent - child between two Terms.
Preconditions: The Taxonomy must not be flat and the terms must not be null.
Postconditions: Sets a relationship parent - child between arguments. If variable checkRel is true, calls the isValidRel(parent, child) method to check the relationship, if it is false sets the relationship with out checking. And it adds the terms to the terminology.

Parameters:
parent - the parent Term of the relationship.
child - the child Term of the relationship.
Returns:
true if the relationship is implemented successfully; false otherwise;

setRelship

boolean setRelship(FacetsType parentValue,
                   int parentId,
                   FacetsType childValue,
                   int childId)
Create the terms and sets the relationship parent - child between the two Terms.
Preconditions: The Taxonomy must not be flat and the values must not be null and the ids must not be negatives.
Postconditions: Sets a relationship parent - child between arguments. If variable checkRel is true, calls the isValidRel(parent, child) method to check the relationship, if it is false sets the relationship with out checking. And it adds the terms to the terminology.

Parameters:
parentValue - the value of the parent term
parentId - the id of the parent term
childValue - the value of the child term
childId - the id of the child term
Returns:
true if the relationship is set successfully; false otherwise.

setRelship

java.util.HashMap<java.lang.String,java.lang.Integer> setRelship(FacetsType parentValue,
                                                                 FacetsType childValue)
Creates and inserts two Terms with specified values into Taxonomy and creates a relationship between them.
Preconditions: The arguments must not be null and the taxonomy must not be flat. Postconditions: Constructs two Terms checks if already included in Taxonomy, if not adds them. Then, if variable checkRel is true, it checks if relationship is redundant or causes a cycle, if it is false sets the relationship with out checking.

Parameters:
parentValue - the value of parent Term.
childValue - the value of child Term.
Returns:
the ids of the child and parent terms.

setRelship

int setRelship(int parentId,
               FacetsType childValue)
Set a relationship between two terms. The parent must already exists into the taxonomy and adds the child value to the parent. Finally, returns the id of the child term. Preconditions: The parent must be already in the taxonomy. The Taxonomy must not be flat and the childValue must not be null and the parentid must not be negatives.
Postconditions: Sets a relationship parent - child between arguments. If variable checkRel is true, calls the isValidRel(parent, child) method to check the relationship, if it is false sets the relationship with out checking. And it adds the terms to the terminology.

Parameters:
parentId - the id of the parent term
childValue - the value of the child term
Returns:
the id of the child term if the relationship added successfully; -1 otherwise.

getChildId

int getChildId(int parentId,
               FacetsType childValue)
Returns the id of the child term with the specified value of the parent term with the specified id. If there is no such relationship it returns -1. Preconditions: The Taxonomy must not be flat and the childValue must not be null and the parentId must not be negatives.
Postconditions: Checks preconditions, gets the direct children of the parent term, and iterates until it finds the child with the specified value. When finds it, returns it's id. If there is no such relationship it returns -1.

Parameters:
parentId - the id of the parent term
childValue - the value of the child term
Returns:
the id of the child term.

isRR

boolean isRR(Term<FacetsType> parent,
             Term<FacetsType> child)
Checks if this relationship parent - child is redundant.
Preconditions: Taxonomy must not be flat and the arguments must not be null. Postconditions: Checks if this relationship parent - child is redundant. If checking of relationships has been defined as true then when this method called it will check if this relationship is redundant. To check if this relationship is redundant it just checks if the child term is included in the list of the descendants of the parent term. If yes returns true; false otherwise.

Parameters:
parent - parent Term of relationship.
child - child Term of relationship.
Returns:
true if relationship is redundant.

isCycle

boolean isCycle(Term<FacetsType> parent,
                Term<FacetsType> child)
Checks if this relationship parent - child causes a cycle to Taxonomy's graph. Preconditions: Taxonomy must not be flat and the arguments must not be null.
Postconditions: Checks if the parent term has already a parent which is the child term of this method. If there is no parents or children of a term, so the relationship can not causes a cycle.

Parameters:
parent - parent Term of relationship.
child - child Term of relationship.
Returns:
true if relationship causes a cycle to Taxonomy's graph; false otherwise.

toString

java.lang.String toString()
Returns a string representation of all materialized relationships.
Preconditions: Always true.
Postconditions: Returns a string representation of all materialized relationships.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of all materialized relationships.

clear

void clear()
Removes all relationships and terms from the taxonomy. Preconditions: Always true.
Postconditions: Clears the children list, the parents list and the terminology.


addHead

int addHead(FacetsType head)
Add a head term at the taxonomy. Preconditions: The argument must not be null and the taxonomy must not be flat.
Postconditions: Adds to the list of the children of the top element the id of the term, and the opposite.

Parameters:
head - the value of the
Returns:
the id of the head.

isValid

boolean isValid()
Search for cycles in Taxonomy. If detects a cycle returns true and defines Taxonomy as invalid. Preconditions: Taxonomy must not be null. The variable for checking of relationships must be false.
Postconditions: Search for cycles in Taxonomy. If detect a cycle returns true and define Taxonomy as invalid.

Returns:
true if it doesn't detects a cycle in Taxonomy; false otherwise.

elimRR

void elimRR()
Eliminates redundant relationships.
Preconditions: Taxonomy must not be flat.
Postconditions: Checks Taxonomy from redundant relationships and eliminates them.


setRelshipsMaterialization

boolean setRelshipsMaterialization(Materialization toDo)
Materializes or cancels relationships if Terms are comparable.
Preconditions: Taxonomy must not be null. Private variable comparability must be true.
Postconditions: If enumeration type is MATERIALIZE then materializes the relationships. If its CANCEL cancels all relationships between Taxonomy's Terms.

Returns:
true if relationships are materialized or canceled successfully; false otherwise;