fleXplorer.Terminologies
Class Terminology<Type extends FacetsType>

java.lang.Object
  extended by fleXplorer.Terminologies.Terminology<Type>
Type Parameters:
Type - Generic Type. Terminology can include only one type of Terms. Type can be int, String, Date, Interval ...
All Implemented Interfaces:
ITerminology<Type>
Direct Known Subclasses:
Taxonomy

public class Terminology<Type extends FacetsType>
extends java.lang.Object
implements ITerminology<Type>

Version:
1.1
Author:
Nikos Armenatzoglou

Constructor Summary
Terminology()
          Constructs a Terminology and sets the terms of Terminology as comparable.
Terminology(java.lang.String name)
          Constructs a Terminology with the specified name and sets the terms of Terminology as comparable, also starts the sequence number for ids from zero.
Terminology(java.lang.String name, Comparison comparability)
          Constructs a Terminology with the specified name and comparability of terminology's terms.
 
Method Summary
 void clear()
          Removes all Terms from the Terminology but does not delete the Terms.
 boolean containsTerm(FacetsType termValue)
          Checks if the Term with specified value is included in Terminology.
 boolean containsTermWithId(int termId)
          Tests if the Term with specified id is included in Terminology.
 void decrSeqNumber(int decrNumber)
          Decreases the sequence number of giving ids to the new Terms of Terminology.
 boolean deleteAllIndexes()
          Deletes from all Terms of the Terminology the indexes.
 Comparison getComparability()
          Returns if the Terms that included into Terminology are comparable.
 java.lang.String getName()
          Returns the name of Terminology.
 int getSeqNumber()
          Returns the sequence number of giving ids to the new Terms of Terminology.
 Term<FacetsType> getTerm(FacetsType termValue)
          Returns the Term with the specified value, if it is included in Terminology.
 Term<FacetsType> getTerm(int index)
          Returns the term at the specified position in this Terminology.
 Term<FacetsType> getTerm(Term<FacetsType> term)
          Returns the specified Term, if it is included in Terminology.
 int getTermId(FacetsType value)
          Returns the id of the first Term with the specified value.
 java.util.Collection<Term<FacetsType>> getTerminology()
          Reruns a Collection that includes all Terms of the Terminology.
 Term<FacetsType> getTermWithId(int termId)
          Returns the Term with the specified id that included in Terminology.
 void incrSeqNumber(int incrNumber)
          Increases the sequence number of giving ids to the new Terms of Terminology.
 boolean isComparable()
          Returns true if the Terms of Terminology are comparable.
 boolean isEmpty()
          Checks if Terminology is empty.
 boolean removeTerm(FacetsType termValue)
          Removes the Term with the specified value from Terminology.
 Term<FacetsType> removeTerm(int index)
          Removes the Term at the specified position in this Terminology.
 boolean removeTerm(Term<FacetsType> term)
          Removes the specified Term from Terminology.
 boolean removeTermWithId(int termId)
          Removes the Term with the specified id from Terminology.
 void setComparability(Comparison comparability)
          Sets the value of variable that defines if the Terms of Terminology are comparable.
 void setName(java.lang.String name)
          Define the name of Terminology.
 void setSeqNumber(int num)
          Sets the value of sequence number that is used for giving ids to the new Terms of Terminology.
 Term<FacetsType> setTerm(FacetsType termValue)
          Add a Term with the specified value to the Terminology.
 Term<FacetsType> setTerm(FacetsType termValue, int termId)
          Add a Term with the specified value and id to the Terminology.
 boolean setTerm(Term<FacetsType> term)
          Adds a Term to Terminology.
 void setTerminology(java.util.Collection<Term<FacetsType>> terms)
          Sets the Terminology.
 boolean setTerms(java.util.Collection<Term<FacetsType>> set)
          Adds a Collection of Terms to Terminology.
 boolean setTermsValues(java.util.Collection<Type> set)
          Get a Collection of Terms's values, creates Terms with specified values and insert them into Terminology.
 int size()
          Returns Terminology's size.
 java.lang.String toString()
          Returns a String representation of Terminology.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Terminology

public Terminology()
Constructs a Terminology and sets the terms of Terminology as comparable. Also starts the sequence number for ids from zero (0) and sets the name of Terminology as null.
Preconditions: Always true
Postconditions: Constructs a Terminology object.


Terminology

public Terminology(java.lang.String name)
Constructs a Terminology with the specified name and sets the terms of Terminology as comparable, also starts the sequence number for ids from zero.
Preconditions: Always true
Postconditions: Constructs a Terminology object and set Terminology's name as the value of argument name.

