// Path: json/src/main/java/com/esri/json/deserializer/GeometryJsonDeserializer.java
// public class GeometryJsonDeserializer extends JsonDeserializer<Geometry> {
// 
// 	public GeometryJsonDeserializer(){}
// 	
// 	@Override
// 	public Geometry deserialize(JsonParser arg0, DeserializationContext arg1)
// 			throws IOException, JsonProcessingException {
// 		return GeometryEngine.jsonToGeometry(arg0).getGeometry();
// 	}
// }
// 
// Path: json/src/main/java/com/esri/json/deserializer/GeometryTypeJsonDeserializer.java
// public class GeometryTypeJsonDeserializer extends JsonDeserializer<Geometry.Type> {
// 
// 	public GeometryTypeJsonDeserializer(){}
// 	
// 	@Override
// 	public Geometry.Type deserialize(JsonParser parser, DeserializationContext arg1)
// 			throws IOException, JsonProcessingException {
// 		
// 		String type_text = parser.getText();
// 		
// 		// geometry type enumerations coming from the JSON are prepended with "esriGeometry" (i.e. esriGeometryPolygon)
// 		// while the geometry-java-api uses the form Geometry.Type.Polygon
// 		if (type_text.startsWith("esriGeometry"))
// 		{
// 			// cut out esriGeometry to match Geometry.Type enumeration values
// 			type_text = type_text.substring(12);
// 			
// 			try {
// 				return Enum.valueOf(Geometry.Type.class, type_text);
// 			} catch (Exception e){
// 				// parsing failed, fall through to unknown geometry type
// 			}
// 		}
// 		
// 		
// 		return Geometry.Type.Unknown;
// 	}
// }
// 
// Path: json/src/main/java/com/esri/json/deserializer/SpatialReferenceJsonDeserializer.java
// public class SpatialReferenceJsonDeserializer extends JsonDeserializer<SpatialReference> {
// 
// 	public SpatialReferenceJsonDeserializer(){}
// 	
// 	@Override
// 	public SpatialReference deserialize(JsonParser parser, DeserializationContext arg1)
// 			throws IOException, JsonProcessingException {
// 		try {
// 			return SpatialReference.fromJson(parser);
// 		} catch (Exception e) {
// 			return null;
// 		}
// 	}
// }
// 
// Path: json/src/main/java/com/esri/json/serializer/GeometryJsonSerializer.java
// public class GeometryJsonSerializer extends JsonSerializer<Geometry> {
// 
// 	@Override
// 	public void serialize(Geometry geometry, JsonGenerator jsonGenerator,
// 			SerializerProvider arg2) throws IOException,
// 			JsonProcessingException {
// 		
// 		jsonGenerator.writeRawValue(GeometryEngine.geometryToJson(null, geometry));
// 	}
// }
// 
// Path: json/src/main/java/com/esri/json/serializer/GeometryTypeJsonSerializer.java
// public class GeometryTypeJsonSerializer extends JsonSerializer<Geometry.Type>{
// 
// 	@Override
// 	public void serialize(Type geometryType, JsonGenerator jsonGenerator, SerializerProvider arg2)
// 			throws IOException, JsonProcessingException {
// 		jsonGenerator.writeString("esriGeometry" + geometryType);
// 	}
// }
// 
// Path: json/src/main/java/com/esri/json/serializer/SpatialReferenceJsonSerializer.java
// public class SpatialReferenceJsonSerializer extends JsonSerializer<SpatialReference>{
// 
// 	@Override
// 	public void serialize(SpatialReference spatialReference, JsonGenerator jsonGenerator,
// 			SerializerProvider arg2) throws IOException,
// 			JsonProcessingException {
// 			
// 		int wkid = spatialReference.getID();
// 		
// 		jsonGenerator.writeStartObject();
// 		jsonGenerator.writeObjectField("wkid", wkid);
// 		jsonGenerator.writeEndObject();
// 	}
// 
// }


import java.io.IOException;
import java.io.InputStream;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.SpatialReference;
import com.esri.json.deserializer.GeometryJsonDeserializer;
import com.esri.json.deserializer.GeometryTypeJsonDeserializer;
import com.esri.json.deserializer.SpatialReferenceJsonDeserializer;
import com.esri.json.serializer.GeometryJsonSerializer;
import com.esri.json.serializer.GeometryTypeJsonSerializer;
import com.esri.json.serializer.SpatialReferenceJsonSerializer;
package com.esri.json;




public class EsriJsonFactory {

	private static final ObjectMapper jsonObjectMapper;
	private static final JsonFactory jsonFactory = new JsonFactory();
	
