public final class Input extends java.lang.Object implements java.lang.Iterable<InputElement>, org.macroing.cit.java.util.function.ListSupplier<InputElement>, org.macroing.cit.java.util.node.Node
Input
denotes the nonterminal symbol Input, as defined by the Java Language Specification.Modifier and Type | Method and Description |
---|---|
boolean |
accept(org.macroing.cit.java.util.node.NodeHierarchicalVisitor nodeHierarchicalVisitor)
Accepts a
NodeHierarchicalVisitor . |
void |
addInputElement(InputElement inputElement)
Adds an
InputElement to this Input instance. |
boolean |
equals(java.lang.Object object)
Returns
true if, and only if, object is an instance of Input , and that Input instance is equal to this Input instance, false otherwise. |
java.util.List<InputElement> |
get()
Returns a
List with all currently added InputElement s. |
java.util.List<InputElement> |
getInputElements()
Returns a
List with all currently added InputElement s. |
int |
hashCode()
Returns a hash-code for this
Input instance. |
boolean |
hasSubAtEnd()
Returns
true if, and only if, a Sub or Control-Z has been added to the end, false otherwise. |
java.util.Iterator<InputElement> |
iterator()
Returns an
Iterator over all currently added InputElement s. |
static Input |
newInstance()
Returns a new empty
Input instance. |
static Input |
parseInput(java.io.File file)
Parses the content of a file as an
Input instance. |
static Input |
parseInput(java.lang.String string)
Parses the content of the suppled
String as an Input instance. |
void |
removeInputElement(InputElement inputElement)
Removes an
InputElement from this Input instance. |
void |
setSubAtEnd(boolean hasSubAtEnd)
Sets the state of the Sub or Control-Z at the end of this
Input instance. |
java.lang.String |
toString()
Returns a
String representation of this Input instance. |
public boolean accept(org.macroing.cit.java.util.node.NodeHierarchicalVisitor nodeHierarchicalVisitor)
NodeHierarchicalVisitor
.
Returns the result of nodeHierarchicalVisitor.visitLeave(this)
.
If nodeHierarchicalVisitor
is null
, a NullPointerException
will be thrown.
If a RuntimeException
is thrown by the current NodeHierarchicalVisitor
, a NodeTraversalException
will be thrown with the RuntimeException
wrapped.
This implementation will:
NullPointerException
if nodeHierarchicalVisitor
is null
.NodeTraversalException
if nodeHierarchicalVisitor
throws a RuntimeException
.Node
s, if it has any.accept
in interface org.macroing.cit.java.util.node.Node
nodeHierarchicalVisitor
- the NodeHierarchicalVisitor
to acceptnodeHierarchicalVisitor.visitLeave(this)
org.macroing.cit.java.util.node.NodeTraversalException
- thrown if, and only if, a RuntimeException
is thrown by the current NodeHierarchicalVisitor
java.lang.NullPointerException
- thrown if, and only if, nodeHierarchicalVisitor
is null
public boolean equals(java.lang.Object object)
true
if, and only if, object
is an instance of Input
, and that Input
instance is equal to this Input
instance, false
otherwise.equals
in class java.lang.Object
true
if, and only if, object
is an instance of Input
, and that Input
instance is equal to this Input
instance, false
otherwisepublic boolean hasSubAtEnd()
true
if, and only if, a Sub or Control-Z has been added to the end, false
otherwise.true
if, and only if, a Sub or Control-Z has been added to the end, false
otherwisepublic int hashCode()
Input
instance.hashCode
in class java.lang.Object
Input
instancepublic java.util.Iterator<InputElement> iterator()
Iterator
over all currently added InputElement
s.
Removing an InputElement
via the Iterator
will not affect the internal state of this Input
instance.
iterator
in interface java.lang.Iterable<InputElement>
Iterator
over all currently added InputElement
spublic java.util.List<InputElement> get()
List
with all currently added InputElement
s.
Modifications made to the returned List
will not affect the internal state of this Input
instance.
get
in interface java.util.function.Supplier<java.util.List<InputElement>>
get
in interface org.macroing.cit.java.util.function.ListSupplier<InputElement>
List
with all currently added InputElement
spublic java.util.List<InputElement> getInputElements()
List
with all currently added InputElement
s.
Modifications made to the returned List
will not affect the internal state of this Input
instance.
List
with all currently added InputElement
spublic java.lang.String toString()
String
representation of this Input
instance.toString
in class java.lang.Object
String
representation of this Input
instancepublic void addInputElement(InputElement inputElement)
InputElement
to this Input
instance.
If inputElement
is null
, a NullPointerException
will be thrown.
inputElement
- the InputElement
to addjava.lang.NullPointerException
- thrown if, and only if, inputElement
is null
public void removeInputElement(InputElement inputElement)
InputElement
from this Input
instance.
If inputElement
is null
, a NullPointerException
will be thrown.
inputElement
- the InputElement
to removejava.lang.NullPointerException
- thrown if, and only if, inputElement
is null
public void setSubAtEnd(boolean hasSubAtEnd)
Input
instance.hasSubAtEnd
- true
for Sub or Control-Z at the endpublic static Input newInstance()
Input
instance.Input
instancepublic static Input parseInput(java.io.File file)
Input
instance.
Returns an Input
instance.
If file
is null
, a NullPointerException
will be thrown.
If the file cannot be read, an UncheckedIOException
will be thrown.
file
- a File
denoting the file from which to parseInput
instancejava.lang.NullPointerException
- thrown if, and only if, file
is null
java.io.UncheckedIOException
- thrown if, and only if, the file cannot be readpublic static Input parseInput(java.lang.String string)
String
as an Input
instance.
Returns an Input
instance.
If string
is null
, a NullPointerException
will be thrown.
string
- the String
with the content to parseInput
instancejava.lang.NullPointerException
- thrown if, and only if, string
is null