public interface MwsWriter extends Closeable
| Modifier and Type | Method and Description |
|---|---|
void |
beginObject(String name)
Write a begin tag for an object value.
|
void |
close() |
void |
endObject(String name)
Write the end of an object value.
|
void |
write(String name,
Object value)
Write out a value, with proper escaping and delimiters for the context.
|
void |
write(String namespace,
String name,
MwsObject value)
Write out an object with a namespace attribute.
|
void |
writeAny(Collection<Element> elements)
Write a list of arbitrary elements.
|
void |
writeAttribute(String name,
Object value)
Write out a labeled attribute value with proper escaping and delimiters
for the context.
|
void |
writeList(String name,
Collection<?> list)
Write a list using sibling elements.
|
void |
writeList(String name,
String memberName,
Collection<?> list)
Write a list using child elements.
|
void |
writeValue(Object value)
Write out an unlabeled value.
|
void beginObject(String name)
Must follow with matching endObject call eventually.
For JSON writes [,]name: { or {
For XML writes <name>
name - void close()
close in interface AutoCloseableclose in interface Closeablevoid endObject(String name)
Must previously have written a matching beginObject.
For JSON writes: }
For XML writes: </name>
name - void write(String namespace, String name, MwsObject value)
Same as calling:
if (value!=null) {
w.beginObject(name);
w.writeAttribute("xmlns",name);
value.writeFragmentTo(w);
w.endObject(name);
}
name - The label for the value.value - The value to output.void write(String name, Object value)
The value must be one of: null, Boolean, Number, String, MwsObject.
Calling with a null value does nothing and returns.
For JSON: [,]label:value or [,]value
For XML: <label>valueFragment</label>
name - The label for the value.value - The value to output.void writeAttribute(String name, Object value)
Can only be called after beginObject or writeAttribute methods.
The value must be one of: null, Boolean, Number, String.
Calling with a null value does nothing and returns.
For JSON: same as write(name,value)
For XML: label = "value" inside the object tag.
name - value - void writeList(String name, Collection<?> list)
For JSON: [,]name:[values...] or [values...]
For XML: <name>value</name>...
name - list - void writeList(String name, String memberName, Collection<?> list)
For JSON: [,]name:[values...] or [values...]
For XML: <name><memberName>value</memberName>...
name - memberName - list - void writeAny(Collection<Element> elements)
elements - Collection of w3c DOM elements to writevoid writeValue(Object value)
Calling with null value does nothing and returns.
For JSON: [,]Value:value or [,]value
For XML: value
value - The object value.Copyright © 2014. All Rights Reserved.