public final class NodeReader extends Object implements Closeable
Node instances from String representations.
e.g. The String:
(+ 9 5)will produce the
Node:
new FunctionNode(new Add(), createArguments(new ConstantNode(9), new ConstantNode(5))
| Constructor and Description |
|---|
NodeReader(String input,
Function[] functions,
ConstantNode[] constants,
VariableSet variableSet)
Creates a
NodeReader that reads from the given java.lang.String. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
isEndOfStream()
Returns
true if there is no more data to read from the underlying stream, else false. |
static boolean |
isValidDisplayName(String displayName)
Returns
true if the given String is suitable for use as the display name of a Function, else {code false}. |
Node |
readNode()
Creates and returns a
Node which represents the next s-expression read from the input. |
public NodeReader(String input, Function[] functions, ConstantNode[] constants, VariableSet variableSet)
NodeReader that reads from the given java.lang.String.input - contains the s-expressions, representing programs as tree structures, that will be read to construct new Node instancesfunctions - a collection of Functions to use to represent functions read from inputconstants - a collection of ConstantNodes to use to represent constants read from inputvariableSet - the variable set to use to represent variables read from inputpublic Node readNode() throws IOException
Node which represents the next s-expression read from the input.IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic boolean isEndOfStream()
throws IOException
true if there is no more data to read from the underlying stream, else false.IOExceptionpublic static boolean isValidDisplayName(String displayName)
true if the given String is suitable for use as the display name of a Function, else {code false}.
A String is considered suitable as a display name for a Function - as returned from Function.getDisplayName() - if it can be
successfully parsed by a NodeReader. Suitable function names do not start with a number or contain any of the special characters used to represent
the start or end of functions (i.e. ( and )), arrays (i.e. [ and ]) or strings (i.e. ").
OakGP Genetic Programming Framework