Android Open Source - spotastop Resource






From Project

Back to project page spotastop.

License

The source code is released under:

MIT License

If you think the Android project spotastop 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 resources;
/*from  www . ja  va  2  s  . c  om*/
import java.lang.reflect.Type;
import java.util.ArrayList;

import rest.RestApi;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.nicfix.gsoncompatibility.GsonConfigurator;

public class Resource implements JsonDeserializer<Resource>,
    JsonSerializer<Resource> {

  protected String resourceClassifier = "becontent\\resource\\entity\\Resource";

  protected long resourceIdentifier;

  public long getResourceIdentifier() {
    return resourceIdentifier;
  }

  public void setResourceIdentifier(long resourceIdentifier) {
    this.resourceIdentifier = resourceIdentifier;
  }

  public String getResourceClassifier() {
    return resourceClassifier;
  }

  public Resource() {
    ResourcesMapper.getInstance().registerResClass(resourceClassifier,
        this.getClass());
    ResourcesCache.getInstance().storeResource(this);
    GsonConfigurator.getInstance().registerDeserializer(this,
        this.getClass());
  }

  public void store() {
    ArrayList<Resource> resources = new ArrayList<Resource>();
    resources.add(this);
    RestApi.editResources(resources,null);
  }

  public Resource(String resourceClassifier) {
    this.resourceClassifier = resourceClassifier;
    ResourcesMapper.getInstance().registerResClass(resourceClassifier,
        this.getClass());
    ResourcesCache.getInstance().storeResource(this);
    GsonConfigurator.getInstance().registerDeserializer(this,
        this.getClass());
  }

  @Override
  public Resource deserialize(JsonElement arg0, Type arg1,
      JsonDeserializationContext arg2) throws JsonParseException {
    Resource turnback = new Resource();
    turnback.resourceClassifier = arg0.getAsJsonObject()
        .get("resourceClassifier").getAsString();
    if (arg0.getAsJsonObject().get("resourceIdentifier") != null)
      turnback.resourceClassifier = arg0.getAsJsonObject()
          .get("resourceIdentifier").getAsString();
    return turnback;
  }

  @Override
  public JsonElement serialize(Resource arg0, Type arg1,
      JsonSerializationContext arg2) {
    JsonObject obj = new JsonObject();
    obj.addProperty("resourceClassifier", this.resourceClassifier);
    obj.addProperty("id", this.resourceIdentifier);
    return obj;
  }

}




Java Source Code List

.LoaderTester.java
com.cipciop.spotastop.ErrorActivity.java
com.cipciop.spotastop.LoginActivity.java
com.cipciop.spotastop.RegisterActivity.java
com.cipciop.spotastop.SelectBusLine.java
com.cipciop.spotastop.SpotActivity.java
com.cipciop.spotastop.StopSpotApp.java
com.cipciop.spotastop.domain.BusStop.java
com.cipciop.spotastop.domain.GeoPos.java
com.cipciop.spotastop.domain.Line.java
com.cipciop.spotastop.domain.User.java
com.cipciop.spotastop.presentation.BusLineItem.java
com.cipciop.spotastop.services.JarvisDynDnsService.java
com.cipciop.spotastop.services.LoginService.java
com.cipciop.spotastop.services.RegistrationService.java
com.cipciop.spotastop.services.RetrieveLinesListService.java
com.cipciop.spotastop.services.SpotBusStopService.java
com.nicfix.gsoncompatibility.GsonConfigurator.java
requests.CreatorRequest.java
requests.Criteria.java
requests.Data.java
requests.EditorRequest.java
requests.Link.java
requests.LinkerRequest.java
requests.LoaderRequest.java
requests.StorerRequest.java
requests.Unlink.java
requests.beContentRequest.java
resources.Resource.java
resources.ResourcesCache.java
resources.ResourcesMapper.java
responses.AsyncCallback.java
responses.beContentResponse.java
rest.RestApi.java
settings.Settings.java