gson-comments/gson/docs/javadocs/com/google/gson/GsonBuilder.html

529 lines
28 KiB
HTML

<!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_01) on Fri Aug 29 15:11:27 PDT 2008 -->
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>
GsonBuilder (Gson 1.2 API)
</TITLE>
<META NAME="date" CONTENT="2008-08-29">
<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 1.2 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://java.sun.com/j2se/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://java.sun.com/j2se/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())
.serializeNulls()
.setDateFormat(DateFormat.LONG)
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
.setPrettyPrinting()
.setVersion(1.0)
.create();
</pre></p>
<p>NOTE: the order of invocation of configuration methods does not matter.</p>
<P>
<P>
<DL>
<DT><B>Author:</B></DT>
<DD>Inderjeet Singh, Joel Leitch</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/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#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#registerTypeAdapter(java.lang.reflect.Type, java.lang.Object)">registerTypeAdapter</A></B>(<A HREF="http://java.sun.com/j2se/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://java.sun.com/j2se/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#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#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(java.lang.String)">setDateFormat</A></B>(<A HREF="http://java.sun.com/j2se/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#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#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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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://java.sun.com/j2se/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="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="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="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="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://java.sun.com/j2se/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>Note that this pattern must abide by the convention provided by <code>SimpleDateFormat</code>
class. See the documentation in <A HREF="http://java.sun.com/j2se/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://java.sun.com/j2se/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="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://java.sun.com/j2se/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://java.sun.com/j2se/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/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 an instance creator,
serializer or deserializer 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/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="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. All Rights Reserved.
</BODY>
</HTML>