fleXplorer.Terms
Class Term<Type extends FacetsType>

java.lang.Object
  extended by fleXplorer.Terms.Term<Type>
Type Parameters:
Type - Generic Type. Term's value can be int, String, Date, Interval ...
All Implemented Interfaces:
ITerm<Type>

public class Term<Type extends FacetsType>
extends java.lang.Object
implements ITerm<Type>

Version:
1.1
Author:
Nikos Armenatzoglou

Constructor Summary
Term()
          Constructs a Term with null value and set it non comparable.
Term(Term<Type> term)
          Constructs a Term with the same attributes of the given Term.
Term(Type value, Comparison comparability)
          Constructs a Term with specified value and comparability.
Term(Type value, int id)
          Constructs a Term with specific name and id, the Term is not comparable.
Term(Type value, int id, Comparison comparability)
          Constructs a Term with specific value, id and comparability.
 
Method Summary
 boolean addIndex(int id)
          Add the index(id) of a document to the list of indexes of this Term.
 void clearIndexes()
          Removes all ids of documents that are assigned to the specific Term from the indexes.
 boolean containsIndex(int id)
          Returns true if the list of indexes contains the specified id of a document.
 boolean equals(java.lang.Object obj)
           
 java.util.HashSet<java.lang.Integer> getAllIndexes()
          Returns all ids of documents that are indexed to the specific Term.
 Comparison getComparability()
          Returns the comparability of Term.
 int getCount()
          Returns the number of the legal objects that are classified under this term.
 java.util.HashSet<java.lang.Integer> getIndexes()
          Returns the list of objects that have been indexed to this Term.
 java.util.HashSet<java.lang.Integer> getLegalIds(java.util.HashSet<java.lang.Integer> indexes)
          Returns the intersection of the term's indexes with the legal indexes that have to be displayed.
 int getNumOfIndexes()
          Returns the number of indexes of this term (cardinality of indexes).
 int getNumOfLegalIds(java.util.HashSet<java.lang.Integer> indexes)
          Returns the size of the intersection of the term's indexes with the legal indexes that have to be displayed.
 int getTermId()
          Return term's id.
 Type getTermValue()
          Return term's value.
 int hashCode()
           
 boolean isComparable()
          Returns true if Term is Comparable.
 boolean isIndexesListEmpty()
          Returns true if the list of indexes of the Term is empty.
 boolean isOpened()
          Returns true if the term belongs to a hierarchical facet and it must be opened in UI; false otherwise.
 boolean isZP(java.util.HashSet<java.lang.Integer> indexes)
          Returns true if this term is a zoom-in point.
 boolean removeIndex(int id)
          Returns true if the specified id removed correctly from the list of indexes of the Term.
 void setClosed()
          Defines that the term will be displayed as closed in UI.
 void setComparability(Comparison comparability)
          Sets Term's comparability.
 void setCount(int count)
          Sets the number of the legal objects that are classified under this term.
 void setOpened()
          Defines that the term will be displayed as opened in UI.
 void setTermId(int id)
          Set term's id.
 void setTermValue(Type value)
          Sets Term's value.
 java.lang.String toString()
          Returns the String representation of the term.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Term

public Term()
Constructs a Term with null value and set it non comparable.
Preconditions:Always true.
Postconditions:Constructs a Term object.


Term

public Term(Type value,
            Comparison comparability)
Constructs a Term with specified value and comparability.
Preconditions: Arguments must not be null.
Postconditions:Constructs a Term object and defines Term value and comparability.

Parameters:
value - term's value.
comparability - term's comparability.

Term

public Term(Type value,
            int id,
            Comparison comparability)
Constructs a Term with specific value, id and comparability.
Preconditions: Arguments must not be null.
Postconditions: Constructs a Term with specified name, id and comparability.

Parameters:
value - Term's value.
id - Term's id.
comparability - Term's comparability.

Term

public Term(Type value,
            int id)
