|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectai.krr.SyntaxAdaptableSymbol
ai.krr.NamedSymbol
public class NamedSymbol
This class implements part of the foundations for symbolic programming in
Java. A NamedSymbol
consists of a String that is its name and
the NameSpace
to which it belongs. NamedSymbol
s are
memory unique objects, i.e. there are no two NamedSymbol
s that
are equal, but not the same Object in memory.
NamedSymbol
s are maintained in their NameSpace
. This is
why there is no public constructor provided by the class; instead, the
NameSpace
that will own the NamedSymbol
may create
a new NamedSymbol
. However, a NamedSymbol
may be
created as strictly internal in which case it does not belong to a
NameSpace
. Use the static function getInternalSymbol(java.lang.String)
to
get hold of this type of symbol.
NamedSymbol
s are primarily ordered by the NameSpace
they
belong to, and secondarily by their name.
NameSpace
Constructor Summary | |
---|---|
protected |
NamedSymbol(NameSpace ns,
java.lang.String name)
This constructor creates a new NamedSymbol that has the given name and belongs to the given NameSpace . |
Method Summary | |
---|---|
protected java.lang.Object |
clone()
This class does not support cloning and an Exception will be thrown if this method is called. |
int |
compareTo(NamedSymbol namedSy)
This function compares this NamedSymbol to the given NamedSymbol. |
int |
compareTo(Symbol sy)
This function compares this NamedSymbol to the given Symbol . |
int |
getClassOrderIndex()
This function returns the index used for ordering Symbols across different classes. |
static NamedSymbol |
getInternalSymbol(java.lang.String name)
This function must be used to obtain a new or the existing internal NamedSymbol for the given name. |
java.lang.String |
getName()
This function returns the name of this NamedSymbol. |
NameSpace |
getNameSpace()
This function returns the NameSpace to which this NamedSymbol
belongs. |
int |
hashCode()
This function computes a hash value for this symbol by combining the hashCode() of the name with the hashCode() of the NameSpace. |
boolean |
isInternal()
This function returns whether this NamedSymbol is internal. |
boolean |
isNamedSymbol()
This function tests whether this Symbol is a NamedSymbol. |
java.lang.String |
toString()
This function returns a printable representation of this NamedSymbol which is the URI for its NameSpace followed by the hash character followed by the name of the symbol. |
java.lang.String |
toString(java.util.Map<NameSpace,java.lang.String> proxies)
This function returns a printable representation of this NamedSymbol which is an abbreviation for the NameSpace from the given Map followed by the colon character followed by the name of the symbol. |
Methods inherited from class ai.krr.SyntaxAdaptableSymbol |
---|
isBooleanSymbol, isNumericSymbol, prettyPrint, read, write |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected NamedSymbol(NameSpace ns, java.lang.String name)
This constructor creates a new NamedSymbol that has the given name and
belongs to the given NameSpace
. The given name must not be null
or the empty String. The NameSpace may be null in which case this
NamedSymbol is is considered to be strictly internal.
ns
- the NameSpace that owns this NamedSymbolname
- the name given to this NamedSymbol; null for internalMethod Detail |
---|
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
This class does not support cloning and an Exception will be thrown if this method is called.
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- will be thrownpublic int getClassOrderIndex()
This function returns the index used for ordering Symbols across different classes. This index of this class is defined to be 224.
public boolean isNamedSymbol()
This function tests whether this Symbol
is a NamedSymbol.
isNamedSymbol
in interface Symbol
isNamedSymbol
in class SyntaxAdaptableSymbol
public int compareTo(Symbol sy)
This function compares this NamedSymbol to the given Symbol
. The
order between different kinds of Symbols is arbitrarily defined as
(ascending): BooleanSymbol
, NumericSymbol
,
CharacterSymbol
, StringSymbol
, AnonymousSymbol
,
NamedSymbol.
sy
- the Symbol to which this Symbol is to be compared
public final NameSpace getNameSpace()
This function returns the NameSpace
to which this NamedSymbol
belongs.
public final java.lang.String getName()
This function returns the name of this NamedSymbol. The result is not the same as that of toString() as the name does not include any reference to the NameSpace.
public boolean isInternal()
This function returns whether this NamedSymbol is internal. This is true iff it does not belong to a NameSpace.
public int compareTo(NamedSymbol namedSy)
This function compares this NamedSymbol to the given NamedSymbol. Two
NamedSymbols in the same NameSpace
are compared by name.
Otherwise the order is determined by the order of the NameSpaces.
Internal NamedSymbols that have no NameSpace precede other NamedSymbols.
namedSy
- the NamedSymbol to which this NamedSymbol is compared
public final int hashCode()
This function computes a hash value for this symbol by combining the hashCode() of the name with the hashCode() of the NameSpace.
hashCode
in class java.lang.Object
public java.lang.String toString()
This function returns a printable representation of this NamedSymbol which is the URI for its NameSpace followed by the hash character followed by the name of the symbol.
toString
in class java.lang.Object
public java.lang.String toString(java.util.Map<NameSpace,java.lang.String> proxies)
This function returns a printable representation of this NamedSymbol which is an abbreviation for the NameSpace from the given Map followed by the colon character followed by the name of the symbol.
proxies
- the abbreviation table for NameSpace URIs
public static NamedSymbol getInternalSymbol(java.lang.String name)
This function must be used to obtain a new or the existing internal NamedSymbol for the given name. Note: the given String must not be null or the empty String.
name
- the name of the internal symbol that will be returned
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |