aminePlatform.util
Class Variable

java.lang.Object
  extended byaminePlatform.kernel.lexicons.Identifier
      extended byaminePlatform.util.Variable
All Implemented Interfaces:
AmineConstants, AmineObject, java.lang.Cloneable, java.lang.Comparable, Matching, Muable, java.io.Serializable, ToString
Direct Known Subclasses:
VarListConstructor

public class Variable
extends Identifier
implements java.io.Serializable, AmineObject, Matching, AmineConstants

Title : util.Variable Class

Description : a Variable is an identifier that represents a variable. A variable identifier should start with a letter followed optionally by a digit or underscore. After the digit or the underscore, a variable can have any sequence of characters. A variable identifier can begin also with an underscore followed optionally by any sequence of characters. There is also special cases of identifiers "super", "this", "x_source", and "y_target" that are considered as variables.

Variable is explicitly defined to avoid the check, at each time, of the identifier in order to infer if it is a variable identifier or a constant identifier.

It is only in a programming context, like PROLOG+CG, SYNERGY or other programming contexts that the binding relation concerning a variable is considered; that the associated value is looked for and the substitution is done.

Note also that the value of a variable, once the association is considered, is not specified directly as an attribute of the class Variable. The association is specified and treated in the context of each programming context (PROLOG+CG, SYNERGY or any other context).

Subclasses : VarListConstructor.

Implements : AmineObject and Matching interfaces

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

See Also:
Serialized Form

Field Summary
static Variable SUPER
           
