aminePlatform.util
Class AmineObjects

java.lang.Object
  extended byaminePlatform.util.AmineObjects
All Implemented Interfaces:
AmineConstants

public class AmineObjects
extends java.lang.Object
implements AmineConstants

Title : util.AmineObjects Class

Description : AmineObjects class concerns aspects that are common to all the Amine data structures. It is a 'pure service' class; it has no attribute, only static methods. Copyright: Copyright (c) Adil KABBAJ, 2004-2009


Field Summary
static byte[] simpleTypes
           
 
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
AmineObjects()
           
 
Method Summary
static void clearHmpOfArrayList(java.util.HashMap hmp)
          Clear the content of a HashMap where values are ArrayList.
static java.lang.Object clone(BindingContext bindContext, java.lang.Object obj, java.lang.Object bindInf)
          A deep copy is performed by the copy methods : elements are copied too and if an element is a variable and variable binding is considered, then the copy operation will concern also the value of variables.
static AmineList enumeration2AmineList(java.util.Enumeration e)
           
static java.util.Iterator enumeration2Iterator(java.util.Enumeration e)
           
static boolean equal(BindingContext bindContext, java.lang.Object obj1, java.lang.Object bindInf, java.lang.Object obj2, java.lang.Object bindInfObj)
          Check if the two specified objects obj1 and obj2 are equal (in content).
static boolean equal(java.lang.Object obj1, java.lang.Object obj2)
          Check if the two specified objects obj1 and obj2 are equal (in content).
static java.lang.Object generalize(BindingContext bindContext, java.lang.Object obj1, java.lang.Object bindInf, java.lang.Object obj2, java.lang.Object bindInfObj)
          Get the generalization of the two specified objects obj1 and obj2.
static java.lang.Object generalize(java.lang.Object obj1, java.lang.Object obj2)
          Get the generalization of the two specified objects obj1 and obj2.
static byte getClassOfObject(java.lang.Object obj)
          Get the class of the specified object obj.
static java.lang.String getName(java.lang.Object obj, Lexicon lexicon)
          Get the name of the object obj in the given lexicon.
static boolean in(byte v, byte[] vctByte)
          Check if the byte v is in the array vctByte.
static boolean isBoolean(java.lang.Object obj)
          Check if the specified Object obj is a Boolean.
static boolean isConform(BindingContext bindContext, java.lang.Object obj, java.lang.Object bindInf)
          Check that conformity constraint is satisfied for an object that can be a CG or it can contain a CG : designator of each concept in a CG must be conform to its concept type.
static boolean isDouble(java.lang.Object obj)
          Check if the specified Object obj is a Double.
static boolean isIdent(java.lang.Object obj)
          Check if the specified Object obj is an Identifier; if obj is an Identifier or it is a Type or an Individual object, both represent (are associated to) identifiers in the context of a multi-lingua ontology.
static boolean isIdentOrString(java.lang.Object obj)
          Check if the specified Object obj is an Identifier or a String.
static boolean isInteger(java.lang.Object obj)
          Check if the specified Object obj is an Integer.
static boolean isNumber(java.lang.Object obj)
          Check if the specified Object obj is a Number; an Integer or a Double.
static boolean isSimpleObject(java.lang.Object obj)
          Check if the class of the specified obj is an elementary class ; an Integer, a Double, a Boolean, a String, an Identifier or a CS object.
static boolean isString(java.lang.Object obj)
          Check if the specified Object obj is a String.
static java.lang.Object match(byte matchOperation, BindingContext bindContext, java.lang.Object obj1, java.lang.Object bindInf, java.lang.Object obj2, java.lang.Object bindInfObj)
          Match the two specified objects obj1 and obj2, according to the value of the parameter matchOperation.
static java.lang.Object match(byte matchOperation, java.lang.Object obj1, java.lang.Object obj2)
          Match the two specified objects obj1 and obj2, according to the value of the parameter matchOperation.
