Package com.mackenziehigh.sexpr
Class SAtom
java.lang.Object
com.mackenziehigh.sexpr.SAtom
- All Implemented Interfaces:
Sexpr<SAtom>
,Comparable<Sexpr<?>>
Symbolic Atom.
All instances of this interface are immutable.
-
Method Summary
Modifier and TypeMethodDescriptionThis method retrieves this value, as a boolean.asByte()
This method retrieves this value, as a byte.asChar()
This method retrieves this value, as a char.asDouble()
This method retrieves this value, as a float.asFloat()
This method retrieves this value, as a float.asInt()
This method retrieves this value, as an integer.asLong()
This method retrieves this value, as a long.asShort()
This method retrieves this value, as a short.boolean
This method performs a breadth-first-search of the tree rooted at this node.content()
This method retrieves the series of characters that this atom contains.boolean
This method performs a depth-first-search of the tree rooted at this node.boolean
escaped()
This method returns the content() with all special characters escaped.static SAtom
fromBoolean
(boolean value) Factory Method.static SAtom
fromBoolean
(SourceLocation location, boolean value) Factory Method.static SAtom
fromByte
(byte value) Factory Method.static SAtom
fromByte
(SourceLocation location, byte value) Factory Method.static SAtom
fromChar
(char value) Factory Method.static SAtom
fromChar
(SourceLocation location, char value) Factory Method.static SAtom
fromDouble
(double value) Factory Method.static SAtom
fromDouble
(SourceLocation location, double value) Factory Method.static SAtom
fromFloat
(float value) Factory Method.static SAtom
fromFloat
(SourceLocation location, float value) Factory Method.static SAtom
fromInt
(int value) Factory Method.static SAtom
fromInt
(SourceLocation location, int value) Factory Method.static SAtom
fromLong
(long value) Factory Method.static SAtom
fromLong
(SourceLocation location, long value) Factory Method.static SAtom
fromShort
(short value) Factory Method.static SAtom
fromShort
(SourceLocation location, short value) Factory Method.static SAtom
fromString
(SourceLocation location, String value) Factory Method.static SAtom
fromString
(String value) Factory Method.int
hashCode()
boolean
isAtom()
This method determines whether this object is a SAtom.boolean
isList()
This method determines whether this object is a SList.location()
This method retrieves an object describing the source from which this object we obtained.boolean
This method performs a post-order-search of the tree rooted at this node.boolean
This method performs a pre-order-search of the tree rooted at this node.final String
toString()
This method retrieves the textual representation of this symbolic expression.void
This method performs a traversal of the tree rooted at this node.int
This method determines the height of the tree rooted at this node.int
This method counts the leaf nodes in the tree rooted at this node.int
treeSize()
This method counts the nodes in the tree rooted at this node.
-
Method Details
-
fromBoolean
Factory Method.- Parameters:
value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromChar
Factory Method.- Parameters:
value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromByte
Factory Method.- Parameters:
value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromShort
Factory Method.- Parameters:
value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromInt
Factory Method.- Parameters:
value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromLong
Factory Method.- Parameters:
value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromFloat
Factory Method.- Parameters:
value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromDouble
Factory Method.- Parameters:
value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromString
Factory Method.- Parameters:
value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromBoolean
Factory Method.- Parameters:
location
- will be thelocation()
of the new atom.value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromChar
Factory Method.- Parameters:
location
- will be thelocation()
of the new atom.value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromByte
Factory Method.- Parameters:
location
- will be thelocation()
of the new atom.value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromShort
Factory Method.- Parameters:
location
- will be thelocation()
of the new atom.value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromInt
Factory Method.- Parameters:
location
- will be thelocation()
of the new atom.value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromLong
Factory Method.- Parameters:
location
- will be thelocation()
of the new atom.value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromFloat
Factory Method.- Parameters:
location
- will be thelocation()
of the new atom.value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromDouble
Factory Method.- Parameters:
location
- will be thelocation()
of the new atom.value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
fromString
Factory Method.- Parameters:
location
- will be thelocation()
of the new atom.value
- will be thecontent()
of the new atom.- Returns:
- the new atom.
-
content
This method retrieves the series of characters that this atom contains.- Returns:
- the content of this atom.
-
escaped
This method returns the content() with all special characters escaped.- Returns:
- the escaped content().
-
isAtom
public boolean isAtom()This method determines whether this object is a SAtom. -
isList
public boolean isList()This method determines whether this object is a SList. -
bfs
This method performs a breadth-first-search of the tree rooted at this node. -
dfs
This method performs a depth-first-search of the tree rooted at this node. -
preorder
This method performs a pre-order-search of the tree rooted at this node. -
postorder
This method performs a post-order-search of the tree rooted at this node. -
traverse
This method performs a traversal of the tree rooted at this node. -
asBoolean
This method retrieves this value, as a boolean.If toString() equals (ignoring case) "true", "yes", "on", "T", or "1", then this method will return a true result.
If toString() equals (ignoring case) "false", "no", "off", "F", or "0", then this method will return a false result.
- Returns:
- the value, if possible.
-
asChar
This method retrieves this value, as a char.- Returns:
- the value, if possible.
-
asByte
This method retrieves this value, as a byte.- Returns:
- the value, if possible.
-
asShort
This method retrieves this value, as a short.- Returns:
- the value, if possible.
-
asInt
This method retrieves this value, as an integer.- Returns:
- the value, if possible.
-
asLong
This method retrieves this value, as a long.- Returns:
- the value, if possible.
-
asFloat
This method retrieves this value, as a float.- Returns:
- the value, if possible.
-
asDouble
This method retrieves this value, as a float.- Returns:
- the value, if possible.
-
treeHeight
public int treeHeight()This method determines the height of the tree rooted at this node.This is a constant-time operation.
- Specified by:
treeHeight
in interfaceSexpr<SAtom>
- Returns:
- the height of this tree.
-
treeLeafCount
public int treeLeafCount()This method counts the leaf nodes in the tree rooted at this node.This is a constant-time operation.
- Specified by:
treeLeafCount
in interfaceSexpr<SAtom>
- Returns:
- the number of leaf nodes.
-
treeSize
public int treeSize()This method counts the nodes in the tree rooted at this node.This is a constant-time operation.
-
location
This method retrieves an object describing the source from which this object we obtained. -
hashCode
public int hashCode() -
equals
-
toString
This method retrieves the textual representation of this symbolic expression.
-