Package edu.uky.ai.io
Class Node
java.lang.Object
edu.uky.ai.io.Node
- Author:
- Stephen G. Ware
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionasList()Casts the node to a list.asList(int min, int max) Casts the node to a list of a certain length.asSymbol()Casts this node to a symbol.Casts this node to a specific symbol.booleanisList()Tests if this node is aList.booleanisList(int min, int max) Tests if this node is aListof a certain length.booleanisSymbol()Tests if this node is aSymbol.booleanTests if this node is a specificSymbol.static final NodeParse a given file as a node.static final NodeParse a given string as a node.Returns the node's next sibling or throws an exception if no such node exists.
-
Field Details
-
next
The node that follows this node (i.e. its next sibling) or null if this is the last node in a list
-
-
Method Details
-
requireNext
Returns the node's next sibling or throws an exception if no such node exists.- Returns:
- the next sibling
- Throws:
FormatException- if no next sibling exists
-
isSymbol
public boolean isSymbol()Tests if this node is aSymbol.- Returns:
- true if the node is a symbol, false otherwise
-
isSymbol
Tests if this node is a specificSymbol.- Parameters:
value- the value of the symbol- Returns:
- true if the node is that symbol, false otherwise
-
asSymbol
Casts this node to a symbol.- Returns:
- the node as a symbol
- Throws:
FormatException- if the node is not a symbol
-
asSymbol
Casts this node to a specific symbol.- Parameters:
value- the value of the symbol- Returns:
- the node as the symbol
- Throws:
FormatException- if the node is not a symbol
-
isList
public boolean isList()Tests if this node is aList.- Returns:
- true if the node is a list, false otherwise
-
isList
public boolean isList(int min, int max) Tests if this node is aListof a certain length.- Parameters:
min- the minimum number of elements the list can havemax- the maximum number of elements the list can have (-1 indicates any number of elements)- Returns:
- true if the node is such a list, false otherwise
-
asList
Casts the node to a list.- Returns:
- the node as a list
- Throws:
FormatException- if the node is not a list
-
asList
Casts the node to a list of a certain length.- Parameters:
min- the minimum number of elements the list can havemax- the maximum number of elements the list can have (-1 indicates any number of elements)- Returns:
- the node as a list of that length
- Throws:
FormatException- if the node is not a list
-
parse
Parse a given file as a node.- Parameters:
file- the file to parse- Returns:
- a node
- Throws:
IOException- if an IO exception occurred while reading the file
-
parse
Parse a given string as a node.- Parameters:
string- the string to parse- Returns:
- a node
-