Android Open Source - disconnected-content-explorer-android Feature Deserializer






From Project

Back to project page disconnected-content-explorer-android.

License

The source code is released under:

MIT License

If you think the Android project disconnected-content-explorer-android 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 mil.nga.dice.jackson.deserializer;
/*from  w  w w.  j  a  v  a 2s  .c o  m*/
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.vividsolutions.jts.geom.Geometry;

public class FeatureDeserializer extends Deserializer {

  private GeometryDeserializer geometryDeserializer = new GeometryDeserializer();

  public Collection<Geometry> parseFeatures(InputStream is) throws JsonParseException, IOException {
      Collection<Geometry> features = new ArrayList<Geometry>();
    JsonParser parser = factory.createParser(is);
    parser.nextToken();

    if (parser.getCurrentToken() != JsonToken.START_OBJECT) {
      return features;
    }

    while (parser.nextToken() != JsonToken.END_OBJECT) {
      String name = parser.getCurrentName();
      if ("features".equals(name)) {
        parser.nextToken();
        while (parser.nextToken() != JsonToken.END_ARRAY) {
            Geometry geometry = parseFeature(parser);
          features.add(geometry);
        }
      } else {
        parser.nextToken();
        parser.skipChildren();
      }
    }

    parser.close();
    return features;
  }

  
  private Geometry parseFeature(JsonParser parser) throws JsonParseException, IOException {
      Geometry geometry = null;
    if (parser.getCurrentToken() != JsonToken.START_OBJECT) {
      Collections.emptyList();
    }

    while (parser.nextToken() != JsonToken.END_OBJECT) {
      String name = parser.getCurrentName();
      if ("geometry".equals(name)) {
        parser.nextToken();
        geometry = geometryDeserializer.parseGeometry(parser);
      } else {
        parser.nextToken();
        parser.skipChildren();
      }
    }
    
    return geometry;
  }
}




Java Source Code List

mil.nga.dice.DICE.java
mil.nga.dice.gridview.CustomGrid.java
mil.nga.dice.gridview.ReportGridActivity.java
mil.nga.dice.gridview.ReportGridFragment.java
mil.nga.dice.jackson.deserializer.Deserializer.java
mil.nga.dice.jackson.deserializer.FeatureDeserializer.java
mil.nga.dice.jackson.deserializer.GeometryDeserializer.java
mil.nga.dice.listview.CustomList.java
mil.nga.dice.listview.ReportListActivity.java
mil.nga.dice.listview.ReportListFragment.java
mil.nga.dice.listview.ReportListItem.java
mil.nga.dice.map.BackgroundTileProvider.java
mil.nga.dice.map.OfflineMapLoader.java
mil.nga.dice.map.OfflineMap.java
mil.nga.dice.map.ReportMapActivity.java
mil.nga.dice.map.ReportMapFragment.java
mil.nga.dice.report.NoteActivity.java
mil.nga.dice.report.NoteFragment.java
mil.nga.dice.report.ReportDetailActivity.java
mil.nga.dice.report.ReportDetailFragment.java
mil.nga.dice.report.ReportDropbox.java
mil.nga.dice.report.ReportManager.java
mil.nga.dice.report.ReportUnzipRunnable.java
mil.nga.dice.report.Report.java