Package org.openstreetmap.josm.tools
Class XmlObjectParser
- java.lang.Object
-
- org.openstreetmap.josm.tools.XmlObjectParser
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
XmlObjectParser.AddNamespaceFilter
private static class
XmlObjectParser.Entry
private class
XmlObjectParser.Parser
-
Field Summary
Fields Modifier and Type Field Description static String
lang
The language prefix to useprivate Map<String,XmlObjectParser.Entry>
mapping
private DefaultHandler
parser
private List<Object>
queue
The queue of already parsed items from the parsing thread.private Iterator<Object>
queueIterator
-
Constructor Summary
Constructors Constructor Description XmlObjectParser()
Constructs a newXmlObjectParser
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
Check if there is a next parsed object availableIterator<Object>
iterator()
void
map(String tagName, Class<?> klass)
Add a new tag name to class type mappingvoid
mapBoth(String tagName, Class<?> klass)
void
mapOnStart(String tagName, Class<?> klass)
Object
next()
Get the next element that was parsedIterable<Object>
start(Reader in)
Starts parsing from the given input reader, without validation.private Iterable<Object>
start(Reader in, ContentHandler contentHandler)
Iterable<Object>
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, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
mapping
private final Map<String,XmlObjectParser.Entry> mapping
-
parser
private final DefaultHandler parser
-
queueIterator
private Iterator<Object> queueIterator
-
-
Constructor Detail
-
XmlObjectParser
public XmlObjectParser()
Constructs a newXmlObjectParser
.
-
-
Method Detail
-
start
private Iterable<Object> start(Reader in, ContentHandler contentHandler) throws SAXException, IOException
- Throws:
SAXException
IOException
-
start
public Iterable<Object> start(Reader in) throws SAXException
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
public void map(String tagName, Class<?> klass)
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
public void mapOnStart(String tagName, Class<?> klass)
-
hasNext
public boolean hasNext()
Check if there is a next parsed object available- Returns:
true
if there is a next object
-
-