Parameters:
name - Taxonomy's name.

Terminology

public Terminology(java.lang.String name,
                   Comparison comparability)
Constructs a Terminology with the specified name and comparability of terminology's terms. Also starts the sequence number for ids from zero.
Preconditions: Always true.
Postconditions: Constructs a Terminology with specified name and defines if the terms of Terminology are comparable or not, starts the count for ids from zero.

Parameters:
name - the name of Terminology.
comparability - defines if the Terms of Terminology are comparable.
Method Detail

deleteAllIndexes

public boolean deleteAllIndexes()
Deletes from all Terms of the Terminology the indexes. Preconditions: Always true.
Postconditions: Deletes from all Terms of the Terminology the indexes.

Specified by:
deleteAllIndexes in interface ITerminology<Type extends FacetsType>
Returns:
true if all indexes removed successfully; false otherwise.

setSeqNumber

public void setSeqNumber(int num)
Sets the value of sequence number that is used for giving ids to the new Terms of Terminology.
Preconditions: Always true.
Postconditions: Changes the value of private variable seqNumber

Specified by:
setSeqNumber in interface ITerminology<Type extends FacetsType>
Parameters:
num - the new value of sequence number.

getSeqNumber

public int getSeqNumber()
Returns the sequence number of giving ids to the new Terms of Terminology.
Preconditions: Always true.
Postconditions: Returns the value of private variable seqNumber.

Specified by:
getSeqNumber in interface ITerminology<Type extends FacetsType>
Returns:
the sequence number of giving ids to the new Terms of Terminology.

incrSeqNumber

public void incrSeqNumber(int incrNumber)
Increases the sequence number of giving ids to the new Terms of Terminology.
Preconditions: The argument must not be negative or zero.
Postconditions: Increases the value of private variable seqNumber at incrNumber.

Specified by:
incrSeqNumber in interface ITerminology<Type extends FacetsType>
Parameters:
incrNumber - the number according to which the serial number will be increased.

decrSeqNumber

public void decrSeqNumber(int decrNumber)
Decreases the sequence number of giving ids to the new Terms of Terminology.
Preconditions: The argument must not be negative or zero.
Postconditions: Decreases the value of private variable seqNumber at incrNumber. The sequence number after decrease must not be negative.

Specified by:
decrSeqNumber in interface ITerminology<Type extends FacetsType>
Parameters:
decrNumber - the number according to which the serial number will be decreased.

setComparability

public void setComparability(Comparison comparability)
Sets the value of variable that defines if the Terms of Terminology are comparable.
Preconditions: Always true.
Postconditions: Sets to the value of private variable comparability the value of argument.

Specified by:
setComparability in interface ITerminology<Type extends FacetsType>
Parameters:
comparability - defines if the Terms of Terminology are comparable.

isComparable

public boolean isComparable()
Returns true if the Terms of Terminology are comparable.
Preconditions: Always true.
Postconditions: Returns the value of private variable comparability.

Specified by:
isComparable in interface ITerminology<Type extends FacetsType>
Returns:
true if the Terms of Terminology are comparable; false otherwise.

getComparability

public Comparison getComparability()
Returns if the Terms that included into Terminology are comparable.
Preconditions: Always true.
Postconditions: Returns the value of private variable comparability.

Specified by:
getComparability in interface ITerminology<Type extends FacetsType>
Returns:
COMPARABLE if the Terms that included into Terminology are comparable.

clear

public void clear()
Removes all Terms from the Terminology but does not delete the Terms.
Preconditions: Always true.
Postconditions: Removes all Terms from the Collection listOfTerms. The Collection must be empty after this method returns.

Specified by:
clear in interface ITerminology<Type extends FacetsType>

containsTerm

public boolean containsTerm(FacetsType termValue)
Checks if the Term with specified value is included in Terminology.
Preconditions: The argument must not be null.
Postconditions: Checks if the Term with specified value is included in Terminology. It checks the String value of the argument. If it is included returns true, false otherwise.

Specified by:
containsTerm in interface ITerminology<Type extends FacetsType>
Parameters:
termValue - the value of Term that look for.
Returns:
true if Terminology contains the Term; false otherwise.

containsTermWithId

public boolean containsTermWithId(int termId)
Tests if the Term with specified id is included in Terminology.
Preconditions: The argument must not be negative.
Postconditions: Tests if Terminology contains a Term with the specified id. If yes then returns true, false otherwise.

Specified by:
containsTermWithId in interface ITerminology<Type extends FacetsType>
Parameters:
termId - The id of Term.
Returns:
true if Terminology contains the Term; false otherwise.

getTerm

