aminePlatform.util
Class AmineSet

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractSet
          extended byjava.util.HashSet
              extended byaminePlatform.util.AmineSet
All Implemented Interfaces:
AmineConstants, AmineObject, java.lang.Cloneable, java.util.Collection, Matching, java.io.Serializable, java.util.Set, ToString

public class AmineSet
extends java.util.HashSet
implements java.io.Serializable, AmineObject, Matching, AmineConstants

Title : util.AmineSet Class

Description : Class AmineSet is a specialization of HashSet : Like a Set, no order is applied on the elements of an AmineSet object. Since a concept descriptor can be an AmineSet and in order to have a simple and efficient definition of CG matching operations, we adopt the following restriction on the kinds of elements an AmineSet could contain : each element of an AmineSet should be a simple object : an Integer, a Double, a Boolean, a String, an Identifier, a Type or an Individual CS. An AmineSet can be a descriptor (or contained in a descriptor) of a concept in a CG.

Implements : AmineObject and Matching interfaces

Copyright: Copyright (c) Adil KABBAJ, 2004-2009

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.HashSet
 
Fields inherited from interface aminePlatform.util.AmineConstants
ANALOGY, B_ASSIGN, B_DSPLY_WT_DELAY, B_DSPLY_WTT_DELAY, B_TRIGGER, B_WTT_DSPLY, BLOCK_BACKWARD_PROPAGATION, BLOCK_FORWARD_PROPAGATION, CANON, CGIF, CGRAPHIC, CHECK_PRECONDITIONS, COMPARE, COMPOSED_GOAL, CONCEPT_TYPE_IDENT, CONTEXT, COVERED_BY, CPLTE_CONTRACT, DEFINITION, EQ_OR_MORE_SPCFQ, EQUAL, EXPAND, FALSE_FOCUS_LIST, FUNCTIONAL, GENERALISE, GENERALIZE, HAVE_AN_INTERSECTION, ID_ADD, ID_DIV, ID_EQ, ID_INF, ID_IS, ID_MESSAGE, ID_MUL, ID_NOT, ID_NULL, ID_OPER_AND, ID_OPER_OR, ID_SUB, ID_SUP, IN_ACTIVATION, IN_MODE, IN_MODE2, INDIVIDUAL, INDIVIDUAL_IDENT, INTEGRATED, IS_CANONIC, KEY_GLOBAL_RULE, LC_ADD, LC_AMINE_BOOLEAN, LC_AMINE_DOUBLE, LC_AMINE_INTEGER, LC_AND, LC_BOOLEAN, LC_CG, LC_CLOSE_BRKT, LC_CLOSE_PARENT, LC_CLOSE_SET, LC_COMMA, LC_COMMA_SEMI, LC_CONCEPT, LC_CONSTRUCTOR, LC_CS, LC_CUT, LC_DIFF, LC_DIV, LC_DOUBLE, LC_DSBL_BKWRD_PRPGTN, LC_DSBL_FRWRD_PRPGTN, LC_EOF, LC_EQ, LC_FOUR_POINTS, LC_IDENTIFIER, LC_IF, LC_INF, LC_INTEGER, LC_INTEROG, LC_IS, LC_JAVA_OBJECT, LC_LEFT_ARROW, LC_LIST, LC_NULL, LC_OPEN_BRKT, LC_OPEN_PARENT, LC_OPEN_SET, LC_OPER_AND, LC_OPER_OR, LC_POINT, LC_RELATION, LC_RGHT_ARROW, LC_SEMI_COMMA, LC_SET, LC_STAR, LC_STATE, LC_STRING, LC_SUB, LC_SUP, LC_TERM, LC_TWO_POINTS, LC_VAR_LIST_CONSTRUCTOR, LC_VARIABLE, LF, MAXIMAL_JOIN, MORE_GENERAL, MORE_SPECIFIC, NOTHING_TO_INTEGRATE, OPERS_WITH_RSLT, OUT_MODE, OUT_MODE2, PARTIAL_CONTRACT, PARTIAL_SUBSUME, PRJCT_OPERS, PROJECT, READ, READ_SENTENCE, RELATION_TYPE_IDENT, S_AND, S_BOOLEAN, S_CG, S_CLOSE_BRKT, S_CLOSE_PARENT, S_CLOSE_SET, S_COMMA, S_CONCEPT, S_CONSTRUCTOR, S_CUT, S_DIFF, S_DOUBLE, S_EOF, S_EQUAL, S_EXPAND, S_FALSE, S_FOUR_POINTS, S_GENERALISE, S_GENERALIZE, S_IDENTIFIER, S_IF, S_INTEGER, S_INTEROG, S_IS, S_IS_CANONIC, S_LEFT_ARROW, S_LIST, S_MAXIMAL_JOIN, S_OPEN_BRKT, S_OPEN_PARENT, S_OPEN_SET, S_POINT, S_RGHT_ARROW, S_SEMI_COMMA, S_SOURCE, S_SPECIALIZE, S_STATE, S_STRING, S_SUBSUME, S_SUBSUME_WITH_RESULT, S_SUPER, S_TARGET, S_TERM, S_THIS, S_TRUE, S_TWO_POINTS, S_UNIFY, S_VARIABLE, SITUATION, SPECIALIZE, STEADY, SUBSUME, SUBSUME_WITH_RSLT, TRIGGER, UNCOMPARABLE, UNIFY, VAR_SUPER, WAIT_ASSIGNMENT, WAIT_END_OF_ASSIGNMENT, WAIT_PRECONDITIONS, WAIT_VALUE
 
