public interface MwsReader extends Closeable
MwsReader instances can wrap an input stream or other resource and should be closed to avoid resource leakage.
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
<T> T |
read(String name,
Class<T> cls)
Read the next labeled value.
|
List<Element> |
readAny()
Read a list of all elements, ignoring type and name.
|
<T> T |
readAttribute(String name,
Class<T> cls)
Get an attribute by name.
|
<T> List<T> |
readList(String memberName,
Class<T> cls)
Read a list of sibling elements.
|
<T> List<T> |
readList(String name,
String memberName,
Class<T> cls)
Read a list of child elements.
|
<T> T |
readValue(Class<T> cls)
Read raw string value.
|
void close()
close in interface AutoCloseableclose in interface Closeable<T> T read(String name, Class<T> cls)
Returns null if the reader is not positioned on a labeled value of the requested type.
For XML reads:
For JSON reads: <name>value</name>
name:value if in Object or
value if in list.
name - The expected label.cls - The expected value class.<T> T readAttribute(String name, Class<T> cls)
Called when positioned on begin Object.
Returns null if the named attribute is not present.
name - The attribute name to get.<T> List<T> readList(String memberName, Class<T> cls)
For XML reads: <memberName>value</memberName>...
For JSON reads: name:[value...] or [value...]
memberName - XML tag name of each membercls - <T> List<T> readList(String name, String memberName, Class<T> cls)
For XML reads: <name><memberName>value</memberName>...
For JSON reads: name:[value...] or [value...]
name - XML tag name of list parentmemberName - XML tag name of each membercls - List<Element> readAny()
<T> T readValue(Class<T> cls)
For XML reads: characters up to next tag.
For JSON reads: "characters"
Copyright © 2014. All Rights Reserved.