blob: 2832652d677b951860d62ae69a051f23b0ed47bb [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_23) on Fri Dec 30 23:30:48 PST 2011 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
GsonBuilder (Gson 2.1 API)
</TITLE>
<META NAME="date" CONTENT="2011-12-30">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="GsonBuilder (Gson 2.1 API)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/GsonBuilder.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../com/google/gson/Gson.html" title="class in com.google.gson"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../com/google/gson/InstanceCreator.html" title="interface in com.google.gson"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html?com/google/gson/GsonBuilder.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="GsonBuilder.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.google.gson</FONT>
<BR>
Class GsonBuilder</H2>
<PRE>
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A>
<IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>com.google.gson.GsonBuilder</B>
</PRE>
<HR>
<DL>
<DT><PRE>public final class <B>GsonBuilder</B><DT>extends <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL>
</PRE>
<P>
<p>Use this builder to construct a <A HREF="../../../com/google/gson/Gson.html" title="class in com.google.gson"><CODE>Gson</CODE></A> instance when you need to set configuration
options other than the default. For <A HREF="../../../com/google/gson/Gson.html" title="class in com.google.gson"><CODE>Gson</CODE></A> with default configuration, it is simpler to
use <code>new Gson()</code>. <code>GsonBuilder</code> is best used by creating it, and then invoking its
various configuration methods, and finally calling create.</p>
<p>The following is an example shows how to use the <code>GsonBuilder</code> to construct a Gson
instance:
<pre>
Gson gson = new GsonBuilder()
.registerTypeAdapter(Id.class, new IdTypeAdapter())
.enableComplexMapKeySerialization()
.serializeNulls()
.setDateFormat(DateFormat.LONG)
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
.setPrettyPrinting()
.setVersion(1.0)
.create();
</pre></p>
<p>NOTES:
<ul>
<li> the order of invocation of configuration methods does not matter.</li>
<li> The default serialization of <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Date.html?is-external=true" title="class or interface in java.util"><CODE>Date</CODE></A> and its subclasses in Gson does
not contain time-zone information. So, if you are using date/time instances,
use <code>GsonBuilder</code> and its <code>setDateFormat</code> methods.</li>
</ul>
</p>
<P>
<P>
<DL>
<DT><B>Author:</B></DT>
<DD>Inderjeet Singh, Joel Leitch, Jesse Wilson</DD>
</DL>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#GsonBuilder()">GsonBuilder</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a GsonBuilder instance that can be used to build Gson with various configuration
settings.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#addDeserializationExclusionStrategy(com.google.gson.ExclusionStrategy)">addDeserializationExclusionStrategy</A></B>(<A HREF="../../../com/google/gson/ExclusionStrategy.html" title="interface in com.google.gson">ExclusionStrategy</A>&nbsp;strategy)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to apply the passed in exclusion strategy during deserialization.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#addSerializationExclusionStrategy(com.google.gson.ExclusionStrategy)">addSerializationExclusionStrategy</A></B>(<A HREF="../../../com/google/gson/ExclusionStrategy.html" title="interface in com.google.gson">ExclusionStrategy</A>&nbsp;strategy)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to apply the passed in exclusion strategy during serialization.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/Gson.html" title="class in com.google.gson">Gson</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#create()">create</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a <A HREF="../../../com/google/gson/Gson.html" title="class in com.google.gson"><CODE>Gson</CODE></A> instance based on the current configuration.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#disableHtmlEscaping()">disableHtmlEscaping</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;By default, Gson escapes HTML characters such as &lt; &gt; etc.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#disableInnerClassSerialization()">disableInnerClassSerialization</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to exclude inner classes during serialization.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#enableComplexMapKeySerialization()">enableComplexMapKeySerialization</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enabling this feature will only change the serialized form if the map key is
a complex type (i.e.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#excludeFieldsWithModifiers(int...)">excludeFieldsWithModifiers</A></B>(int...&nbsp;modifiers)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to excludes all class fields that have the specified modifiers.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#excludeFieldsWithoutExposeAnnotation()">excludeFieldsWithoutExposeAnnotation</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to exclude all fields from consideration for serialization or deserialization
that do not have the <A HREF="../../../com/google/gson/annotations/Expose.html" title="annotation in com.google.gson.annotations"><CODE>Expose</CODE></A> annotation.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#generateNonExecutableJson()">generateNonExecutableJson</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Makes the output JSON non-executable in Javascript by prefixing the generated JSON with some
special text.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#registerTypeAdapter(java.lang.reflect.Type, java.lang.Object)">registerTypeAdapter</A></B>(<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/Type.html?is-external=true" title="class or interface in java.lang.reflect">Type</A>&nbsp;type,
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;typeAdapter)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson for custom serialization or deserialization.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#registerTypeAdapterFactory(com.google.gson.TypeAdapterFactory)">registerTypeAdapterFactory</A></B>(<A HREF="../../../com/google/gson/TypeAdapterFactory.html" title="interface in com.google.gson">TypeAdapterFactory</A>&nbsp;factory)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Register a factory for type adapters.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#registerTypeHierarchyAdapter(java.lang.Class, java.lang.Object)">registerTypeHierarchyAdapter</A></B>(<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</A>&lt;?&gt;&nbsp;baseType,
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;typeAdapter)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson for custom serialization or deserialization for an inheritance type hierarchy.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#serializeNulls()">serializeNulls</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configure Gson to serialize null fields.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#serializeSpecialFloatingPointValues()">serializeSpecialFloatingPointValues</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Section 2.4 of <a href="http://www.ietf.org/rfc/rfc4627.txt">JSON specification</a> disallows
special double values (NaN, Infinity, -Infinity).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#setDateFormat(int)">setDateFormat</A></B>(int&nbsp;style)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to to serialize <code>Date</code> objects according to the style value provided.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#setDateFormat(int, int)">setDateFormat</A></B>(int&nbsp;dateStyle,
int&nbsp;timeStyle)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to to serialize <code>Date</code> objects according to the style value provided.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#setDateFormat(java.lang.String)">setDateFormat</A></B>(<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;pattern)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to serialize <code>Date</code> objects according to the pattern provided.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#setExclusionStrategies(com.google.gson.ExclusionStrategy...)">setExclusionStrategies</A></B>(<A HREF="../../../com/google/gson/ExclusionStrategy.html" title="interface in com.google.gson">ExclusionStrategy</A>...&nbsp;strategies)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to apply a set of exclusion strategies during both serialization and
deserialization.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#setFieldNamingPolicy(com.google.gson.FieldNamingPolicy)">setFieldNamingPolicy</A></B>(<A HREF="../../../com/google/gson/FieldNamingPolicy.html" title="enum in com.google.gson">FieldNamingPolicy</A>&nbsp;namingConvention)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to apply a specific naming policy to an object's field during serialization
and deserialization.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#setFieldNamingStrategy(com.google.gson.FieldNamingStrategy)">setFieldNamingStrategy</A></B>(<A HREF="../../../com/google/gson/FieldNamingStrategy.html" title="interface in com.google.gson">FieldNamingStrategy</A>&nbsp;fieldNamingStrategy)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to apply a specific naming policy strategy to an object's field during
serialization and deserialization.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#setLongSerializationPolicy(com.google.gson.LongSerializationPolicy)">setLongSerializationPolicy</A></B>(<A HREF="../../../com/google/gson/LongSerializationPolicy.html" title="enum in com.google.gson">LongSerializationPolicy</A>&nbsp;serializationPolicy)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to apply a specific serialization policy for <code>Long</code> and <code>long</code>
objects.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#setPrettyPrinting()">setPrettyPrinting</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to output Json that fits in a page for pretty printing.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/google/gson/GsonBuilder.html#setVersion(double)">setVersion</A></B>(double&nbsp;ignoreVersionsAfter)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures Gson to enable versioning support.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="GsonBuilder()"><!-- --></A><H3>
GsonBuilder</H3>
<PRE>
public <B>GsonBuilder</B>()</PRE>
<DL>
<DD>Creates a GsonBuilder instance that can be used to build Gson with various configuration
settings. GsonBuilder follows the builder pattern, and it is typically used by first
invoking various configuration methods to set desired options, and finally calling
<A HREF="../../../com/google/gson/GsonBuilder.html#create()"><CODE>create()</CODE></A>.
<P>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="setVersion(double)"><!-- --></A><H3>
setVersion</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>setVersion</B>(double&nbsp;ignoreVersionsAfter)</PRE>
<DL>
<DD>Configures Gson to enable versioning support.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>ignoreVersionsAfter</CODE> - any field or type marked with a version higher than this value
are ignored during serialization or deserialization.
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern</DL>
</DD>
</DL>
<HR>
<A NAME="excludeFieldsWithModifiers(int...)"><!-- --></A><H3>
excludeFieldsWithModifiers</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>excludeFieldsWithModifiers</B>(int...&nbsp;modifiers)</PRE>
<DL>
<DD>Configures Gson to excludes all class fields that have the specified modifiers. By default,
Gson will exclude all fields marked transient or static. This method will override that
behavior.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>modifiers</CODE> - the field modifiers. You must use the modifiers specified in the
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/Modifier.html?is-external=true" title="class or interface in java.lang.reflect"><CODE>Modifier</CODE></A> class. For example,
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/Modifier.html?is-external=true#TRANSIENT" title="class or interface in java.lang.reflect"><CODE>Modifier.TRANSIENT</CODE></A>,
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/Modifier.html?is-external=true#STATIC" title="class or interface in java.lang.reflect"><CODE>Modifier.STATIC</CODE></A>.
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern</DL>
</DD>
</DL>
<HR>
<A NAME="generateNonExecutableJson()"><!-- --></A><H3>
generateNonExecutableJson</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>generateNonExecutableJson</B>()</PRE>
<DL>
<DD>Makes the output JSON non-executable in Javascript by prefixing the generated JSON with some
special text. This prevents attacks from third-party sites through script sourcing. See
<a href="http://code.google.com/p/google-gson/issues/detail?id=42">Gson Issue 42</a>
for details.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.3</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="excludeFieldsWithoutExposeAnnotation()"><!-- --></A><H3>
excludeFieldsWithoutExposeAnnotation</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>excludeFieldsWithoutExposeAnnotation</B>()</PRE>
<DL>
<DD>Configures Gson to exclude all fields from consideration for serialization or deserialization
that do not have the <A HREF="../../../com/google/gson/annotations/Expose.html" title="annotation in com.google.gson.annotations"><CODE>Expose</CODE></A> annotation.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern</DL>
</DD>
</DL>
<HR>
<A NAME="serializeNulls()"><!-- --></A><H3>
serializeNulls</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>serializeNulls</B>()</PRE>
<DL>
<DD>Configure Gson to serialize null fields. By default, Gson omits all fields that are null
during serialization.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.2</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="enableComplexMapKeySerialization()"><!-- --></A><H3>
enableComplexMapKeySerialization</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>enableComplexMapKeySerialization</B>()</PRE>
<DL>
<DD>Enabling this feature will only change the serialized form if the map key is
a complex type (i.e. non-primitive) in its <strong>serialized</strong> JSON
form. The default implementation of map serialization uses <code>toString()</code>
on the key; however, when this is called then one of the following cases
apply:
<h3>Maps as JSON objects</h3>
For this case, assume that a type adapter is registered to serialize and
deserialize some <code>Point</code> class, which contains an x and y coordinate,
to/from the JSON Primitive string value <code>"(x,y)"</code>. The Java map would
then be serialized as a <A HREF="../../../com/google/gson/JsonObject.html" title="class in com.google.gson"><CODE>JsonObject</CODE></A>.
<p>Below is an example:
<pre> <code>Gson gson = new GsonBuilder()
.register(Point.class, new MyPointTypeAdapter())
.enableComplexMapKeySerialization()
.create();
Map&lt;Point, String&gt; original = new LinkedHashMap&lt;Point, String&gt;();
original.put(new Point(5, 6), "a");
original.put(new Point(8, 8), "b");
System.out.println(gson.toJson(original, type));
</code></pre>
The above code prints this JSON object:<pre> <code>{
"(5,6)": "a",
"(8,8)": "b"
}
</code></pre>
<h3>Maps as JSON arrays</h3>
For this case, assume that a type adapter was NOT registered for some
<code>Point</code> class, but rather the default Gson serialization is applied.
In this case, some <code>new Point(2,3)</code> would serialize as <code>{"x":2,"y":5}</code>.
<p>Given the assumption above, a <code>Map&lt;Point, String&gt;</code> will be
serialize as an array of arrays (can be viewed as an entry set of pairs).
<p>Below is an example of serializing complex types as JSON arrays:
<pre> <code>Gson gson = new GsonBuilder()
.enableComplexMapKeySerialization()
.create();
Map&lt;Point, String&gt; original = new LinkedHashMap&lt;Point, String&gt;();
original.put(new Point(5, 6), "a");
original.put(new Point(8, 8), "b");
System.out.println(gson.toJson(original, type));
</code>
The JSON output would look as follows:
<pre> <code>[
[
{
"x": 5,
"y": 6
},
"a"
],
[
{
"x": 8,
"y": 8
},
"b"
]
]
</code></pre>
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.7</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="disableInnerClassSerialization()"><!-- --></A><H3>
disableInnerClassSerialization</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>disableInnerClassSerialization</B>()</PRE>
<DL>
<DD>Configures Gson to exclude inner classes during serialization.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.3</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setLongSerializationPolicy(com.google.gson.LongSerializationPolicy)"><!-- --></A><H3>
setLongSerializationPolicy</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>setLongSerializationPolicy</B>(<A HREF="../../../com/google/gson/LongSerializationPolicy.html" title="enum in com.google.gson">LongSerializationPolicy</A>&nbsp;serializationPolicy)</PRE>
<DL>
<DD>Configures Gson to apply a specific serialization policy for <code>Long</code> and <code>long</code>
objects.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>serializationPolicy</CODE> - the particular policy to use for serializing longs.
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.3</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setFieldNamingPolicy(com.google.gson.FieldNamingPolicy)"><!-- --></A><H3>
setFieldNamingPolicy</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>setFieldNamingPolicy</B>(<A HREF="../../../com/google/gson/FieldNamingPolicy.html" title="enum in com.google.gson">FieldNamingPolicy</A>&nbsp;namingConvention)</PRE>
<DL>
<DD>Configures Gson to apply a specific naming policy to an object's field during serialization
and deserialization.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>namingConvention</CODE> - the JSON field naming convention to use for serialization and
deserialization.
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern</DL>
</DD>
</DL>
<HR>
<A NAME="setFieldNamingStrategy(com.google.gson.FieldNamingStrategy)"><!-- --></A><H3>
setFieldNamingStrategy</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>setFieldNamingStrategy</B>(<A HREF="../../../com/google/gson/FieldNamingStrategy.html" title="interface in com.google.gson">FieldNamingStrategy</A>&nbsp;fieldNamingStrategy)</PRE>
<DL>
<DD>Configures Gson to apply a specific naming policy strategy to an object's field during
serialization and deserialization.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>fieldNamingStrategy</CODE> - the actual naming strategy to apply to the fields
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.3</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setExclusionStrategies(com.google.gson.ExclusionStrategy...)"><!-- --></A><H3>
setExclusionStrategies</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>setExclusionStrategies</B>(<A HREF="../../../com/google/gson/ExclusionStrategy.html" title="interface in com.google.gson">ExclusionStrategy</A>...&nbsp;strategies)</PRE>
<DL>
<DD>Configures Gson to apply a set of exclusion strategies during both serialization and
deserialization. Each of the <code>strategies</code> will be applied as a disjunction rule.
This means that if one of the <code>strategies</code> suggests that a field (or class) should be
skipped then that field (or object) is skipped during serializaiton/deserialization.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>strategies</CODE> - the set of strategy object to apply during object (de)serialization.
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.4</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="addSerializationExclusionStrategy(com.google.gson.ExclusionStrategy)"><!-- --></A><H3>
addSerializationExclusionStrategy</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>addSerializationExclusionStrategy</B>(<A HREF="../../../com/google/gson/ExclusionStrategy.html" title="interface in com.google.gson">ExclusionStrategy</A>&nbsp;strategy)</PRE>
<DL>
<DD>Configures Gson to apply the passed in exclusion strategy during serialization.
If this method is invoked numerous times with different exclusion strategy objects
then the exclusion strategies that were added will be applied as a disjunction rule.
This means that if one of the added exclusion strategies suggests that a field (or
class) should be skipped then that field (or object) is skipped during its
serialization.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>strategy</CODE> - an exclusion strategy to apply during serialization.
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.7</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="addDeserializationExclusionStrategy(com.google.gson.ExclusionStrategy)"><!-- --></A><H3>
addDeserializationExclusionStrategy</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>addDeserializationExclusionStrategy</B>(<A HREF="../../../com/google/gson/ExclusionStrategy.html" title="interface in com.google.gson">ExclusionStrategy</A>&nbsp;strategy)</PRE>
<DL>
<DD>Configures Gson to apply the passed in exclusion strategy during deserialization.
If this method is invoked numerous times with different exclusion strategy objects
then the exclusion strategies that were added will be applied as a disjunction rule.
This means that if one of the added exclusion strategies suggests that a field (or
class) should be skipped then that field (or object) is skipped during its
deserialization.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>strategy</CODE> - an exclusion strategy to apply during deserialization.
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.7</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setPrettyPrinting()"><!-- --></A><H3>
setPrettyPrinting</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>setPrettyPrinting</B>()</PRE>
<DL>
<DD>Configures Gson to output Json that fits in a page for pretty printing. This option only
affects Json serialization.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern</DL>
</DD>
</DL>
<HR>
<A NAME="disableHtmlEscaping()"><!-- --></A><H3>
disableHtmlEscaping</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>disableHtmlEscaping</B>()</PRE>
<DL>
<DD>By default, Gson escapes HTML characters such as &lt; &gt; etc. Use this option to configure
Gson to pass-through HTML characters as is.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.3</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setDateFormat(java.lang.String)"><!-- --></A><H3>
setDateFormat</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>setDateFormat</B>(<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;pattern)</PRE>
<DL>
<DD>Configures Gson to serialize <code>Date</code> objects according to the pattern provided. You can
call this method or <A HREF="../../../com/google/gson/GsonBuilder.html#setDateFormat(int)"><CODE>setDateFormat(int)</CODE></A> multiple times, but only the last invocation
will be used to decide the serialization format.
<p>The date format will be used to serialize and deserialize <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Date.html?is-external=true" title="class or interface in java.util"><CODE>Date</CODE></A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/Timestamp.html?is-external=true" title="class or interface in java.sql"><CODE>Timestamp</CODE></A> and <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/Date.html?is-external=true" title="class or interface in java.sql"><CODE>Date</CODE></A>.
<p>Note that this pattern must abide by the convention provided by <code>SimpleDateFormat</code>
class. See the documentation in <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html?is-external=true" title="class or interface in java.text"><CODE>SimpleDateFormat</CODE></A> for more information on
valid date and time patterns.</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>pattern</CODE> - the pattern that dates will be serialized/deserialized to/from
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.2</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setDateFormat(int)"><!-- --></A><H3>
setDateFormat</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>setDateFormat</B>(int&nbsp;style)</PRE>
<DL>
<DD>Configures Gson to to serialize <code>Date</code> objects according to the style value provided.
You can call this method or <A HREF="../../../com/google/gson/GsonBuilder.html#setDateFormat(java.lang.String)"><CODE>setDateFormat(String)</CODE></A> multiple times, but only the last
invocation will be used to decide the serialization format.
<p>Note that this style value should be one of the predefined constants in the
<code>DateFormat</code> class. See the documentation in <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/text/DateFormat.html?is-external=true" title="class or interface in java.text"><CODE>DateFormat</CODE></A> for more
information on the valid style constants.</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>style</CODE> - the predefined date style that date objects will be serialized/deserialized
to/from
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.2</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setDateFormat(int, int)"><!-- --></A><H3>
setDateFormat</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>setDateFormat</B>(int&nbsp;dateStyle,
int&nbsp;timeStyle)</PRE>
<DL>
<DD>Configures Gson to to serialize <code>Date</code> objects according to the style value provided.
You can call this method or <A HREF="../../../com/google/gson/GsonBuilder.html#setDateFormat(java.lang.String)"><CODE>setDateFormat(String)</CODE></A> multiple times, but only the last
invocation will be used to decide the serialization format.
<p>Note that this style value should be one of the predefined constants in the
<code>DateFormat</code> class. See the documentation in <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/text/DateFormat.html?is-external=true" title="class or interface in java.text"><CODE>DateFormat</CODE></A> for more
information on the valid style constants.</p>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>dateStyle</CODE> - the predefined date style that date objects will be serialized/deserialized
to/from<DD><CODE>timeStyle</CODE> - the predefined style for the time portion of the date objects
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.2</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="registerTypeAdapter(java.lang.reflect.Type, java.lang.Object)"><!-- --></A><H3>
registerTypeAdapter</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>registerTypeAdapter</B>(<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/reflect/Type.html?is-external=true" title="class or interface in java.lang.reflect">Type</A>&nbsp;type,
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;typeAdapter)</PRE>
<DL>
<DD>Configures Gson for custom serialization or deserialization. This method combines the
registration of an <A HREF="../../../com/google/gson/TypeAdapter.html" title="class in com.google.gson"><CODE>TypeAdapter</CODE></A>, <A HREF="../../../com/google/gson/InstanceCreator.html" title="interface in com.google.gson"><CODE>InstanceCreator</CODE></A>, <A HREF="../../../com/google/gson/JsonSerializer.html" title="interface in com.google.gson"><CODE>JsonSerializer</CODE></A>, and a
<A HREF="../../../com/google/gson/JsonDeserializer.html" title="interface in com.google.gson"><CODE>JsonDeserializer</CODE></A>. It is best used when a single object <code>typeAdapter</code> implements
all the required interfaces for custom serialization with Gson. If a type adapter was
previously registered for the specified <code>type</code>, it is overwritten.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>type</CODE> - the type definition for the type adapter being registered<DD><CODE>typeAdapter</CODE> - This object must implement at least one of the <A HREF="../../../com/google/gson/TypeAdapter.html" title="class in com.google.gson"><CODE>TypeAdapter</CODE></A>,
<A HREF="../../../com/google/gson/InstanceCreator.html" title="interface in com.google.gson"><CODE>InstanceCreator</CODE></A>, <A HREF="../../../com/google/gson/JsonSerializer.html" title="interface in com.google.gson"><CODE>JsonSerializer</CODE></A>, and a <A HREF="../../../com/google/gson/JsonDeserializer.html" title="interface in com.google.gson"><CODE>JsonDeserializer</CODE></A> interfaces.
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern</DL>
</DD>
</DL>
<HR>
<A NAME="registerTypeAdapterFactory(com.google.gson.TypeAdapterFactory)"><!-- --></A><H3>
registerTypeAdapterFactory</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>registerTypeAdapterFactory</B>(<A HREF="../../../com/google/gson/TypeAdapterFactory.html" title="interface in com.google.gson">TypeAdapterFactory</A>&nbsp;factory)</PRE>
<DL>
<DD>Register a factory for type adapters. Registering a factory is useful when the type
adapter needs to be configured based on the type of the field being processed. Gson
is designed to handle a large number of factories, so you should consider registering
them to be at par with registering an individual type adapter.
<P>
<DD><DL>
<DT><B>Since:</B></DT>
<DD>2.1</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="registerTypeHierarchyAdapter(java.lang.Class, java.lang.Object)"><!-- --></A><H3>
registerTypeHierarchyAdapter</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>registerTypeHierarchyAdapter</B>(<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</A>&lt;?&gt;&nbsp;baseType,
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A>&nbsp;typeAdapter)</PRE>
<DL>
<DD>Configures Gson for custom serialization or deserialization for an inheritance type hierarchy.
This method combines the registration of a <A HREF="../../../com/google/gson/TypeAdapter.html" title="class in com.google.gson"><CODE>TypeAdapter</CODE></A>, <A HREF="../../../com/google/gson/JsonSerializer.html" title="interface in com.google.gson"><CODE>JsonSerializer</CODE></A> and
a <A HREF="../../../com/google/gson/JsonDeserializer.html" title="interface in com.google.gson"><CODE>JsonDeserializer</CODE></A>. If a type adapter was previously registered for the specified
type hierarchy, it is overridden. If a type adapter is registered for a specific type in
the type hierarchy, it will be invoked instead of the one registered for the type hierarchy.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>baseType</CODE> - the class definition for the type adapter being registered for the base class
or interface<DD><CODE>typeAdapter</CODE> - This object must implement at least one of <A HREF="../../../com/google/gson/TypeAdapter.html" title="class in com.google.gson"><CODE>TypeAdapter</CODE></A>,
<A HREF="../../../com/google/gson/JsonSerializer.html" title="interface in com.google.gson"><CODE>JsonSerializer</CODE></A> or <A HREF="../../../com/google/gson/JsonDeserializer.html" title="interface in com.google.gson"><CODE>JsonDeserializer</CODE></A> interfaces.
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.7</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="serializeSpecialFloatingPointValues()"><!-- --></A><H3>
serializeSpecialFloatingPointValues</H3>
<PRE>
public <A HREF="../../../com/google/gson/GsonBuilder.html" title="class in com.google.gson">GsonBuilder</A> <B>serializeSpecialFloatingPointValues</B>()</PRE>
<DL>
<DD>Section 2.4 of <a href="http://www.ietf.org/rfc/rfc4627.txt">JSON specification</a> disallows
special double values (NaN, Infinity, -Infinity). However,
<a href="http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf">Javascript
specification</a> (see section 4.3.20, 4.3.22, 4.3.23) allows these values as valid Javascript
values. Moreover, most JavaScript engines will accept these special values in JSON without
problem. So, at a practical level, it makes sense to accept these values as valid JSON even
though JSON specification disallows them.
<p>Gson always accepts these special values during deserialization. However, it outputs
strictly compliant JSON. Hence, if it encounters a float value <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Float.html?is-external=true#NaN" title="class or interface in java.lang"><CODE>Float.NaN</CODE></A>,
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Float.html?is-external=true#POSITIVE_INFINITY" title="class or interface in java.lang"><CODE>Float.POSITIVE_INFINITY</CODE></A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Float.html?is-external=true#NEGATIVE_INFINITY" title="class or interface in java.lang"><CODE>Float.NEGATIVE_INFINITY</CODE></A>, or a double value
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Double.html?is-external=true#NaN" title="class or interface in java.lang"><CODE>Double.NaN</CODE></A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Double.html?is-external=true#POSITIVE_INFINITY" title="class or interface in java.lang"><CODE>Double.POSITIVE_INFINITY</CODE></A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Double.html?is-external=true#NEGATIVE_INFINITY" title="class or interface in java.lang"><CODE>Double.NEGATIVE_INFINITY</CODE></A>, it
will throw an <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang"><CODE>IllegalArgumentException</CODE></A>. This method provides a way to override the
default behavior when you know that the JSON receiver will be able to handle these special
values.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a reference to this <code>GsonBuilder</code> object to fulfill the "Builder" pattern<DT><B>Since:</B></DT>
<DD>1.3</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="create()"><!-- --></A><H3>
create</H3>
<PRE>
public <A HREF="../../../com/google/gson/Gson.html" title="class in com.google.gson">Gson</A> <B>create</B>()</PRE>
<DL>
<DD>Creates a <A HREF="../../../com/google/gson/Gson.html" title="class in com.google.gson"><CODE>Gson</CODE></A> instance based on the current configuration. This method is free of
side-effects to this <code>GsonBuilder</code> instance and hence can be called multiple times.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>an instance of Gson configured with the options currently set in this builder</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/GsonBuilder.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../com/google/gson/Gson.html" title="class in com.google.gson"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../com/google/gson/InstanceCreator.html" title="interface in com.google.gson"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html?com/google/gson/GsonBuilder.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="GsonBuilder.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
Copyright &#169; 2008-2011 <a href="http://www.google.com">Google, Inc.</a>. All Rights Reserved.
</BODY>
</HTML>