	static {
		jsonObjectMapper = new ObjectMapper();

		SimpleModule module = new SimpleModule("EsriJsonModule", new Version(1, 0, 0, null));
		
		// add deserializers and serializers for types that can't be mapped field for field from the JSON
		module.addDeserializer(Geometry.class, new GeometryJsonDeserializer());
		module.addDeserializer(SpatialReference.class, new SpatialReferenceJsonDeserializer());
		module.addDeserializer(Geometry.Type.class, new GeometryTypeJsonDeserializer());
		
		module.addSerializer(Geometry.class, new GeometryJsonSerializer());
// Path: json/src/main/java/com/esri/json/deserializer/GeometryJsonDeserializer.java
// public class GeometryJsonDeserializer extends JsonDeserializer<Geometry> {
// 
// 	public GeometryJsonDeserializer(){}
// 	
// 	@Override
// 	public Geometry deserialize(JsonParser arg0, DeserializationContext arg1)
// 			throws IOException, JsonProcessingException {
// 		return GeometryEngine.jsonToGeometry(arg0).getGeometry();
// 	}
// }
// 
// Path: json/src/main/java/com/esri/json/deserializer/GeometryTypeJsonDeserializer.java
// public class GeometryTypeJsonDeserializer extends JsonDeserializer<Geometry.Type> {
// 
// 	public GeometryTypeJsonDeserializer(){}
// 	
// 	@Override
// 	public Geometry.Type deserialize(JsonParser parser, DeserializationContext arg1)
// 			throws IOException, JsonProcessingException {
// 		
// 		String type_text = parser.getText();
// 		
// 		// geometry type enumerations coming from the JSON are prepended with "esriGeometry" (i.e. esriGeometryPolygon)
// 		// while the geometry-java-api uses the form Geometry.Type.Polygon
// 		if (type_text.startsWith("esriGeometry"))
// 		{
// 			// cut out esriGeometry to match Geometry.Type enumeration values
// 			type_text = type_text.substring(12);
// 			
// 			try {
// 				return Enum.valueOf(Geometry.Type.class, type_text);
// 			} catch (Exception e){
// 				// parsing failed, fall through to unknown geometry type
// 			}
// 		}
// 		
// 		
// 		return Geometry.Type.Unknown;
// 	}
// }
// 
// Path: json/src/main/java/com/esri/json/deserializer/SpatialReferenceJsonDeserializer.java
// public class SpatialReferenceJsonDeserializer extends JsonDeserializer<SpatialReference> {
// 
// 	public SpatialReferenceJsonDeserializer(){}
// 	
// 	@Override
// 	public SpatialReference deserialize(JsonParser parser, DeserializationContext arg1)
// 			throws IOException, JsonProcessingException {
// 		try {
// 			return SpatialReference.fromJson(parser);
// 		} catch (Exception e) {
// 			return null;
// 		}
// 	}
// }
// 
// Path: json/src/main/java/com/esri/json/serializer/GeometryJsonSerializer.java
// public class GeometryJsonSerializer extends JsonSerializer<Geometry> {
// 
// 	@Override
// 	public void serialize(Geometry geometry, JsonGenerator jsonGenerator,
// 			SerializerProvider arg2) throws IOException,
// 			JsonProcessingException {
// 		
// 		jsonGenerator.writeRawValue(GeometryEngine.geometryToJson(null, geometry));
// 	}
// }
// 
// Path: json/src/main/java/com/esri/json/serializer/GeometryTypeJsonSerializer.java
// public class GeometryTypeJsonSerializer extends JsonSerializer<Geometry.Type>{
// 
// 	@Override
// 	public void serialize(Type geometryType, JsonGenerator jsonGenerator, SerializerProvider arg2)
// 			throws IOException, JsonProcessingException {
// 		jsonGenerator.writeString("esriGeometry" + geometryType);
// 	}
// }
// 
// Path: json/src/main/java/com/esri/json/serializer/SpatialReferenceJsonSerializer.java
// public class SpatialReferenceJsonSerializer extends JsonSerializer<SpatialReference>{
// 
// 	@Override
// 	public void serialize(SpatialReference spatialReference, JsonGenerator jsonGenerator,
// 			SerializerProvider arg2) throws IOException,
// 			JsonProcessingException {
// 			
// 		int wkid = spatialReference.getID();
// 		
// 		jsonGenerator.writeStartObject();
// 		jsonGenerator.writeObjectField("wkid", wkid);
// 		jsonGenerator.writeEndObject();
// 	}
// 
// }


// Path: json/src/main/java/com/esri/json/EsriJsonFactory.java
import java.io.IOException;
import java.io.InputStream;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.SpatialReference;
import com.esri.json.deserializer.GeometryJsonDeserializer;
import com.esri.json.deserializer.GeometryTypeJsonDeserializer;
import com.esri.json.deserializer.SpatialReferenceJsonDeserializer;
import com.esri.json.serializer.GeometryJsonSerializer;
import com.esri.json.serializer.GeometryTypeJsonSerializer;
import com.esri.json.serializer.SpatialReferenceJsonSerializer;

package com.esri.json;




public class EsriJsonFactory {

	private static final ObjectMapper jsonObjectMapper;
	private static final JsonFactory jsonFactory = new JsonFactory();
	
	static {
		jsonObjectMapper = new ObjectMapper();

		SimpleModule module = new SimpleModule("EsriJsonModule", new Version(1, 0, 0, null));
		
		// add deserializers and serializers for types that can't be mapped field for field from the JSON
		module.addDeserializer(Geometry.class, new GeometryJsonDeserializer());
		module.addDeserializer(SpatialReference.class, new SpatialReferenceJsonDeserializer());
		module.addDeserializer(Geometry.Type.class, new GeometryTypeJsonDeserializer());
		
		module.addSerializer(Geometry.class, new GeometryJsonSerializer());
		module.addSerializer(Geometry.Type.class, new GeometryTypeJsonSerializer());