List of usage examples for com.google.gson GsonBuilder create
public Gson create()
From source file:com.google.mr4c.serialize.json.JsonDatasetBeanSerializer.java
License:Open Source License
public DataKeyBean deserializeDataKeyBean(String serializedKey) { GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create(); return gson.fromJson(serializedKey, DataKeyBean.class); }
From source file:com.google.mr4c.serialize.json.JsonKeyspaceBeanSerializer.java
License:Open Source License
public void serializeKeyspaceBean(KeyspaceBean keyspace, Writer writer) throws IOException { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting();/*w w w .j av a2 s.co m*/ Gson gson = builder.create(); gson.toJson(keyspace, writer); }
From source file:com.google.mr4c.serialize.json.JsonKeyspaceBeanSerializer.java
License:Open Source License
public KeyspaceBean deserializeKeyspaceBean(Reader reader) throws IOException { GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create(); return gson.fromJson(reader, KeyspaceBean.class); }
From source file:com.google.mr4c.serialize.json.JsonPropertiesSerializer.java
License:Open Source License
public void serializeProperties(Properties props, Writer writer) throws IOException { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting();/* w w w .ja v a 2 s. c om*/ Gson gson = builder.create(); gson.toJson(props, writer); }
From source file:com.google.mr4c.serialize.json.JsonPropertiesSerializer.java
License:Open Source License
public Properties deserializeProperties(Reader reader) throws IOException { GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create(); return gson.fromJson(reader, Properties.class); }
From source file:com.google.nigori.common.MessageLibrary.java
License:Apache License
private static Gson initializeGson() { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(GetRequest.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(GetResponse.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(GetIndicesRequest.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(GetIndicesResponse.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(GetRevisionsRequest.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(GetRevisionsResponse.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(PutRequest.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(DeleteRequest.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(RegisterRequest.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(UnregisterRequest.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(AuthenticateRequest.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(RevisionValue.class, new TypeAdapterProtobuf()); gsonBuilder.registerTypeAdapter(ByteString.class, new TypeAdapterByteString()); gsonBuilder.setPrettyPrinting();//from w ww . ja va2 s .com return gsonBuilder.create(); }
From source file:com.google.research.ic.ferret.data.LogLoader.java
License:Open Source License
private LogLoader() { GsonBuilder gBuilder = new GsonBuilder(); gBuilder.registerTypeAdapter(Event.class, new JsonEventDeserializer<Event>()); gBuilder.registerTypeAdapter(Attribute.class, new JsonAttributeDeserializer<Attribute>()); gson = gBuilder.create(); }
From source file:com.googlesource.gerrit.plugins.hooks.rtc.network.RTCClient.java
License:Apache License
public RTCClient(String url, boolean sslVerify, HttpParams httpParams) throws IOException { super();//from w w w.j a va 2s . co m this.baseUrl = (url.endsWith("/") ? url.substring(url.length() - 1) : url); if (httpParams == null) { httpParams = new BasicHttpParams(); } SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); this.httpclient = new DefaultHttpClient(new ThreadSafeClientConnManager(httpParams, schemeRegistry), httpParams); this.transport = new Transport(this, baseUrl, httpclient, httpParams); this.factory = new CachableResourcesFactory(transport); GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(RtcWorkItem.class, new RtcWorkItemDeserializer(factory)); builder.registerTypeAdapter(RtcComment.class, new RtcCommentDeserializer()); builder.registerTypeAdapter(RtcEntity.class, new RtcEntityDeserializer()); builder.registerTypeAdapter(RtcRelatedLink.class, new RtcRelatedLinkDeserializer()); builder.registerTypeAdapter(RtcWorkflowAction.class, new RtcWorkflowActionDeserializer()); gson = builder.create(); transport.setGson(gson); setCookieStore(); setRedirectStategy(); setSSLTrustStrategy(sslVerify); sessionApi = new SessionApiImpl(this, transport); workItemsApi = new WorkItemsApiImpl(this, transport); }
From source file:com.goplace.service.generic.implementation.MetaServiceGenImpl.java
License:Open Source License
@Override public String getPrettyColumns() throws Exception { String data = null;//from w ww . ja v a 2 s. c om try { oConnection.setAutoCommit(false); Constructor c = Class .forName("com.goplace.dao.generic.specific.implementation." + strPojo + "DaoGenSpImpl") .getConstructor(String.class, Connection.class); TableDaoGenImpl oDao = (TableDaoGenImpl) c.newInstance(strObjectName, oConnection); ArrayList<String> alColumns = null; alColumns = oDao.getPrettyColumnsNames(); GsonBuilder gsonBuilder = new GsonBuilder(); Gson gson = gsonBuilder.create(); data = gson.toJson(alColumns); } catch (Exception ex) { oConnection.rollback(); ExceptionBooster.boost( new Exception(this.getClass().getName() + ":getPrettyColumns ERROR: " + ex.getMessage())); } finally { oConnection.commit(); } return data; }
From source file:com.goplace.service.generic.implementation.MetaServiceGenImpl.java
License:Open Source License
@Override public String getColumns() throws Exception { String data = null;// w w w .ja v a 2 s. c om try { oConnection.setAutoCommit(false); Constructor c = Class .forName("com.goplace.dao.generic.specific.implementation." + strPojo + "DaoGenSpImpl") .getConstructor(String.class, Connection.class); TableDaoGenImpl oDao = (TableDaoGenImpl) c.newInstance(strObjectName, oConnection); ArrayList<String> alColumns = null; alColumns = oDao.getColumnsNames(); GsonBuilder gsonBuilder = new GsonBuilder(); Gson gson = gsonBuilder.create(); data = gson.toJson(alColumns); } catch (Exception ex) { oConnection.rollback(); ExceptionBooster .boost(new Exception(this.getClass().getName() + ":getColumns ERROR: " + ex.getMessage())); } finally { oConnection.commit(); } return data; }