Constructs a Term with specific name and id, the Term is not comparable.
Preconditions: Arguments must not be null.
Postconditions: Constructs a Term with specified name, id and comparability.

Parameters:
value - Term's value.
id - Term's id.

Term

public Term(Term<Type> term)
Constructs a Term with the same attributes of the given Term.

Parameters:
term - the given Term
Method Detail

isOpened

public boolean isOpened()
Returns true if the term belongs to a hierarchical facet and it must be opened in UI; false otherwise.

Specified by:
isOpened in interface ITerm<Type extends FacetsType>
Returns:
true if the term belongs to a hierarchical facet and it must be opened in UI; false otherwise.

setOpened

public void setOpened()
Defines that the term will be displayed as opened in UI.

Specified by:
setOpened in interface ITerm<Type extends FacetsType>

setClosed

public void setClosed()
Defines that the term will be displayed as closed in UI.

Specified by:
setClosed in interface ITerm<Type extends FacetsType>

getNumOfIndexes

public int getNumOfIndexes()
Returns the number of indexes of this term (cardinality of indexes).

Specified by:
getNumOfIndexes in interface ITerm<Type extends FacetsType>
Returns:
the number of indexes of this term.

setComparability

public void setComparability(Comparison comparability)
Sets Term's comparability.
Preconditions: Term must not be null.The type of argument must be boolean.
Postconditions: Changes the value of variable comparability.

Specified by:
setComparability in interface ITerm<Type extends FacetsType>
Parameters:
comparability - Term's comparability.

getComparability

public Comparison getComparability()
Returns the comparability of Term.
Preconditions: Term must not be null.
Postconditions: Returns the value of comparability of Term.

Specified by:
getComparability in interface ITerm<Type extends FacetsType>
Returns:
true if Term is comparable, otherwise false.

toString

public java.lang.String toString()
Returns the String representation of the term.
Preconditions: Term must not be null;
Postconditions: Prints Term value and if hasId is true prints Term's id.

Specified by:
toString in interface ITerm<Type extends FacetsType>
Overrides:
toString in class java.lang.Object
Returns:
the String representation of the term.

getIndexes

public java.util.HashSet<java.lang.Integer> getIndexes()
Returns the list of objects that have been indexed to this Term. Preconditions: Term must not be null;
Postconditions: Returns the list of objects that have been indexed to this Term.

Specified by:
getIndexes in interface ITerm<Type extends FacetsType>
Returns:
the list of objects that have been indexed to this Term.

setTermValue

public void setTermValue(Type value)
Sets Term's value.
Preconditions: Term and argument must not be null.
Postconditions: Defines as value of private variable value the value of argument.

Specified by:
setTermValue in interface ITerm<Type extends FacetsType>
Parameters:
id - The new name of term.

isZP

public boolean isZP(java.util.HashSet<java.lang.Integer> indexes)
Returns true if this term is a zoom-in point. A term is a zoom-in point if at least one id from its indexes is contained in the list of legal objects that have to be displayed. This method is used only in case we do not display the counters of zoom-in points. Preconditions: The argument must not be null.

Specified by:
isZP in interface ITerm<Type extends FacetsType>
Parameters:
indexes - the legal ids of documents that have to be displayed.
Returns:
true if term is a zoom-in point; false otherwise.

getLegalIds

public java.util.HashSet<java.lang.Integer> getLegalIds(java.util.HashSet<java.lang.Integer> indexes)
Returns the intersection of the term's indexes with the legal indexes that have to be displayed. Preconditions: The argument must not be null.

Specified by:
getLegalIds in interface ITerm<Type extends FacetsType>
Parameters:
indexes - the legal ids of documents that have to be displayed.
Returns:
the intersection of the term's indexes with the legal indexes that have to be displayed.

getNumOfLegalIds

public int getNumOfLegalIds(java.util.HashSet<java.lang.Integer> indexes)
Returns the size of the intersection of the term's indexes with the legal indexes that have to be displayed. Preconditions: The argument must not be null.