static java.lang.Object maximalJoin(BindingContext bindContext, java.lang.Object obj1, java.lang.Object bindInf, java.lang.Object obj2, java.lang.Object bindInfObj)
          Get the maximal join of the two specified objects obj1 and obj2.
static java.lang.Object maximalJoin(java.lang.Object obj1, java.lang.Object obj2)
          Get the maximal join of the two specified objects obj1 and obj2.
static java.lang.String objsToString(java.lang.Object[] objs, int indCurrElem, BindingContext bindContext, java.lang.Object bindInf, Lexicon lexicon, boolean isList)
          Return the textual formulation of a list of objects.
static java.lang.Object parse(java.lang.String objInString)
           
static java.lang.Object parse(java.lang.String objInString, Lexicon lexicon)
          Parse the textual formulation of an Amine Object (parameter objInString) using the specified lexicon and returns its internal representation (an Amine Object).
static boolean subsume(BindingContext bindContext, java.lang.Object obj1, java.lang.Object bindInf, java.lang.Object obj2, java.lang.Object bindInfObj)
          Check if the first object obj1 subsumes (is more general than) the second object obj2.
static boolean subsume(java.lang.Object obj1, java.lang.Object obj2)
          Check if the first object obj1 subsumes (is more general than) the second object obj2.
static java.lang.Object subsumeWithResult(BindingContext bindContext, java.lang.Object obj1, java.lang.Object bindInf, java.lang.Object obj2, java.lang.Object bindInfObj)
          Check if the first object obj1 subsumes (is more general than) the second object obj2.
static java.lang.Object subsumeWithResult(java.lang.Object obj1, java.lang.Object obj2)
          Check if the first object obj1 subsumes (is more general than) the second object obj2.
static java.lang.String toString(BindingContext bindContext, java.lang.Object obj, java.lang.Object bindInf, Lexicon lexicon)
          Return the textual formulation of an Object.
static java.lang.String toString(java.lang.Object obj)
          Return the textual formulation of an Object.
static java.lang.String toString(java.lang.Object obj, Lexicon lexicon)
          Return the textual formulation of an Object.