static Variable THIS
           
 
Fields inherited from class aminePlatform.kernel.lexicons.Identifier
id, ignoreCase, name
 
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
Variable(java.lang.String s)
           
 
Method Summary
 void clear()
          Method from the interface AmineObject.
 java.lang.Object clone()
          Return a clone of the object without considering binding context and resolution.
 java.lang.Object clone(BindingContext bindContext, java.lang.Object bindInf)
          This method is equivalent to copy(bindContext, bindInf).
 java.lang.Object copy(BindingContext bindContext, java.lang.Object bindInf)
          Perform a copy of the current variable, taking into account the variable binding; the copy will concern the variable's value instead.
 boolean equal(BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Check that the current variable 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.
 boolean equals(java.lang.Object obj)
          Override the method equals().
 void finalize()
          Method from the interface AmineObject.
 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.
static Variable generateNewVariable()
          Generate a new variable identifier.
 java.lang.String getDefinitionalBoundForm()
          If the variable is a refered bound label (i.e. it starts with '?')
 java.lang.String getReferedBoundForm()
          If the variable is a definitional label (i.e. it starts with '*'), then returns the bound form; the same label but the char '*' is replaced by '?'
 void getVariables(java.util.ArrayList varsIdent)
          This method adds the current variable in the specified varsIdent if it is not already in the ArrayList varsIdent.
static boolean isAnonymousVariable(java.lang.Object obj)
          Check if the specified obj is an anonymous variable; represented by an underscore
 boolean isBoundCoreferent()
          This method returns true if the variable starts with "?"
 boolean isDefinitionalCoreferent()
          This method returns true if the variable starts with "*" (i.e. a definitional bound label)
static boolean isVariable(java.lang.Object obj)
          Check if the specified Object obj is a Variable (and so, a VarListConstructor which is a subclass of Variable).
static boolean isVariableName(java.lang.String name)
           
 java.lang.Object match(byte matchOperation, BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Match two variables by looking to their values and then matching these values.
 java.lang.Object match(byte matchOperation, java.lang.Object obj)
          Match two variables.
 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 int nextCount()
          Increment a counter that is used for the generation of variable identifiers
 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.
 java.lang.String toString(BindingContext bindContext, java.lang.Object bindInf, Lexicon lexicon)
          Return the textual formulation of the variable, taking into account the variable binding: if the binding is not null, the method will consider the textual formulation of the variable's value, not the variable itself.
 java.lang.String toString(Lexicon lexicon)
          Return the textual formulation of the variable (the name of the variable).
 boolean unify(BindingContext bindContext, java.lang.Object bindInf, java.lang.Object obj, java.lang.Object bindInfObj)
          Unify the current CG with the specified object obj.
 
Methods inherited from class aminePlatform.kernel.lexicons.Identifier
compareTo, copy, getIgnoreCase, getName, hashCode, isCorrectIdentName, isIdentifier, isIgnoreCase, setIgnoreCase, setName, toString, wrap
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SUPER

public static Variable SUPER

THIS

public static Variable THIS
Constructor Detail

Variable

public Variable(java.lang.String s)
Method Detail

equals

public boolean equals(java.lang.Object obj)
Description copied from class: Identifier
Override the method equals(). The method tests if two identifiers are equal. The test takes into account the value of the static attribute ignoreCase (true or false): if ignoreCase is true, the method calls equalsIgnoreCase(), else it calls the method equals().

Overrides:
equals in class Identifier
Parameters:
obj - An Object
Returns:
true if the current identifier is equal to obj taking int account the value of the parameter ignoreCase.

isVariable

public static boolean isVariable(java.lang.Object obj)
Check if the specified Object obj is a Variable (and so, a VarListConstructor which is a subclass of Variable).

Parameters:
obj - : an object
Returns:
true if obj is a Variable (or a VarListConstructor) and false otherwise

isVariableName

public static boolean isVariableName(java.lang.String name)

isAnonymousVariable

public static boolean isAnonymousVariable(java.lang.Object obj)
Check if the specified obj is an anonymous variable; represented by an underscore

Parameters:
obj - A Variable
Returns:
true if if the specified obj is an anonymous variable; represented by an underscore

nextCount

public static int nextCount()
Increment a counter that is used for the generation of variable identifiers

Returns:
the new value of the counter

generateNewVariable

public static Variable generateNewVariable()
Generate a new variable identifier. Such an identifier has the form: _v followed by an integer.

Returns:
a new variable identifier

isDefinitionalCoreferent

public boolean isDefinitionalCoreferent()
This method returns true if the variable starts with "*" (i.e. a definitional bound label)

Returns:
boolean

isBoundCoreferent

public boolean isBoundCoreferent()
This method returns true if the variable starts with "?" (i.e. a refered bound label)

Returns:
boolean

getReferedBoundForm

public java.lang.String getReferedBoundForm()
If the variable is a definitional label (i.e. it starts with '*'), then returns the bound form; the same label but the char '*' is replaced by '?'

Returns:
String

getDefinitionalBoundForm

public java.lang.String getDefinitionalBoundForm()
If the variable is a refered bound label (i.e. it starts with '?'), then returns the definitional bound form; the same label but the char '?' is replaced by '*'

Returns:
String

clear

public void clear()
Method from the interface AmineObject. An "empty" definition is provided

Specified by:
clear in interface AmineObject

finalize

public void finalize()
Method from the interface AmineObject. An "empty" definition is provided

Specified by:
finalize in interface AmineObject

toString

public java.lang.String toString(Lexicon lexicon)
                          throws ToStringException
Return the textual formulation of the variable (the name of the variable). This definition is a special case of the defnition toString(bindContext, bindInf, lexicon) which takes into account the variable binding.

Specified by:
toString in interface ToString
Parameters:
lexicon - The lexicon to use during the textual formulation of the current concept
Returns:
a String that represents the linear form of the current concept.
Throws:
ToStringException - if an error occurs during the textualization

toString

public java.lang.String toString(BindingContext bindContext,
                                 java.lang.Object bindInf,
                                 Lexicon lexicon)
                          throws ToStringException
Return the textual formulation of the variable, taking into account the variable binding: if the binding is not null, the method will consider the textual formulation of the variable's value, not the variable itself.

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

clone

public java.lang.Object clone()
Description copied from interface: AmineObject
Return a clone of the object without considering binding context and resolution.

Specified by:
clone in interface AmineObject
Overrides:
clone in class Identifier
Returns:
a clone of the current Identifier

clone

public java.lang.Object clone(BindingContext bindContext,
                              java.lang.Object bindInf)
This method is equivalent to copy(bindContext, bindInf). This clone() method considers the case of variable 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 variable
Returns:
a clone of the current variable (or of its value)

copy

public java.lang.Object copy(BindingContext bindContext,
                             java.lang.Object bindInf)
Perform a copy of the current variable, taking into account the variable binding; the copy will concern the variable's value instead.

Parameters:
bindContext - The Binding context
bindInf - The binding information related to the binding context and to the current variable
Returns:
a copy of the current variable (or of its value). Return null if variable is null.

getVariables

public void getVariables(java.util.ArrayList varsIdent)
This method adds the current variable in the specified varsIdent if it is not already in the ArrayList varsIdent. Nothing is done if the parameter varsIdent is null.

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

match

public java.lang.Object match(byte matchOperation,
                              java.lang.Object obj)
Match two variables.

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 CG
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 two variables by looking to their values and then matching these values.

Specified by:
match in interface Matching
Parameters:
matchOperation - A byte value that specifies which kind of matching to apply
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 variable 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 CG 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 CG 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