|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.stanfy.gsonxml.GsonXmlBuilder
public class GsonXmlBuilder
Use this builder for constructing GsonXml object. All methods are very
similar to GsonBuilder.
| Constructor Summary | |
|---|---|
GsonXmlBuilder()
|
|
| Method Summary | |
|---|---|
GsonXml |
create()
Creates a GsonXml instance based on the current configuration. |
GsonXmlBuilder |
setPrimitiveArrays(boolean primitiveArrays)
If set to true than arrays can contain primitive values. |
GsonXmlBuilder |
setRootArrayPrimitive(boolean rootArrayPrimitive)
When set to true and the root element is parsed as a collection this collection items are treated as primitives. |
GsonXmlBuilder |
setSameNameLists(boolean value)
Here's the difference. Same name lists: on |
GsonXmlBuilder |
setSkipRoot(boolean value)
Here's the difference. Skip root: on |
GsonXmlBuilder |
setTreatNamespaces(boolean value)
Here's the difference. Treat namespaces: on |
GsonXmlBuilder |
setXmlParserCreator(XmlParserCreator xmlParserCreator)
Set a factory for XML pull parser. |
GsonXmlBuilder |
wrap(com.google.gson.GsonBuilder gsonBuilder)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GsonXmlBuilder()
| Method Detail |
|---|
public GsonXmlBuilder wrap(com.google.gson.GsonBuilder gsonBuilder)
gsonBuilder - instance of GsonBuilder
public GsonXmlBuilder setXmlParserCreator(XmlParserCreator xmlParserCreator)
xmlParserCreator - instance of XmlParserCreator
public GsonXmlBuilder setSkipRoot(boolean value)
<root><name>value</name></root>
==>
{name : 'value'}
Skip root: off
<root><name>value</name></root>
==>
{root : {name : 'value'}}
value - true to skip root element
public GsonXmlBuilder setTreatNamespaces(boolean value)
<root><ns:name>value</ns:name></root>
==>
{'<ns>name' : 'value'}
Treat namespaces: off
<root><ns:name>value</ns:name></root>
==>
{name : 'value'}
value - true to treat namespaces
public GsonXmlBuilder setSameNameLists(boolean value)
<root>
<name>value</name>
<item>value1</item>
<item>value2</item>
</root>
==>
{name : 'value', item : ['value1', 'value2']}
Treat namespaces: off
<root>
<name>value</name>
<items>
<ignored>value1</ignored>
<ignored>value2</ignored>
</items>
</root>
==>
{name : 'value', items : ['value1', 'value2']}
value - true for same name list policy
public GsonXmlBuilder setPrimitiveArrays(boolean primitiveArrays)
<list>
<item>
text node value
<field-name>field value</field-name>
</item>
<item>value2</item>
</list>
It's caused by the fact that parser meats 'text node value' and makes a decision that this item is primitive.
primitiveArrays - value for primitive arrays policy
public GsonXmlBuilder setRootArrayPrimitive(boolean rootArrayPrimitive)
rootArrayPrimitive - flag for 'root array primitive' policy
setPrimitiveArrays(boolean)public GsonXml create()
GsonXml instance based on the current configuration. This method is free of
side-effects to this GsonXmlBuilder instance and hence can be called multiple times.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||