Android Open Source - geocamMemoForAndroid Django Memo Json Converter Implementation






From Project

Back to project page geocamMemoForAndroid.

License

The source code is released under:

NASA OPEN SOURCE AGREEMENT VERSION 1.3 THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE, REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN COMPUTER SOFTWARE ORI...

If you think the Android project geocamMemoForAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package gov.nasa.arc.geocam.memo.service;
//from  ww  w  .  j ava2 s  .c  om
import gov.nasa.arc.geocam.memo.bean.GeoCamMemoMessage;

import java.lang.reflect.Type;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

/**
 * The Class DjangoMemoJsonConverterImplementation.  This class 
 * provides the methods that manipulate the data into and from
 * the Json string
 */
public class DjangoMemoJsonConverterImplementation
    implements DjangoMemoJsonConverterInterface {

  /* (non-Javadoc)
   * @see gov.nasa.arc.geocam.memo.service.DjangoMemoJsonConverterInterface#deserializeList(java.lang.String)
   */
  @Override
  public List<GeoCamMemoMessage> deserializeList(String jsonString) {
    GsonBuilder builder = new GsonBuilder();
    builder.setDateFormat("MM/dd/yy HH:mm:ss");
    Gson gson = builder.create();
    
    Type listType = new TypeToken<List<GeoCamMemoMessage>>(){}.getType();
    
    return gson.fromJson(jsonString, listType);
  }

  /* (non-Javadoc)
   * @see gov.nasa.arc.geocam.memo.service.DjangoMemoJsonConverterInterface#deserialize(java.lang.String)
   */
  public GeoCamMemoMessage deserialize(String jsonString) {
    GsonBuilder builder = new GsonBuilder();
    builder.setDateFormat("MM/dd/yy HH:mm:ss");
    
    Gson gson = builder.create();
    return gson.fromJson(jsonString, GeoCamMemoMessage.class);
  }

  /* (non-Javadoc)
   * @see gov.nasa.arc.geocam.memo.service.DjangoMemoJsonConverterInterface#serialize(gov.nasa.arc.geocam.memo.bean.GeoCamMemoMessage)
   */
  @Override
  public String serialize(GeoCamMemoMessage message) {
    GsonBuilder builder = new GsonBuilder();
    builder.setDateFormat("MM/dd/yy HH:mm:ss");
    
    Gson gson = builder.create();
    String ret= gson.toJson(message);
    return ret;
  }
}




Java Source Code List

gov.nasa.arc.geocam.memo.GeoCamMemoModule.java
gov.nasa.arc.geocam.memo.GeoCamMemoRoboApplication.java
gov.nasa.arc.geocam.memo.UIUtils.java
gov.nasa.arc.geocam.memo.activity.GeoCamMemoCreateActivity.java
gov.nasa.arc.geocam.memo.activity.GeoCamMemoHomeActivity.java
gov.nasa.arc.geocam.memo.activity.GeoCamMemoMapActivity.java
gov.nasa.arc.geocam.memo.activity.GeoCamMemoMessageArrayAdapter.java
gov.nasa.arc.geocam.memo.activity.GeoCamMemoSettings.java
gov.nasa.arc.geocam.memo.bean.GeoCamMemoMessage.java
gov.nasa.arc.geocam.memo.exception.AuthenticationFailedException.java
gov.nasa.arc.geocam.memo.service.DjangoMemoImplementation.java
gov.nasa.arc.geocam.memo.service.DjangoMemoInterface.java
gov.nasa.arc.geocam.memo.service.DjangoMemoJsonConverterImplementation.java
gov.nasa.arc.geocam.memo.service.DjangoMemoJsonConverterInterface.java
gov.nasa.arc.geocam.memo.service.GeoLocationListener.java
gov.nasa.arc.geocam.memo.service.MemoMapOverlay.java
gov.nasa.arc.geocam.memo.service.SiteAuthCookieImplementation.java
gov.nasa.arc.geocam.memo.service.SiteAuthInterface.java