Constructor Summary
AmineSet()
           
AmineSet(int i)
           
 
Method Summary
 boolean add(java.lang.Object element)
          Override the method add() in order to check that the specified element is a simple object.
 boolean addAll(java.util.Collection c)
          Override the method addAll() in order to check that the elements of the specified collection are simple objects.
static boolean canBeElement(java.lang.Object element)
          Check if the specified element can be an element in an AmineSet object : an Integer, a Double, a Boolean, a String, an Identifier or a Type or an Individual CS.
 void clear()
          Clear the content of the current AmineSet
 java.lang.Object clone(BindingContext bindContext, java.lang.Object bindInf)
          Since no variables could be contained in an AmineSet, this definition is reduced to a simple clone().
 AmineSet copy()
          Return a copy of the current AmineSet.
 boolean equal(BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Check that the current object is equal with the specified object obj.
 boolean equal(java.lang.Object obj)
          Check that the current object is equal with the specified object obj.
 void finalize()
          Implements AmineObject Methods
 java.lang.Object generalize(BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Perform a generalization of the current object with the specified object obj, to determine what is common to the two objects.
 java.lang.Object generalize(java.lang.Object obj)
          Perform a generalization of the current object with the specified object obj, to determine what is common to the two objects.
 void getVariables(java.util.ArrayList varsIdent)
          This method has an empty body since elements of an AmineSet can not be variables.
 AmineSet intersection(AmineSet set)
          Intersection of two sets.
static boolean isAmineSet(java.lang.Object obj)
          Check if the specified Object obj is an AmineSet.
 boolean isMember(java.lang.Object obj)
          Test if the specified object is member of the current set.
 boolean isSubSet(AmineSet set)
          This methods is equivalent to the inherited method containsAll().
 java.lang.Object match(byte matchOperation, BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Match the current object with the specified object obj, according to the value of the parameter matchOperation.
 java.lang.Object match(byte matchOperation, java.lang.Object obj)
          Match the current object with the specified object obj, according to the value of the parameter matchOperation.
 java.lang.Object maximalJoin(BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Perform a maximal join of the current object with the specified object obj.
 java.lang.Object maximalJoin(java.lang.Object obj)
          Perform a maximal join of the current object with the specified object obj.
static AmineSet parse(java.lang.String amineSetInString)
          Parse the textual formulation of an AmineSet (parameter amineSetInString) and return its internal representation (i.e. an AmineList object).
static AmineSet parse(java.lang.String amineSetInString, Lexicon lexicon)
          Parse the textual formulation of an AmineSet (parameter amineSetInString) using the specified lexicon and return its internal representation (i.e. an AmineSet object).
 boolean subsume(BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Check that the current object subsumes (is more general than) the specified object obj.
 boolean subsume(java.lang.Object obj)
          Check that the current object subsumes (is more general than) the specified object obj.
 java.lang.Object subsumeWithResult(BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Check that the current object subsumes (is more general than) the specified object obj.
 java.lang.Object subsumeWithResult(java.lang.Object obj)
          Check that the current object subsumes (is more general than) the specified object obj.
 AmineList toAmineList()
          Create an AmineList object with the content of the current AmineSet.
 java.lang.String toString()
          This method overrides toString() and returns a textual formulation of the current AmineSet.
 java.lang.String toString(BindingContext bindContext, java.lang.Object bindInf, Lexicon lexicon)
          Since this class implements AmineObject interface, it should define this method which is reduced in the case of AmineSet to the simpler version (without binding information).
 java.lang.String toString(Lexicon lexicon)
          Like toString() method, this method returns a textual formulation of the current AmineSet using the specified lexicon.
 boolean unify(BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Unify the current object with the specified object obj.
 AmineSet union(AmineSet set)
          Union of two sets.
 AmineSet union(java.lang.Object obj)
          Add the specified object to the current set.
 
Methods inherited from class java.util.HashSet
clone, contains, isEmpty, iterator, remove, size
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface aminePlatform.util.AmineObject
clone
 
Methods inherited from interface java.util.Set
containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

AmineSet

public AmineSet()

AmineSet

public AmineSet(int i)
Method Detail

finalize

public void finalize()
Implements AmineObject Methods

Specified by:
finalize in interface AmineObject

clear

public void clear()
Clear the content of the current AmineSet

Specified by:
clear in interface AmineObject

copy

public AmineSet copy()
Return a copy of the current AmineSet. This is a shallow copy; the copy is not applied to the elements.

Returns:
a new AmineSet which is a copy of the current AmineSet

clone

public java.lang.Object clone(BindingContext bindContext,
                              java.lang.Object bindInf)
Since no variables could be contained in an AmineSet, this definition is reduced to a simple clone().

Specified by:
clone in interface AmineObject
Parameters:
bindContext - The Binding context
bindInf - The binding information related to the binding context and the current AmineSet
Returns:
a copy of the current AmineSet

getVariables

public void getVariables(java.util.ArrayList varsIdent)
This method has an empty body since elements of an AmineSet can not be variables.

Specified by:
getVariables in interface AmineObject
Parameters:
varsIdent - An ArrayList of variables

toString

public java.lang.String toString(Lexicon lexicon)
                          throws ToStringException
Like toString() method, this method returns a textual formulation of the current AmineSet using the specified lexicon. Note that this definition of toString() does not redefine the inherited method toString() since the present definition takes an argument.

Specified by:
toString in interface ToString
Parameters:
lexicon - The lexicon to use during the textual formulation of the current AmineSet Lexicon is relevant since it could contains references to CS present in the current ontology and so the possibility to express CS in different languages, via the associated identifiers.
Returns:
the textual formulation of the current AmineSet using the specified lexicon
Throws:
ToStringException - if an error occurs during the textual formulation of this AmineSet object.

toString

public java.lang.String toString()
This method overrides toString() and returns a textual formulation of the current AmineSet.

Returns:
the textual formulation of the current AmineSet.

toString

public java.lang.String toString(BindingContext bindContext,
                                 java.lang.Object bindInf,
                                 Lexicon lexicon)
                          throws ToStringException
Since this class implements AmineObject interface, it should define this method which is reduced in the case of AmineSet to the simpler version (without binding information).

Specified by:
toString in interface AmineObject
Parameters:
bindContext - The Binding context
bindInf - The binding information related to the binding context and the current AmineSet
lexicon - The lexicon in use during the textual formulation of the current AmineSet
Returns:
the textual formulation of the current AmineSet using the specified lexicon
Throws:
ToStringException - if an error occurs during the textual formulation of this AmineSet object.

isAmineSet

public static boolean isAmineSet(java.lang.Object obj)
Check if the specified Object obj is an AmineSet.

Parameters:
obj - : an object
Returns:
true if obj is an AmineSet and false otherwise

toAmineList

public AmineList toAmineList()
Create an AmineList object with the content of the current AmineSet.

Returns:
an AmineList copy of the current AmineSet. This is a shallow copy; the two structures will share the same elements.

parse

public static AmineSet parse(java.lang.String amineSetInString,
                             Lexicon lexicon)
                      throws ParsingException
Parse the textual formulation of an AmineSet (parameter amineSetInString) using the specified lexicon and return its internal representation (i.e. an AmineSet object). Lexicon is important because an AmineSet could contain identifiers declared in a lexicon associated to the current ontology. However, lexicon could be null if the text to parse does not require them.

Parameters:
amineSetInString - a textual formulation of an AmineSet
lexicon - The lexicon to use during the parsing
Returns:
the internal representation (Java Object) of the AmineSet
Throws:
throws - ParsingException if an error occurs during the parsing of amineSetInString.
ParsingException

parse

public static AmineSet parse(java.lang.String amineSetInString)
                      throws ParsingException
Parse the textual formulation of an AmineSet (parameter amineSetInString) and return its internal representation (i.e. an AmineList object). This variant does not use a Lexicon (we assume that neither Lexicon nor Ontology is used in this case).

Parameters:
amineSetInString - a textual formulation of an AmineSet
Returns:
the AmineList object that results from the parsing of amineListInString.
Throws:
throws - ParsingException if an error occurs during the parsing of amineListInString.
ParsingException

add

public boolean add(java.lang.Object element)
Override the method add() in order to check that the specified element is a simple object. If this condition holds, the element is added to the current set.

Specified by:
add in interface java.util.Set
Parameters:
element - : an Object
Returns:
true if the addition succeed.

addAll

public boolean addAll(java.util.Collection c)
Override the method addAll() in order to check that the elements of the specified collection are simple objects. If this condition holds, the elements are added to the current set (except for the elements that exist already in the current set).

Specified by:
addAll in interface java.util.Set
Parameters:
c - : a collection of objects
Returns:
true if the addition succeed.

canBeElement

public static boolean canBeElement(java.lang.Object element)
Check if the specified element can be an element in an AmineSet object : an Integer, a Double, a Boolean, a String, an Identifier or a Type or an Individual CS.

Parameters:
element - : an object
Returns:
true if the specified element can be an element in an AmineSet object

isSubSet

public boolean isSubSet(AmineSet set)
This methods is equivalent to the inherited method containsAll().

Parameters:
set - An AmineSet
Returns:
true if set is a subSet of the current set and false otherwise.

union

public AmineSet union(AmineSet set)
Union of two sets. This method is equivalent to a call to copy() of the current set followed by a call to addAll() : create a copy of the current set and add to it all the elements of the specified set that are not in the current set.

Parameters:
set - An AmineSet
Returns:
the union of the current set and the specified set

union

public AmineSet union(java.lang.Object obj)
Add the specified object to the current set. This method is equivalent to a call to copy() of the current set followed by a call to add() : create a copy of the current set and add to it the specified obj if it is a simple object and it is not in the current set.

Parameters:
obj - An Object
Returns:
a copy of the current AmineSet augmented by obj if it is a simple object. Return null if obj is not a simple object.

intersection

public AmineSet intersection(AmineSet set)
Intersection of two sets. This method copies the current set and applies to the copy the method retainAll() : copy the current AmineSet and retain from the copy all the elements that are found in the specified set.

Parameters:
set - An AmineSet
Returns:
the intersection of the current set and the specified set. Return an empty set if the intersection is empty.

isMember

public boolean isMember(java.lang.Object obj)
Test if the specified object is member of the current set. This method is equivalent to the method contains().

Parameters:
obj - An Object
Returns:
true if the specified object obj exists in the current set and false otherwise.

match

public java.lang.Object match(byte matchOperation,
                              java.lang.Object obj)
Match the current object with the specified object obj, according to the value of the parameter matchOperation. This version of matching does not consider the binding context and resolution.

Specified by:
match in interface Matching
Parameters:
matchOperation - A byte value that specifies which kind of matching to apply
obj - The object to match with the current object
Returns:
an object which is the result of the match operation

match

public java.lang.Object match(byte matchOperation,
                              BindingContext bindContext,
                              java.lang.Object bindInf,
                              java.lang.Object obj,
                              java.lang.Object bindInfObj)
Match the current object with the specified object obj, according to the value of the parameter matchOperation. The matching considers the binding context and the binding information for the two objects.

Specified by:
match in interface Matching
Parameters:
matchOperation - A byte value that specifies which kind of matching to apply. Atually, these values are defined in AmineConstants interface and are: EQUAL, UNIFY, SUBSUME, SUBSUME_WITH_RSLT, MAXIMAL_JOIN, and GENERALIZE.
bindContext - The binding context
bindInf - The binding information for the current object
obj - The object to match with the current object
bindInfObj - The binding information for the parameter obj
Returns:
an object which is the result of the match operation

equal

public boolean equal(BindingContext bindContext,
                     java.lang.Object bindInf,
                     java.lang.Object obj,
                     java.lang.Object bindInfObj)
Check that the current object is equal with the specified object obj. The equality is a kind of matching and this version considers the binding context and the binding information for the two objects.

Specified by:
equal in interface Matching
Parameters:
bindContext - The binding context
bindInf - The binding information for the current object
obj - The object to check the equality with the current object
bindInfObj - The binding information for the parameter obj
Returns:
true if the two objects are equal and false otherwise

equal

public boolean equal(java.lang.Object obj)
Check that the current object is equal with the specified object obj. The equality is a kind of matching and this version does not considers the binding context and the binding information for the two objects.

Specified by:
equal in interface Matching
Parameters:
obj - The object to check the equality with the current object
Returns:
true if the two objects are equal and false otherwise

unify

public boolean unify(BindingContext bindContext,
                     java.lang.Object bindInf,
                     java.lang.Object obj,
                     java.lang.Object bindInfObj)
Unify the current object with the specified object obj.

Specified by:
unify in interface Matching
Parameters:
bindContext - The binding context
bindInf - The binding information for the current object
obj - The object to unify with the current object
bindInfObj - The binding information for the parameter obj
Returns:
true if the two objects can be unified and false otherwise

subsume

public boolean subsume(BindingContext bindContext,
                       java.lang.Object bindInf,
                       java.lang.Object obj,
                       java.lang.Object bindInfObj)
Check that the current object subsumes (is more general than) the specified object obj. Subsumption is a kind of matching and this version considers the binding context and the binding information for the two objects.

Specified by:
subsume in interface Matching
Parameters:
bindContext - The binding context
bindInf - The binding information for the current object
obj - The object to check its subsumption by the current object
bindInfObj - The binding information for the parameter obj
Returns:
true if the current object subsumes the specified object obj

subsume

public boolean subsume(java.lang.Object obj)
Check that the current object subsumes (is more general than) the specified object obj. Subsumption is a kind of matching and this version does not considers the binding context and the binding information for the two objects.

Specified by:
subsume in interface Matching
Parameters:
obj - The object to check its subsumption by the current object
Returns:
true if the current object subsumes the specified object obj

subsumeWithResult

public java.lang.Object subsumeWithResult(BindingContext bindContext,
                                          java.lang.Object bindInf,
                                          java.lang.Object obj,
                                          java.lang.Object bindInfObj)
Check that the current object subsumes (is more general than) the specified object obj. Subsumption is a kind of matching and this version considers the binding context and the binding information for the two objects.

Specified by:
subsumeWithResult in interface Matching
Parameters:
bindContext - The binding context
bindInf - The binding information for the current object
obj - The object to check its subsumption by the current object
bindInfObj - The binding information for the parameter obj
Returns:
the image, in obj, of the current object

subsumeWithResult

public java.lang.Object subsumeWithResult(java.lang.Object obj)
Check that the current object subsumes (is more general than) the specified object obj. Subsumption is a kind of matching and this version does not considers the binding context and the binding information for the two objects.

Specified by:
subsumeWithResult in interface Matching
Parameters:
obj - The object to check its subsumption by the current object
Returns:
the image, in obj, of the current object

maximalJoin

public java.lang.Object maximalJoin(BindingContext bindContext,
                                    java.lang.Object bindInf,
                                    java.lang.Object obj,
                                    java.lang.Object bindInfObj)
Perform a maximal join of the current object with the specified object obj. The join considers the binding context and the binding information for the two objects.

Specified by:
maximalJoin in interface Matching
Parameters:
bindContext - The binding context
bindInf - The binding information for the current object
obj - The object to join with the current object
bindInfObj - The binding information for the parameter obj
Returns:
an object which is the result of the join operation

maximalJoin

public java.lang.Object maximalJoin(java.lang.Object obj)
Perform a maximal join of the current object with the specified object obj. This version of join does not considers the binding context and the binding information for the two objects.

Specified by:
maximalJoin in interface Matching
Parameters:
obj - The object to join with the current object
Returns:
an object which is the result of the join operation

generalize

public java.lang.Object generalize(BindingContext bindContext,
                                   java.lang.Object bindInf,
                                   java.lang.Object obj,
                                   java.lang.Object bindInfObj)
Perform a generalization of the current object with the specified object obj, to determine what is common to the two objects. The generalize operation considers the binding context and the binding information for the two objects.

Specified by:
generalize in interface Matching
Parameters:
bindContext - The binding context
bindInf - The binding information for the current object
obj - The object to generalize with the current object
bindInfObj - The binding information for the parameter obj
Returns:
an object which is the result of the generalization operation

generalize

public java.lang.Object generalize(java.lang.Object obj)
Perform a generalization of the current object with the specified object obj, to determine what is common to the two objects. This version of generalize operation does not considers the binding context and the binding information for the two objects.

Specified by:
generalize in interface Matching
Parameters:
obj - The object to generalize with the current object
Returns:
an object which is the result of the generalization operation