Package org.openstreetmap.josm.tools
Class XmlObjectParser
java.lang.Object
org.openstreetmap.josm.tools.XmlObjectParser
An helper class that reads from a XML stream into specific objects.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classprivate final class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe language prefix to useprivate final Map<String,XmlObjectParser.Entry> private final DefaultHandlerThe queue of already parsed items from the parsing thread. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasNext()Check if there is a next parsed object availableiterator()voidAdd a new tag name to class type mappingvoidvoidmapOnStart(String tagName, Class<?> klass) next()Get the next element that was parsedStarts parsing from the given input reader, without validation.start(Reader in, ContentHandler contentHandler) startWithValidation(Reader in, String namespace, String schemaSource) Starts parsing from the given input reader, with XSD validation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
lang
The language prefix to use -
mapping
-
parser
-
queue
The queue of already parsed items from the parsing thread. -
queueIterator
-
-
Constructor Details
-
XmlObjectParser
public XmlObjectParser()Constructs a newXmlObjectParser.
-
-
Method Details
-
start
private Iterable<Object> start(Reader in, ContentHandler contentHandler) throws SAXException, IOException - Throws:
SAXExceptionIOException
-
start
Starts parsing from the given input reader, without validation.- Parameters:
in- The input reader- Returns:
- iterable collection of objects
- Throws:
SAXException- if any XML or I/O error occurs
-
startWithValidation
public Iterable<Object> startWithValidation(Reader in, String namespace, String schemaSource) throws SAXException Starts parsing from the given input reader, with XSD validation.- Parameters:
in- The input readernamespace- default namespaceschemaSource- XSD schema- Returns:
- iterable collection of objects
- Throws:
SAXException- if any XML or I/O error occurs
-
map
Add a new tag name to class type mapping- Parameters:
tagName- The tag name that should be converted to that classklass- The class the XML elements should be converted to.
-
mapOnStart
-
mapBoth
-
next
Get the next element that was parsed- Returns:
- The next object
-
hasNext
Check if there is a next parsed object available- Returns:
trueif there is a next object
-
iterator
-