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.booleanThis 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.booleanThis method performs a depth-first-search of the tree rooted at this node.booleanescaped()This method returns the content() with all special characters escaped.static SAtomfromBoolean(boolean value) Factory Method.static SAtomfromBoolean(SourceLocation location, boolean value) Factory Method.static SAtomfromByte(byte value) Factory Method.static SAtomfromByte(SourceLocation location, byte value) Factory Method.static SAtomfromChar(char value) Factory Method.static SAtomfromChar(SourceLocation location, char value) Factory Method.static SAtomfromDouble(double value) Factory Method.static SAtomfromDouble(SourceLocation location, double value) Factory Method.static SAtomfromFloat(float value) Factory Method.static SAtomfromFloat(SourceLocation location, float value) Factory Method.static SAtomfromInt(int value) Factory Method.static SAtomfromInt(SourceLocation location, int value) Factory Method.static SAtomfromLong(long value) Factory Method.static SAtomfromLong(SourceLocation location, long value) Factory Method.static SAtomfromShort(short value) Factory Method.static SAtomfromShort(SourceLocation location, short value) Factory Method.static SAtomfromString(SourceLocation location, String value) Factory Method.static SAtomfromString(String value) Factory Method.inthashCode()booleanisAtom()This method determines whether this object is a SAtom.booleanisList()This method determines whether this object is a SList.location()This method retrieves an object describing the source from which this object we obtained.booleanThis method performs a post-order-search of the tree rooted at this node.booleanThis method performs a pre-order-search of the tree rooted at this node.final StringtoString()This method retrieves the textual representation of this symbolic expression.voidThis method performs a traversal of the tree rooted at this node.intThis method determines the height of the tree rooted at this node.intThis method counts the leaf nodes in the tree rooted at this node.inttreeSize()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:
treeHeightin 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:
treeLeafCountin 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.
-