public Term<FacetsType> getTerm(FacetsType termValue)
Returns the Term with the specified value, if it is included in Terminology.
Preconditions: The argument must not be null.
Postconditions: Checks if the Term with specified value is included in Terminology. It checks the String value of the argument. If it is included returns the Term, null otherwise.

Specified by:
getTerm in interface ITerminology<Type extends FacetsType>
Parameters:
termValue - the value of Term that it is looking for.
Returns:
the Term if it is included in Terminology; null otherwise.

getTerm

public Term<FacetsType> getTerm(Term<FacetsType> term)
Returns the specified Term, if it is included in Terminology.
Preconditions: The argument must not be null.
Postconditions: Checks if the Term with specified value is included in Terminology. It checks the id of the argument. If it is included returns the Term, null otherwise.

Specified by:
getTerm in interface ITerminology<Type extends FacetsType>
Parameters:
term - the Term that it is looking for.
Returns:
the Term if it is included in Terminology; null otherwise.

getTerm

public Term<FacetsType> getTerm(int index)
Returns the term at the specified position in this Terminology.
Preconditions: Index must be into the bounds of Terminology.
Postconditions: Checks value of index, if it is ok returns the Term at the specified position.

Specified by:
getTerm in interface ITerminology<Type extends FacetsType>
Parameters:
index - index of the Term into the Terminology to be returned.
Returns:
the Term at the specified index.

getTermWithId

public Term<FacetsType> getTermWithId(int termId)
Returns the Term with the specified id that included in Terminology. Checks if Terminology include Term with specified id and if it is included, returns it.
Preconditions: Term id must not be negative.
Postconditions: Tests if Terminology contains a Term with the specified id. If yes then return it.

Specified by:
getTermWithId in interface ITerminology<Type extends FacetsType>
Parameters:
termId - the id of the Term to be returned.
Returns:
the Term with specified id if it is included in Terminology; null otherwise.

getTerminology

public java.util.Collection<Term<FacetsType>> getTerminology()
Reruns a Collection that includes all Terms of the Terminology.
Preconditions: Always true.
Postconditions: Returns the collection listOfTerms.

Specified by:
getTerminology in interface ITerminology<Type extends FacetsType>
Returns:
a Collection that includes all Terms of the Terminology.

getName

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

Specified by:
getName in interface ITerminology<Type extends FacetsType>
Returns:
the name of Terminology.

size

public int size()
Returns Terminology's size.
Preconditions: Always true.
Postconditions: Returns the size of listOfTerms Collection.

Specified by:
size in interface ITerminology<Type extends FacetsType>
Returns:
Terminology's size.

isEmpty

public boolean isEmpty()
Checks if Terminology is empty.
Preconditions: Always true.
Postconditions: Check if the size of listOfTerms Collection is zero. if yes return true; false otherwise.

Specified by:
isEmpty in interface ITerminology<Type extends FacetsType>
Returns:
true if and only if this Terminology has no Terms, that is, its size is zero; false otherwise.

removeTerm

public boolean removeTerm(Term<FacetsType> term)
Removes the specified Term from Terminology.
If the Terminology does not contain the Term, it is unchanged.
Preconditions: The argument must not be null.
Postconditions: Checks if listOfTerms Collection contains a Term with the specified value.

Specified by:
removeTerm in interface ITerminology<Type extends FacetsType>
Parameters:
term - The term to be removed.
Returns:
true if Term removed successfully; false otherwise.

removeTerm

public boolean removeTerm(FacetsType termValue)
Removes the Term with the specified value from Terminology.
If the Terminology does not contain the Term, it is unchanged.
Preconditions: The argument must not be null. Postconditions: Checks if listOfTerms Collection contains the specified Term. If yes remove it from listOfTerms and returns true; false otherwise.

Specified by:
removeTerm in interface ITerminology<Type extends FacetsType>
Parameters:
termValue - value of Term to be removed from this Terminology, if present.
Returns:
true if Term removed successfully; false otherwise.

removeTermWithId

public boolean removeTermWithId(int termId)
Removes the Term with the specified id from Terminology. If the Terminology does not contain the Term, it is unchanged.
Preconditions: The argument must not be negative
Postconditions: Checks if Terminology contains a Term with the specified id. If yes then remove it from listOfTerms and returns true; false otherwise.

Specified by:
removeTermWithId in interface ITerminology<Type extends FacetsType>
Parameters:
termId - id of Term to be removed from the Terminology, if present.
Returns:
true if Term removed successfully; false otherwise.

removeTerm

