aminePlatform.kernel.lexicons
Class Identifier

java.lang.Object
  extended byaminePlatform.kernel.lexicons.Identifier
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, Muable, java.io.Serializable
Direct Known Subclasses:
Variable

public class Identifier
extends java.lang.Object
implements java.io.Serializable, Muable, java.lang.Cloneable, java.lang.Comparable

Title : lexicons.Identifier Class

Description : In general, an identifier is used in Amine Platform to specify 'words' of languages (english, french, arabic, etc.) and identifiers of a language are associated to Conceptual Structures (CS) to form entries of the language's lexicon. CSs are in general interconnected and compose a (conceptual) ontology. CSs are defined in the package ontology.

An identifier has a name which is a String. An identifier is a word that should start with an alphabetic character (underscore '_' is considered as an alphabetic character) and followed by zero or more alphabetic or digit characters. Please note that identifiers should not contain spaces.

A static attribute, the boolean 'ignoreCase' which is common to all the identifiers, is defined in this class (Identifier) to switch on/off the consideration of case. Comparison methods, like equals() and hashCode() are overriden to take into account this possibility. If the user wants to ignore case, he should assign true to the 'ignoreCase' attribute, i.e. by calling Identifier.setIgnoreCase(true). If he does not want to ignore case, he should assign false : Identifier.setIgnoreCase(false). By default, the 'ignoreCase' attribute is initialized to true.

Note: since the class Variable is a subclass of Identifier, it inherits the possibility to ignore or not case.

Subclasses : util.Variable

Implements : The class Identifier implements the interface Muable, which means that an Identifier is an Amine simple object and its value can be changed (i.e., its value is muable).

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

See Also:
Serialized Form

Field Summary
protected static Identifier id
          A static attribute used to wrap a name (a String) in an Identifier form
protected static boolean ignoreCase
          A static attribute that functions as a switcher, for all the identifiers, to activate/de-activate the option to ignore (or not) case in the identifiers.
protected  java.lang.String name
          An identifier has a name
 
Constructor Summary
Identifier(java.lang.String s)
          Construct a new Identifier with the specified name.
 
Method Summary
 java.lang.Object clone()
          Get a clone of the current identifier
 int compareTo(java.lang.Object obj)
           
 Identifier copy()
          Get a copy of the current identifier.
 boolean equals(java.lang.Object obj)
          Override the method equals().
static boolean getIgnoreCase()
          Get the value of the ignoreCase static attribute, true or false
 java.lang.String getName()
          Get the name of the current identifier.
 int hashCode()
          Override the method hashCode() which takes into account the treatment of case.
static boolean isCorrectIdentName(java.lang.String name)
           
static boolean isIdentifier(java.lang.Object obj)
          Check if the specified obj is an Identifier
static boolean isIgnoreCase()
          Check if the value of the ignoreCase static attribute is true.
static void setIgnoreCase(boolean b)
          Change the value of the ignoreCase static attribute to the specified value b.
 void setName(java.lang.String newName)
          Change the name of the current identifier to the specified name.
 java.lang.String toString()
          Return the name of the current Identifier
static Identifier wrap(java.lang.String s)
          This static method wraps the given string s as an identifier.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ignoreCase

protected static boolean ignoreCase
A static attribute that functions as a switcher, for all the identifiers, to activate/de-activate the option to ignore (or not) case in the identifiers. This attribute is set to true by default.


id

protected static Identifier id
A static attribute used to wrap a name (a String) in an Identifier form


name

protected java.lang.String name
An identifier has a name

Constructor Detail

Identifier

public Identifier(java.lang.String s)
Construct a new Identifier with the specified name.

Parameters:
s - The name for the new identifier
Method Detail

compareTo

public int compareTo(java.lang.Object obj)
Specified by:
compareTo in interface java.lang.Comparable

getName

public java.lang.String getName()
Get the name of the current identifier.

Returns:
the name of the current identifier

setName

public void setName(java.lang.String newName)
Change the name of the current identifier to the specified name.

Parameters:
newName - The name for the current identifier

isCorrectIdentName

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

getIgnoreCase

public static boolean getIgnoreCase()
Get the value of the ignoreCase static attribute, true or false

Returns:
the value of the ignoreCase static attribute, true or false

isIgnoreCase

public static boolean isIgnoreCase()
Check if the value of the ignoreCase static attribute is true.

Returns:
true if the ignoreCase static attribute is true

setIgnoreCase

public static void setIgnoreCase(boolean b)
Change the value of the ignoreCase static attribute to the specified value b.

Parameters:
b - A boolean that indicates if case will be ignored (b = true) or not (b = false).

isIdentifier

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

Parameters:
obj - An object
Returns:
true if the specified obj is an Identifier

wrap

public static Identifier wrap(java.lang.String s)
This static method wraps the given string s as an identifier. The method doesn't create a new Identifier object, rather it use the same static attribute id to wrap a string as an identifier, to do comparison for instance. To iterate, please note that it is always the same (static) Identifier object that is returned with the name specified in argument.

Returns:
the static attribute id (an Identifier) with s as the value of its name attribute.

equals

public boolean equals(java.lang.Object obj)
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().

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

hashCode

public int hashCode()
Override the method hashCode() which takes into account the treatment of case. If the static attribute ignoreCase is true, the method returns the hashCode of the lowerCase copy of the current identifier name, otherwise the method returns the hashCode of the identifier name.

Returns:
the hashCode of the current Identifier

clone

public java.lang.Object clone()
Get a clone of the current identifier

Specified by:
clone in interface Muable
Returns:
a clone of the current Identifier

copy

public Identifier copy()
Get a copy of the current identifier. This method is equivalent to clone() except that it returns an Identifier, not an object (that should be cast to Identifier).

Returns:
a copy of the current Identifier

toString

public java.lang.String toString()
Return the name of the current Identifier

Returns:
the name of the current Identifier