aminePlatform.util
Class AmineList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended byaminePlatform.util.AmineList
All Implemented Interfaces:
AmineConstants, AmineObject, java.lang.Cloneable, java.util.Collection, java.util.List, Matching, java.util.RandomAccess, java.io.Serializable, ToString
Direct Known Subclasses:
Term

public class AmineList
extends java.util.ArrayList
implements java.io.Serializable, AmineObject, Matching, AmineConstants

Title : util.AmineList Class

Description : AmineList is a specialization of ArrayList and implements the List structure (as used in Prolog-like language). Elements of an AmineList can be any Amine Platform object : Integer, Double, String, Boolean, Identifier, Variable, AmineList, AmineSet, Term, Concept, CG, CS or any Java Object. An AmineList can be a descriptor (or contained in a descriptor) of a concept in a CG.

Subclasses : Term.

Implements : AmineObject and Matching interfaces

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

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
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
AmineList()
           
AmineList(java.util.Collection c)
           
AmineList(int i)
           
 
Method Summary
 void clear()
          Clear the content of the current list.
 java.lang.Object clone(BindingContext bindContext, java.lang.Object bindInf)
          This method is equivalent to copy(bindContext, bindInf).
 AmineList copy()
          Unlike the inherited method clone(), this method returns a deep copy of the current AmineList (the elements are copied too) but it does not consider the values of variables that could exist in the current list.
 AmineList copy(BindingContext bindContext, java.lang.Object bindInf)
          Perform a deep copy of the current list (elements are themselves copied).
 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()
          Finalize the current AmineList.
 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)
          Add, in the specified parameter varsIdent, all the variables that occur in the current AmineList.