Specified by:
getNumOfLegalIds in interface ITerm<Type extends FacetsType>
Parameters:
indexes - the legal ids of documents that have to be displayed.
Returns:
the size of intersection of the term's indexes with the legal indexes that have to be displayed.

setTermId

public void setTermId(int id)
Set term's id.
Preconditions: Term must not be null, argument id must not be negative.
Postconditions: Defines as value of private variable value the value of argument.

Specified by:
setTermId in interface ITerm<Type extends FacetsType>
Parameters:
id - The new id of term.

getTermValue

public Type getTermValue()
Return term's value.
Preconditions: Term must not be null.
Postconditions: Returns the value of private variable value.

Specified by:
getTermValue in interface ITerm<Type extends FacetsType>
Returns:
Term's value.

getTermId

public int getTermId()
Return term's id.
Preconditions: Term must not be null. Private variable hasId must be true.
Postconditions: Returns the value of private variable id.

Specified by:
getTermId in interface ITerm<Type extends FacetsType>
Returns:
Term's id.

isComparable

public boolean isComparable()
Returns true if Term is Comparable.
Preconditions: Term must not be null.
Postconditions: Returns the value of private variable comparability.

Specified by:
isComparable in interface ITerm<Type extends FacetsType>
Returns:
true if Term is Comparable; false otherwise.

getAllIndexes

public java.util.HashSet<java.lang.Integer> getAllIndexes()
Returns all ids of documents that are indexed to the specific Term.

Specified by:
getAllIndexes in interface ITerm<Type extends FacetsType>
Returns:
all ids of documents that are indexed to the specific Term.

clearIndexes

public void clearIndexes()
Removes all ids of documents that are assigned to the specific Term from the indexes. Preconditions: Term must not be null.
Postconditions: Removes all ids of documents that are assigned to the specific Term from the indexes.

Specified by:
clearIndexes in interface ITerm<Type extends FacetsType>

addIndex

public boolean addIndex(int id)
Add the index(id) of a document to the list of indexes of this Term. Preconditions: Term must not be null.
Postconditions: Add the index(id) of a document to the list of indexes of this Term.

Specified by:
addIndex in interface ITerm<Type extends FacetsType>
Returns:
true if index added successfully; false otherwise.

containsIndex

public boolean containsIndex(int id)
Returns true if the list of indexes contains the specified id of a document. Preconditions: the list of term'indexes must not be null and the id must not be negative.
Postconditions: Returns true if the list of indexes contains the specified id of a document.

Specified by:
containsIndex in interface ITerm<Type extends FacetsType>
Returns:
true if the list of indexes contains the specified id of a document; false otherwise.

removeIndex

public boolean removeIndex(int id)
Returns true if the specified id removed correctly from the list of indexes of the Term. Preconditions: the list of term'indexes must not be null and the id must not be negative.
Postconditions: Returns true if the specified id removed correctly from the list of indexes of the Term.

Specified by:
removeIndex in interface ITerm<Type extends FacetsType>
Returns:
true if the specified id removed correctly from the list of indexes of the Term; false otherwise.

isIndexesListEmpty

public boolean isIndexesListEmpty()
Returns true if the list of indexes of the Term is empty. Preconditions: the list of term'indexes must not be null.
Postconditions: Returns true if the list of indexes of the Term is empty.

Specified by:
isIndexesListEmpty in interface ITerm<Type extends FacetsType>
Returns:
true if the list of indexes of the Term is empty; false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getCount

public int getCount()
Returns the number of the legal objects that are classified under this term.

Specified by:
getCount in interface ITerm<Type extends FacetsType>
Returns:
the number of the legal objects that are classified under this term.

setCount

public void setCount(int count)
Sets the number of the legal objects that are classified under this term.

Specified by:
setCount in interface ITerm<Type extends FacetsType>
Parameters:
count - the number of the legal objects that are classified under this term.