Package net.mtrop.doom.map.udmf
Class UDMFScanner
java.lang.Object
net.mtrop.doom.map.udmf.UDMFScanner
- All Implemented Interfaces:
Iterator<UDMFScanner.Element>
A mechanism for reading UDMF data, element by element, in a pull-oriented way.
compared to
UDMFReader
, which is push-oriented.- Since:
- 2.4.0
- Author:
- Matthew Tropiano
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A single scanned element from the scanner.static enum
The element type returned on each element scanned. -
Method Summary
Modifier and TypeMethodDescriptionstatic UDMFScanner
Creates a UDMFScanner for reading UDMF-formatted data from anInputStream
.static UDMFScanner
createScanner
(Reader reader) Creates a UDMFScanner for reading UDMF-formatted data from aReader
.static UDMFScanner
createScanner
(String data) Creates a UDMFScanner for reading UDMF-formatted data from a String.boolean
hasNext()
Checks if there are more elements to read.next()
Checks if there are more elements to read.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Method Details
-
createScanner
Creates a UDMFScanner for reading UDMF-formatted data from anInputStream
.- Parameters:
in
- the InputStream to read from.- Returns:
- a new scanner for controlled reading.
- Throws:
IOException
- if the data can't be read.
-
createScanner
Creates a UDMFScanner for reading UDMF-formatted data from a String.- Parameters:
data
- the String to read from.- Returns:
- a UDMFTable containing the structures.
- Throws:
UDMFParseException
- if a parsing error occurs.IOException
- if the data can't be read.
-
createScanner
Creates a UDMFScanner for reading UDMF-formatted data from aReader
.- Parameters:
reader
- the reader to read from.- Returns:
- a UDMFTable containing the parsed structures.
- Throws:
UDMFParseException
- if a parsing error occurs.IOException
- if the data can't be read.
-
hasNext
public boolean hasNext()Checks if there are more elements to read.- Specified by:
hasNext
in interfaceIterator<UDMFScanner.Element>
- Returns:
- true if more elements can be read, false if not.
-
next
Checks if there are more elements to read.- Specified by:
next
in interfaceIterator<UDMFScanner.Element>
- Returns:
- the next element read, null if no more elements.
- Throws:
UDMFParseException
- if the UDMF document cannot be parsed during read.
-