static boolean unify(BindingContext bindContext, java.lang.Object obj1, java.lang.Object bindInf, java.lang.Object obj2, java.lang.Object bindInfObj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

simpleTypes

public static byte[] simpleTypes
Constructor Detail

AmineObjects

public AmineObjects()
Method Detail

isInteger

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

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

isDouble

public static boolean isDouble(java.lang.Object obj)
Check if the specified Object obj is a Double.

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

isNumber

public static boolean isNumber(java.lang.Object obj)
Check if the specified Object obj is a Number; an Integer or a Double.

Parameters:
obj - : an object
Returns:
true if obj is a Number (an Integer or a Double) and false otherwise

isBoolean

public static boolean isBoolean(java.lang.Object obj)
Check if the specified Object obj is a Boolean.

Parameters:
obj - : an object
Returns:
true if obj is a Boolean, and false otherwise

isIdentOrString

public static boolean isIdentOrString(java.lang.Object obj)
Check if the specified Object obj is an Identifier or a String. This method calls the method isIdent() to check if obj is an Identifier.

Parameters:
obj - : an object
Returns:
true if obj is an Identifier or a String, and false otherwise

isIdent

public static boolean isIdent(java.lang.Object obj)
Check if the specified Object obj is an Identifier; if obj is an Identifier or it is a Type or an Individual object, both represent (are associated to) identifiers in the context of a multi-lingua ontology.

Parameters:
obj - : an object
Returns:
true if obj is an Identifier or a String, and false otherwise

isString

public static boolean isString(java.lang.Object obj)
Check if the specified Object obj is a String.

Parameters:
obj - : an object
Returns:
true if obj is a String, and false otherwise

enumeration2AmineList

public static AmineList enumeration2AmineList(java.util.Enumeration e)

enumeration2Iterator

public static java.util.Iterator enumeration2Iterator(java.util.Enumeration e)

clone

public static java.lang.Object clone(BindingContext bindContext,
                                     java.lang.Object obj,
                                     java.lang.Object bindInf)
A deep copy is performed by the copy methods : elements are copied too and if an element is a variable and variable binding is considered, then the copy operation will concern also the value of variables. This present method copies the specified object obj. The method identifies if the obj is an AmineObject (it implements the AmineObject interface), or a Muable object (it implements the Muable interface) or a Java object, in the two first cases it calls the clone() method and in the third case, it returns the obj itself..

Parameters:
bindContext - The Binding context
obj - An object
bindInf - The binding information related to the binding context and to obj
Returns:
the copy of obj. Return null if obj is null.

isConform

public static boolean isConform(BindingContext bindContext,
                                java.lang.Object obj,
                                java.lang.Object bindInf)
Check that conformity constraint is satisfied for an object that can be a CG or it can contain a CG : designator of each concept in a CG must be conform to its concept type. This concerns especially the case of a variable as designator: when the variable receives a value, no check is done to see if the variable as designator is conform to the type of the concept.

Parameters:
bindContext -
obj -
bindInf -
Returns:

match

public static java.lang.Object match(byte matchOperation,
                                     java.lang.Object obj1,
                                     java.lang.Object obj2)
Match the two specified objects obj1 and obj2, according to the value of the parameter matchOperation. This version of matching does not consider the binding context and resolution.

Parameters:
matchOperation - A byte value that specifies which kind of matching to apply
obj1 - The object to match
obj2 - The object to match
Returns:
an object which is the result of the match operation

match

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

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
obj1 - The object to match
bindInf - The binding information for obj1
obj2 - The object to match
bindInfObj - The binding information for obj2
Returns:
an object which is the result of the match operation

equal

public static boolean equal(BindingContext bindContext,
                            java.lang.Object obj1,
                            java.lang.Object bindInf,
                            java.lang.Object obj2,
                            java.lang.Object bindInfObj)
Check if the two specified objects obj1 and obj2 are equal (in content). The equality is a kind of matching and this version considers the binding context and the binding information for the two objects.

Parameters:
bindContext - The binding context
obj1 - An object
bindInf - The binding information for obj1
obj2 - An object
bindInfObj - The binding information for obj2
Returns:
true if the two objects are equal and false otherwise

equal

public static boolean equal(java.lang.Object obj1,
                            java.lang.Object obj2)
Check if the two specified objects obj1 and obj2 are equal (in content). This variant of equal does not considers the binding context and the binding information for the two objects.

Parameters:
obj1 - An object
obj2 - An object
Returns:
true if the two objects are equal and false otherwise

unify

public static boolean unify(BindingContext bindContext,
                            java.lang.Object obj1,
                            java.lang.Object bindInf,
                            java.lang.Object obj2,
                            java.lang.Object bindInfObj)
Parameters:
bindContext - The binding context
obj1 - An object
bindInf - The binding information for obj1
obj2 - An object
bindInfObj - The binding information for obj2
Returns:
true if obj1 and obj2 have been unified

subsume

public static boolean subsume(BindingContext bindContext,
                              java.lang.Object obj1,
                              java.lang.Object bindInf,
                              java.lang.Object obj2,
                              java.lang.Object bindInfObj)
Check if the first object obj1 subsumes (is more general than) the second object obj2. Subsumption is a kind of matching and this version considers the binding context and the binding information for the two objects.

Parameters:
bindContext - The binding context
obj1 - An object
bindInf - The binding information for obj1
obj2 - An object
bindInfObj - The binding information for obj2
Returns:
true if the current object subsumes the specified object obj

subsume

public static boolean subsume(java.lang.Object obj1,
                              java.lang.Object obj2)
Check if the first object obj1 subsumes (is more general than) the second object obj2. This variant of subsume does not considers the binding context and the binding information for the two objects.

Parameters:
obj1 - An object
obj2 - An object
Returns:
true if obj1 subsumes (is more general than) obj2

subsumeWithResult

public static java.lang.Object subsumeWithResult(BindingContext bindContext,
                                                 java.lang.Object obj1,
                                                 java.lang.Object bindInf,
                                                 java.lang.Object obj2,
                                                 java.lang.Object bindInfObj)
Check if the first object obj1 subsumes (is more general than) the second object obj2. Subsumption is a kind of matching and this version considers the binding context and the binding information for the two objects.

Parameters:
bindContext - The binding context
obj1 - An object
bindInf - The binding information for obj1
obj2 - An object
bindInfObj - The binding information for obj2
Returns:
the image of obj1 in obj2. The image is in general a subgraph of obj2

subsumeWithResult

public static java.lang.Object subsumeWithResult(java.lang.Object obj1,
                                                 java.lang.Object obj2)
Check if the first object obj1 subsumes (is more general than) the second object obj2. This variant of subsume does not considers the binding context and the binding information for the two objects.

Parameters:
obj1 - An object
obj2 - An object
Returns:
the image of obj1 in obj2. The image is in general a subgraph of obj2

maximalJoin

public static java.lang.Object maximalJoin(BindingContext bindContext,
                                           java.lang.Object obj1,
                                           java.lang.Object bindInf,
                                           java.lang.Object obj2,
                                           java.lang.Object bindInfObj)
Get the maximal join of the two specified objects obj1 and obj2. maximalJoin is a kind of matching and this version considers the binding context and the binding information for the two objects.

Parameters:
bindContext - The binding context
obj1 - An object
bindInf - The binding information for obj1
obj2 - An object
bindInfObj - The binding information for obj2
Returns:
the maximal join of the two objects obj1 and obj2

maximalJoin

public static java.lang.Object maximalJoin(java.lang.Object obj1,
                                           java.lang.Object obj2)
Get the maximal join of the two specified objects obj1 and obj2. This variant of maximalJoin does not considers the binding context and the binding information for the two objects.

Parameters:
obj1 - An object
obj2 - An object
Returns:
the maximal join of the two objects obj1 and obj2

generalize

public static java.lang.Object generalize(BindingContext bindContext,
                                          java.lang.Object obj1,
                                          java.lang.Object bindInf,
                                          java.lang.Object obj2,
                                          java.lang.Object bindInfObj)
Get the generalization of the two specified objects obj1 and obj2. generalize is a kind of matching and this version considers the binding context and the binding information for the two objects.

Parameters:
bindContext - The binding context
obj1 - An object
bindInf - The binding information for obj1
obj2 - An object
bindInfObj - The binding information for obj2
Returns:
the generalization of the two objects obj1 and obj2

generalize

public static java.lang.Object generalize(java.lang.Object obj1,
                                          java.lang.Object obj2)
Get the generalization of the two specified objects obj1 and obj2. This variant of generalization does not considers the binding context and the binding information for the two objects.

Parameters:
obj1 - An object
obj2 - An object
Returns:
the generalization of the two objects obj1 and obj2

parse

public static java.lang.Object parse(java.lang.String objInString,
                                     Lexicon lexicon)
                              throws ParsingException
Parse the textual formulation of an Amine Object (parameter objInString) using the specified lexicon and returns its internal representation (an Amine Object). Lexicon is important because an Amine Object could contain CG as arguments and/or identifiers declared in the specified lexicon. However, lexicon could be null if the text to parse does not require them.

Parameters:
objInString - a textual formulation of an Amine Object
lexicon - The lexicon to use during the parsing
Returns:
the internal representation (Java Object) of the Amine Object
Throws:
ParsingException

parse

public static java.lang.Object parse(java.lang.String objInString)
                              throws ParsingException
Throws:
ParsingException

toString

public static java.lang.String toString(java.lang.Object obj,
                                        Lexicon lexicon)
                                 throws ToStringException
Return the textual formulation of an Object. This definition of toString() doesn't consider the values of variables that could exist in the current Object. Use the method toString(bindContext, obj, bindInf, lexicon) in this case.

Parameters:
obj - An Object
lexicon - The lexicon to use during the textual formulation of the object
Returns:
the textual formulation of obj using the specified lexicon
Throws:
ToStringException - if an error occurs during the textual formulation of obj.

toString

public static java.lang.String toString(java.lang.Object obj)
                                 throws ToStringException
Return the textual formulation of an Object. This definition of toString() doesn't consider the values of variables that could exist in the current Object, neither the presence of a lexicon. Use the method toString(bindContext, obj, bindInf, lexicon) in this case.

Parameters:
obj - An Object
Returns:
the textual formulation of obj
Throws:
ToStringException - if an error occurs during the textual formulation of obj.

toString

public static java.lang.String toString(BindingContext bindContext,
                                        java.lang.Object obj,
                                        java.lang.Object bindInf,
                                        Lexicon lexicon)
                                 throws ToStringException
Return the textual formulation of an Object. Like the other methods in this class, this one is sensitive to the variable binding: if obj is an AmineObject (implements the AmineOject interface), then calls toString(bindContext, bindInf, lexicon) on obj, if obj is a ToString object (it implements the ToString interface) then calls toString(lexicon) on obj, else the method calls the default toString() method.

Parameters:
bindContext - The Binding context
obj - An Object
bindInf - The binding information related to the binding context and to obj
lexicon - The lexicon to use during the textual formulation of the object
Returns:
a String that represents the textual formulation of obj.
Throws:
ToStringException - if an error occurs during the textual formulation of obj.

objsToString

public static java.lang.String objsToString(java.lang.Object[] objs,
                                            int indCurrElem,
                                            BindingContext bindContext,
                                            java.lang.Object bindInf,
                                            Lexicon lexicon,
                                            boolean isList)
                                     throws ToStringException
Return the textual formulation of a list of objects. The method is sensitive to the variable binding problem.

Parameters:
objs - An array of Objects
indCurrElem - The index in objs for the element to start with.
bindContext - The Binding context
bindInf - The binding information related to the binding context and to objs
lexicon - The lexicon in use during the textual formulation
isList - true if objs are elements of an AmineList and false otherwise.
Returns:
a String that represents the textual formulation of objs.
Throws:
ToStringException

getName

public static java.lang.String getName(java.lang.Object obj,
                                       Lexicon lexicon)
                                throws ToStringException
Get the name of the object obj in the given lexicon.

Parameters:
obj - could be null, an Identifier, a Variable, a Type CS or an Individual CS object.
lexicon - The lexicon to consider
Returns:
If obj is a Type or an Individual CS, then returns the associated identifier name in the specified lexicon, If obj is an identifier or a string, the identifier name is returned, otherwise returns null.
Throws:
ToStringException

getClassOfObject

public static byte getClassOfObject(java.lang.Object obj)
Get the class of the specified object obj.

Parameters:
obj - : an object
Returns:
a byte that represents the class of obj.

isSimpleObject

public static boolean isSimpleObject(java.lang.Object obj)
Check if the class of the specified obj is an elementary class ; an Integer, a Double, a Boolean, a String, an Identifier or a CS object.

Parameters:
obj - An Object
Returns:
true if obj is of an elementary class and false otherwise.

clearHmpOfArrayList

public static void clearHmpOfArrayList(java.util.HashMap hmp)
Clear the content of a HashMap where values are ArrayList. For instance, the HashMap returned by lexicons.Lexicon#getAllIdentifiers(CS) is of this form.

Parameters:
hmp - A HashMap of ArrayList

in

public static boolean in(byte v,
                         byte[] vctByte)
Check if the byte v is in the array vctByte.

Parameters:
v - A byte value
vctByte - An array of byte
Returns:
true if the byte v is in the array vctByte