public Term<FacetsType> removeTerm(int index)
Removes the Term at the specified position in this Terminology. Returns the Term that was removed from the Terminology.
Preconditions: THe argument must be into the bounds of Terminology
Postconditions: Checks value of index, if it is ok removes the Term at the specified position of listOfTerms Collection and return it; null otherwise.

Specified by:
removeTerm in interface ITerminology<Type extends FacetsType>
Parameters:
index - the index of the Term to removed.
Returns:
the Term if it is removed successfully; null otherwise.

setTerm

public Term<FacetsType> setTerm(FacetsType termValue)
Add a Term with the specified value to the Terminology.
Preconditions: Argument must not be null.
Postconditions: Creates a Term with specified value and gives to the term as id the sequence number of Terminology then sets the comparability of the Term according to Terminology's comparability and insert it to the Terminology. Finally, increase Terminology's sequence number and if the Term added successfully returns true; false otherwise.

Specified by:
setTerm in interface ITerminology<Type extends FacetsType>
Parameters:
termValue - The value of Term.
Returns:
the Term if it is added successfully; null otherwise.

setTerm

public Term<FacetsType> setTerm(FacetsType termValue,
                                int termId)
Add a Term with the specified value and id to the Terminology.
Preconditions: Term must not be null and termId must not be negative.
Postconditions: Creates a Term with specified value and id then sets the comparability of the Term according to Terminology's comparability. Checks if in Terminology already exists a Term with the same id and if not, insert it to the Terminology. Finally, increase Terminology's sequence number and if the Term added successfully returns true; false otherwise.

Specified by:
setTerm in interface ITerminology<Type extends FacetsType>
Parameters:
termValue - The value of the Term.
termId - the id of the Term.
Returns:
the Term that is added.

setTerm

public boolean setTerm(Term<FacetsType> term)
Adds a Term to Terminology.
Preconditions: Argument must not be null and comparability of Term must be the same with the comparability of the Terminology
Postconditions: Checks if already exists in Terminology any other Term with the same id and if term and Terminology have the same comparability. If everything is ok, adds it to Terminology, gives to the term as id the sequence number of terminology and returns true; false otherwise.

Specified by:
setTerm in interface ITerminology<Type extends FacetsType>
Parameters:
term - the Term to be added.
Returns:
true if Term added successfully; false otherwise.

setName

public void setName(java.lang.String name)
Define the name of Terminology.
Preconditions: Always true.
Postconditions: Sets the value of private variable name as the value of argument name.

Specified by:
setName in interface ITerminology<Type extends FacetsType>
Parameters:
name - the new name of Terminology.

setTerminology

public void setTerminology(java.util.Collection<Term<FacetsType>> terms)
Sets the Terminology. Clears the Terminology and adds all Terms of the Collection to the Terminology. Preconditions: Argument must not be null. Postconditions: Adds to Terminology all The Terms of Collection.

Specified by:
setTerminology in interface ITerminology<Type extends FacetsType>
Parameters:
terms - the Collection of terms that will be added to the Terminology.

setTerms

public boolean setTerms(java.util.Collection<Term<FacetsType>> set)
Adds a Collection of Terms to Terminology.
Preconditions: Argument must not be null.
Postconditions: For every Term of Collection checks if already exists in Terminology, if not inserts it to Terminology. If all Terms of Collection added successfully returns true; false otherwise.

Specified by:
setTerms in interface ITerminology<Type extends FacetsType>
Parameters:
set - Collection of Terms.
Returns:
true if all Terms added successfully; false otherwise.

getTermId

public int getTermId(FacetsType value)
Returns the id of the first Term with the specified value. Preconditions: Argument must not be null. Postconditions: Returns the id of the first Term with the specified value.

Specified by:
getTermId in interface ITerminology<Type extends FacetsType>
Parameters:
value - the value of Term.
Returns:
the id of the first Term with the specified value.

setTermsValues

public boolean setTermsValues(java.util.Collection<Type> set)
Get a Collection of Terms's values, creates Terms with specified values and insert them into Terminology.
Preconditions: Collection must not be null.
Postconditions: For every value of Collection checks if already exists in Terminology any Term with the same value, if not inserts it to Terminology. If all Terms of Collection added successfully returns true; false otherwise.

Specified by:
setTermsValues in interface ITerminology<Type extends FacetsType>
Parameters:
set - Collection of Terms's values.
Returns:
true if all Terms added successfully;false otherwise.

toString

public java.lang.String toString()
Returns a String representation of Terminology. Preconditions: Always true. Postconditions: Append to a STringBuffer all properties of Terminology.

Specified by:
toString in interface ITerminology<Type extends FacetsType>
Overrides:
toString in class java.lang.Object
Returns:
a String representation of Terminology.