Class AtomicTerm
java.lang.Object
com.tangosol.coherence.dsltools.termtrees.Term
com.tangosol.coherence.dsltools.termtrees.AtomicTerm
AtomicTerms is the class used to represent literal Terms such as String
and Numbers. The functor() method for AtomicTerms return a type name for
the stored literals.
- Author:
- djl 2009.08.31
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.coherence.dsltools.termtrees.Term
Term.TermIterator
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The numberic code for a boolean literalstatic final int
The numberic code for a double literalstatic final int
The numberic code for a float literalstatic final int
The numberic code for a integer literalstatic final int
The numberic code for a long literalstatic final int
The numberic code for a boolean literalstatic final int
The numberic code for a symbol literalstatic final int
The numberic code for a string literalstatic final int
The numberic code for a symbol literal -
Constructor Summary
ConstructorDescriptionAtomicTerm
(String sValue, int nType) Construct a new AtomicTerm with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(TermWalker walker) Do a dispatch back to the given walker.Term[]
children()
Obtain the childern Termsstatic AtomicTerm
createBoolean
(String value) Create new AtomicTerm representing a Boolean with given valuestatic AtomicTerm
createDouble
(String value) Create new AtomicTerm representing a Double with given valuestatic AtomicTerm
createFloat
(String value) Create new AtomicTerm representing a float with given valuestatic AtomicTerm
createInteger
(String value) Create new AtomicTerm representing a Integer with given valuestatic AtomicTerm
createLong
(String value) Create new AtomicTerm representing a Long with given valuestatic AtomicTerm
Create new AtomicTerm representing a null.static AtomicTerm
createNull
(String value) Create new AtomicTerm representing a null with given valuestatic AtomicTerm
createShort
(String value) Create new AtomicTerm representing a Short with given valuestatic AtomicTerm
createString
(String value) Create new AtomicTerm representing a String with given valuestatic AtomicTerm
createSymbol
(String value) Create new AtomicTerm representing a Symbol with given valueFind the Term amoungst the children whose functor equals the given functor.Answer a String representation of the Term that is allowed to show more internal details than toString() which does not compress information.Obtain the functor representation of the Term.Obtain the Number representation of the node.Obtain the Object representation of the node.int
Obtain the typecode for the node.getValue()
Obtain the string value for the node.boolean
isNumber()
Answer whether the receiver is an Atomic Term representing a Number.boolean
Test whether the value is of a valid number format.void
negate()
Make negavite the representation of this node.negativeNumber
(Number num) Make negative the given number that supposedly came from this node.termAt
(int index) Obtain the child term at the given index.boolean
Answer whether the receiver is equal to the given Term.toString()
Return a human-readable description for this Node.Join the receiver with the given child Term.Methods inherited from class com.tangosol.coherence.dsltools.termtrees.Term
childrenTermEqual, findAttribute, headChildrenTermEqual, isAtom, isLeaf, iterator, length
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
STRINGLITERAL
public static final int STRINGLITERALThe numberic code for a string literal- See Also:
-
INTEGERLITERAL
public static final int INTEGERLITERALThe numberic code for a integer literal- See Also:
-
LONGLITERAL
public static final int LONGLITERALThe numberic code for a long literal- See Also:
-
FLOATLITERAL
public static final int FLOATLITERALThe numberic code for a float literal- See Also:
-
DOUBLELITERAL
public static final int DOUBLELITERALThe numberic code for a double literal- See Also:
-
BOOLEANLITERAL
public static final int BOOLEANLITERALThe numberic code for a boolean literal- See Also:
-
NULLLITERAL
public static final int NULLLITERALThe numberic code for a boolean literal- See Also:
-
SHORTLITERAL
public static final int SHORTLITERALThe numberic code for a symbol literal- See Also:
-
SYMBOLLITERAL
public static final int SYMBOLLITERALThe numberic code for a symbol literal- See Also:
-
-
Constructor Details
-
AtomicTerm
Construct a new AtomicTerm with the given parameters.- Parameters:
sValue
- the String representation of the literalnType
- the type code for the given literal
-
-
Method Details
-
getTypeCode
public int getTypeCode()Obtain the typecode for the node.- Returns:
- the typecode
-
getValue
Obtain the string value for the node.- Returns:
- the string value
-
getFunctor
Obtain the functor representation of the Term.- Specified by:
getFunctor
in classTerm
- Returns:
- the functor
-
fullFormString
Answer a String representation of the Term that is allowed to show more internal details than toString() which does not compress information. Similar to Object.toString().- Specified by:
fullFormString
in classTerm
- Returns:
- a String representation of the receiver
-
isNumber
public boolean isNumber()Answer whether the receiver is an Atomic Term representing a Number. -
withChild
Join the receiver with the given child Term. AtomicTerms will construct a general list term (functor .list.) and NodeTerms may be mutated. -
children
Obtain the childern Terms -
termAt
Obtain the child term at the given index. The index is 1 based for children and with at(0) returning the functor as an AtomicTerm. Beware, your 0 based habits can cause problems but 1 based indexing is useful since the functor is an interesting part of the information space. We are bowing here to the wisdom of Mathematica Expressions. -
findChild
Find the Term amoungst the children whose functor equals the given functor. -
termEqual
Answer whether the receiver is equal to the given Term. Terms are equal if their functors are equal and their children are termEqual to the children of the given term. -
getObject
Obtain the Object representation of the node. This will be one of the java Types String, Integer, Long, Float, Double, or Boolean.- Returns:
- the Object
-
getNumber
Obtain the Number representation of the node.- Returns:
- the Comparable
-
negativeNumber
Make negative the given number that supposedly came from this node.- Parameters:
num
- a Number that was created by this node- Returns:
- a negated
-
negate
public void negate()Make negavite the representation of this node. -
isValidNumber
public boolean isValidNumber()Test whether the value is of a valid number format.- Returns:
- the the results of testing for numeric format validity
-
accept
Description copied from class:Term
Do a dispatch back to the given walker. -
toString
Return a human-readable description for this Node. -
createString
Create new AtomicTerm representing a String with given value- Parameters:
value
- the text of the literal- Returns:
- a AtomicTerm for a String
-
createShort
Create new AtomicTerm representing a Short with given value- Parameters:
value
- the text of the literal- Returns:
- a AtomicTerm for a Integer
-
createInteger
Create new AtomicTerm representing a Integer with given value- Parameters:
value
- the text of the literal- Returns:
- a AtomicTerm for a Integer
-
createLong
Create new AtomicTerm representing a Long with given value- Parameters:
value
- the text of the literal- Returns:
- a AtomicTerm for a Long
-
createFloat
Create new AtomicTerm representing a float with given value- Parameters:
value
- the text of the literal- Returns:
- a AtomicTerm for a Float
-
createDouble
Create new AtomicTerm representing a Double with given value- Parameters:
value
- the text of the literal- Returns:
- a AtomicTerm for a Double
-
createBoolean
Create new AtomicTerm representing a Boolean with given value- Parameters:
value
- the text of the literal- Returns:
- a AtomicTerm for a boolean
-
createNull
Create new AtomicTerm representing a null with given value- Parameters:
value
- the text of the literal- Returns:
- a AtomicTerm for a null
-
createNull
Create new AtomicTerm representing a null.- Returns:
- a AtomicTerm for a null
-
createSymbol
Create new AtomicTerm representing a Symbol with given value- Parameters:
value
- the text of the literal- Returns:
- a AtomicTerm for a Symbol
-