static boolean isAmineList(java.lang.Object obj)
          Check if the specified Object obj is an AmineList.
 boolean isMember(BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Test if the object obj is member of the current AmineList. if no element in the list is equal to obj and if the list terminates with a constructor and this later has a value (if the binding is considered), then a recursive test is done; check if obj is a member of the list which is the value of the constructor variable.
 boolean isMember(java.lang.Object obj)
          Check if the specified obj is an element, comparison by content, of the current list.
protected  java.lang.Object match(byte matchOperation, BindingContext bindContext, java.lang.Object bindInf, int indCurrElem1, java.lang.Object obj, java.lang.Object bindInfObj, int indCurrElem2)
          Test the matching of two AmineList starting from two specified ranges.
 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 AmineList parse(java.lang.String amineListInString)
          Parse the textual formulation of an AmineList (parameter amineListInString) and return its internal representation (i.e. an AmineList object).
static AmineList parse(java.lang.String amineListInString, Lexicon lexicon)
          Parse the textual formulation of an AmineList (parameter amineListInString) using the specified lexicon and return its internal representation (i.e. an AmineList 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.
 AmineSet toAmineSet()
          Create an AmineSet copy of the current AmineList.
 java.lang.String toString()
          Override toString() by calling toString(null, null, null) which formulates the content of the current list
 java.lang.String toString(BindingContext bindContext, java.lang.Object bindInf, Lexicon lexicon)
          This method returns the textual formulation of the current AmineList.
 java.lang.String toString(Lexicon lexicon)
          Like toString() method, this method returns the textual formulation of the content of the current AmineList, using the specified lexicon.
 Term toTerm()
           
 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.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
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.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Constructor Detail

AmineList

public AmineList()

AmineList

public AmineList(java.util.Collection c)

AmineList

public AmineList(int i)
Method Detail

finalize

public void finalize()
Finalize the current AmineList. Finalize performs a "weak" destruction: it will not destroy the structures that could be included in the amineList because those structures could be shared with other structures (in the context of Prolog+CG for instance). Use the method clear() for a "strong" destruction.

Specified by:
finalize in interface AmineObject

clear

public void clear()
Clear the content of the current list. This method should be used with care since it will clear the structures that could be included in the list (it performs a recursive clear on any object that implements AmineObject). Such a destruction could not be safe if the structures are shared with other structures (in the context of Prolog+CG for instance). In such a context use the method finalize() instead.

Specified by:
clear in interface AmineObject

getVariables

public void getVariables(java.util.ArrayList varsIdent)
Add, in the specified parameter varsIdent, all the variables that occur in the current AmineList.

Specified by:
getVariables in interface AmineObject
Parameters:
varsIdent - : an ArrayList of Variable objects.

toString

public java.lang.String toString(Lexicon lexicon)
                          throws ToStringException
Like toString() method, this method returns the textual formulation of the content of the current AmineList, using the specified lexicon. This definition of toString() does not redefine the inherited method toString() since the current one takes an argument. Note also that this method ignores the variable binding, so use toString(bindContext, bindInf, lexicon) if variable binding has to be considered.

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

toString

public java.lang.String toString()
Override toString() by calling toString(null, null, null) which formulates the content of the current list

Returns:
the textual formulation of the current AmineList

toString

public java.lang.String toString(BindingContext bindContext,
                                 java.lang.Object bindInf,
                                 Lexicon lexicon)
                          throws ToStringException
This method returns the textual formulation of the current AmineList. If variable binding is considered, the values of the variables will be textualized too.

Specified by:
toString in interface AmineObject
Parameters:
bindContext - The Binding context
bindInf - The binding information related to the binding context and the current AmineList
lexicon - The lexicon in use during the textual formulation of the current AmineList
Returns:
a String that represents the linear form of the current AmineList.
Throws:
ToStringException - if an error occurs during the textualization

isAmineList

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

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

toAmineSet

public AmineSet toAmineSet()
Create an AmineSet copy of the current AmineList.

Returns:
an AmineSet copy of the current AmineList. This is a shallow copy; the two structures will share the same elements. Return null however if an element of this AmineList is not a simple object (i.e. an Integer, a Double, a Boolean, a String, an Identifier, a Type or an Individual CS)

toTerm

public Term toTerm()

parse

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

Parameters:
amineListInString - a textual formulation of an AmineList
lexicon - The lexicon to use for the parsing
Returns:
the AmineList object that results from the parsing of amineListInString.
Throws:
throws - ParsingException if an error occurs during the parsing of amineListInString.
ParsingException

parse

public static AmineList parse(java.lang.String amineListInString)
                       throws ParsingException
Parse the textual formulation of an AmineList (parameter amineListInString) 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:
amineListInString - a textual formulation of an AmineList
Returns:
the AmineList object that results from the parsing of amineListInString.
Throws:
throws - ParsingException if an error occurs during the parsing of amineListInString.
ParsingException

clone

public java.lang.Object clone(BindingContext bindContext,
                              java.lang.Object bindInf)
This method is equivalent to copy(bindContext, bindInf). Also, this definition considers the presence of variables and their binding.

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

copy

public AmineList copy()
Unlike the inherited method clone(), this method returns a deep copy of the current AmineList (the elements are copied too) but it does not consider the values of variables that could exist in the current list. Use the method copy(bindContext, bindInf) if variable binding should be considered.

Returns:
a copy of the current list (we consider here variables without their values).

copy

public AmineList copy(BindingContext bindContext,
                      java.lang.Object bindInf)
Perform a deep copy of the current list (elements are themselves copied). If this list terminates with a list constructor and variable binding is considered, then a recursive copy is done to the value of the variable.

Parameters:
bindContext - The Binding context
bindInf - The binding information related to the binding context and to the current AmineList
Returns:
an AmineList object which is a copy of list. Return null if list is null.

isMember

public boolean isMember(java.lang.Object obj)
Check if the specified obj is an element, comparison by content, of the current list. This definition of member does not consider the values of variables. Use the method isMember(bindContext, ObindInf, obj, bindInfObj) if variables values should be considered.

Parameters:
obj - : an Object
Returns:
true if obj is an element, comparison by content, of the current list and false otherwise

isMember

public boolean isMember(BindingContext bindContext,
                        java.lang.Object bindInf,
                        java.lang.Object obj,
                        java.lang.Object bindInfObj)
Test if the object obj is member of the current AmineList. if no element in the list is equal to obj and if the list terminates with a constructor and this later has a value (if the binding is considered), then a recursive test is done; check if obj is a member of the list which is the value of the constructor variable.

Parameters:
bindContext - The Binding context
bindInf - The binding information related to the binding context and to the current list
obj - The object to test the appartenance in the current list
bindInfObj - The binding information related to the binding context and to obj
Returns:
true if obj is a member of the current list and false otherwise (if obj is not a member or if obj is null).

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

match

protected java.lang.Object match(byte matchOperation,
                                 BindingContext bindContext,
                                 java.lang.Object bindInf,
                                 int indCurrElem1,
                                 java.lang.Object obj,
                                 java.lang.Object bindInfObj,
                                 int indCurrElem2)
Test the matching of two AmineList starting from two specified ranges.

Parameters:
bindContext - The Binding context
bindInf - The binding information related to the binding context and to the current list
indCurrElem1 - The range of the element in the current list from which the test should start
obj - The object to test the equality with the current list
bindInfObj - The binding information related to the binding context and to obj
indCurrElem2 - The range of the element in obj from which the test should start
Returns:
true if the two AmineList are equals and false otherwise

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