You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/02/21 17:28:13 UTC
[10/14] [OLINGO-169] First huge import from ODataJClient: for the
moment,
it just build (no tests yet) and dummy Edm interfaces are used instead of the
ones from commons-api
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataValue.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataValue.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataValue.java
new file mode 100644
index 0000000..a6e2201
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataValue.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data;
+
+import java.io.Serializable;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * Abstract representation of an OData entity property value.
+ */
+public abstract class ODataValue implements Serializable {
+
+ private static final long serialVersionUID = 7445422004232581877L;
+
+ /**
+ * Check is is a primitive value.
+ *
+ * @return 'TRUE' if primitive; 'FALSE' otherwise.
+ */
+ public boolean isPrimitive() {
+ return (this instanceof ODataPrimitiveValue);
+ }
+
+ /**
+ * Casts to primitive value.
+ *
+ * @return primitive value.
+ */
+ public ODataPrimitiveValue asPrimitive() {
+ return isPrimitive() ? (ODataPrimitiveValue) this : null;
+ }
+
+ /**
+ * Check is is a complex value.
+ *
+ * @return 'TRUE' if complex; 'FALSE' otherwise.
+ */
+ public boolean isComplex() {
+ return (this instanceof ODataComplexValue);
+ }
+
+ /**
+ * Casts to complex value.
+ *
+ * @return complex value.
+ */
+ public ODataComplexValue asComplex() {
+ return isComplex() ? (ODataComplexValue) this : null;
+ }
+
+ /**
+ * Check is is a collection value.
+ *
+ * @return 'TRUE' if collection; 'FALSE' otherwise.
+ */
+ public boolean isCollection() {
+ return (this instanceof ODataCollectionValue);
+ }
+
+ /**
+ * Casts to collection value.
+ *
+ * @return collection value.
+ */
+ public ODataCollectionValue asCollection() {
+ return isCollection() ? (ODataCollectionValue) this : null;
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/ComposedGeospatial.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/ComposedGeospatial.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/ComposedGeospatial.java
new file mode 100644
index 0000000..78886d2
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/ComposedGeospatial.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.geospatial;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Abstract base class for all Geometries that are composed out of other geospatial elements.
+ */
+public abstract class ComposedGeospatial<T extends Geospatial> extends Geospatial implements Iterable<T> {
+
+ private static final long serialVersionUID = 8796254901098541307L;
+
+ protected final List<T> geospatials;
+
+ /**
+ * Constructor.
+ *
+ * @param dimension dimension.
+ * @param type type.
+ * @param geospatials geospatials info.
+ */
+ protected ComposedGeospatial(final Dimension dimension, final Type type, final List<T> geospatials) {
+ super(dimension, type);
+ this.geospatials = new ArrayList<T>();
+ if (geospatials != null) {
+ this.geospatials.addAll(geospatials);
+ }
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public Iterator<T> iterator() {
+ return this.geospatials.iterator();
+ }
+
+ /**
+ * Checks if is empty.
+ *
+ * @return 'TRUE' if is empty; 'FALSE' otherwise.
+ */
+ public boolean isEmpty() {
+ return geospatials.isEmpty();
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public void setSrid(final Integer srid) {
+ for (Geospatial geospatial : this.geospatials) {
+ geospatial.setSrid(srid);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Geospatial.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Geospatial.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Geospatial.java
new file mode 100644
index 0000000..a5afae5
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Geospatial.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.geospatial;
+
+import java.io.Serializable;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.olingo.odata4.client.core.data.EdmSimpleType;
+
+/**
+ * Base class for all geospatial info.
+ */
+public abstract class Geospatial implements Serializable {
+
+ public enum Dimension {
+
+ GEOMETRY,
+ GEOGRAPHY;
+
+ }
+
+ public enum Type {
+
+ /**
+ * The OGIS geometry type number for points.
+ */
+ POINT,
+ /**
+ * The OGIS geometry type number for lines.
+ */
+ LINESTRING,
+ /**
+ * The OGIS geometry type number for polygons.
+ */
+ POLYGON,
+ /**
+ * The OGIS geometry type number for aggregate points.
+ */
+ MULTIPOINT,
+ /**
+ * The OGIS geometry type number for aggregate lines.
+ */
+ MULTILINESTRING,
+ /**
+ * The OGIS geometry type number for aggregate polygons.
+ */
+ MULTIPOLYGON,
+ /**
+ * The OGIS geometry type number for feature collections.
+ */
+ GEOSPATIALCOLLECTION;
+
+ }
+
+ protected final Dimension dimension;
+
+ protected final Type type;
+
+ /**
+ * Null value means it is expected to vary per instance.
+ */
+ protected Integer srid;
+
+ /**
+ * Constructor.
+ *
+ * @param dimension dimension.
+ * @param type type.
+ */
+ protected Geospatial(final Dimension dimension, final Type type) {
+ this.dimension = dimension;
+ this.type = type;
+ }
+
+ /**
+ * Gets dimension.
+ *
+ * @return dimension.
+ * @see Dimension
+ */
+ public Dimension getDimension() {
+ return dimension;
+ }
+
+ /**
+ * Gets type.
+ *
+ * @return type.
+ * @see Type
+ */
+ public Type getType() {
+ return type;
+ }
+
+ /**
+ * Gets s-rid.
+ *
+ * @return s-rid.
+ */
+ public Integer getSrid() {
+ return srid;
+ }
+
+ /**
+ * Sets s-rid.
+ *
+ * @param srid s-rid.
+ */
+ public void setSrid(final Integer srid) {
+ this.srid = srid;
+ }
+
+ public abstract EdmSimpleType getEdmSimpleType();
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/GeospatialCollection.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/GeospatialCollection.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/GeospatialCollection.java
new file mode 100644
index 0000000..4977953
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/GeospatialCollection.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.core.data.EdmSimpleType;
+
+/**
+ * Wrapper for a collection of geospatials info.
+ */
+public class GeospatialCollection extends ComposedGeospatial<Geospatial> {
+
+ private static final long serialVersionUID = -9181547636133878977L;
+
+ /**
+ * Constructor.
+ *
+ * @param dimension dimension.
+ * @param geospatials geospatials info.
+ */
+ public GeospatialCollection(final Dimension dimension, final List<Geospatial> geospatials) {
+ super(dimension, Type.GEOSPATIALCOLLECTION, geospatials);
+ }
+
+ @Override
+ public EdmSimpleType getEdmSimpleType() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyCollection
+ : EdmSimpleType.GeometryCollection;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/LineString.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/LineString.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/LineString.java
new file mode 100644
index 0000000..09c9638
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/LineString.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.core.data.EdmSimpleType;
+
+public class LineString extends ComposedGeospatial<Point> {
+
+ private static final long serialVersionUID = 3207958185407535907L;
+
+ public LineString(final Dimension dimension, final List<Point> points) {
+ super(dimension, Type.LINESTRING, points);
+ }
+
+ @Override
+ public EdmSimpleType getEdmSimpleType() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyLineString
+ : EdmSimpleType.GeometryLineString;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiLineString.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiLineString.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiLineString.java
new file mode 100644
index 0000000..a506dd8
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiLineString.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.core.data.EdmSimpleType;
+
+public class MultiLineString extends ComposedGeospatial<LineString> {
+
+ private static final long serialVersionUID = -5042414471218124125L;
+
+ public MultiLineString(final Dimension dimension, final List<LineString> lineStrings) {
+ super(dimension, Type.MULTILINESTRING, lineStrings);
+ }
+
+ @Override
+ public EdmSimpleType getEdmSimpleType() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyMultiLineString
+ : EdmSimpleType.GeometryMultiLineString;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiPoint.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiPoint.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiPoint.java
new file mode 100644
index 0000000..408c590
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiPoint.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.core.data.EdmSimpleType;
+
+public class MultiPoint extends ComposedGeospatial<Point> {
+
+ private static final long serialVersionUID = 4951011255142116129L;
+
+ public MultiPoint(final Dimension dimension, final List<Point> points) {
+ super(dimension, Type.MULTIPOINT, points);
+ }
+
+ @Override
+ public EdmSimpleType getEdmSimpleType() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyMultiPoint
+ : EdmSimpleType.GeometryMultiPoint;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiPolygon.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiPolygon.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiPolygon.java
new file mode 100644
index 0000000..4ce9dcb
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/MultiPolygon.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.core.data.EdmSimpleType;
+
+public class MultiPolygon extends ComposedGeospatial<Polygon> {
+
+ private static final long serialVersionUID = -160184788048512883L;
+
+ public MultiPolygon(final Dimension dimension, final List<Polygon> polygons) {
+ super(dimension, Type.MULTIPOLYGON, polygons);
+ }
+
+ @Override
+ public EdmSimpleType getEdmSimpleType() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyMultiPolygon
+ : EdmSimpleType.GeometryMultiPolygon;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Point.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Point.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Point.java
new file mode 100644
index 0000000..0168ae5
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Point.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.geospatial;
+
+import org.apache.olingo.odata4.client.core.data.EdmSimpleType;
+
+public class Point extends Geospatial {
+
+ private static final long serialVersionUID = 4917380107331557828L;
+
+ /**
+ * The X coordinate of the point. In most long/lat systems, this is the longitude.
+ */
+ private double x;
+
+ /**
+ * The Y coordinate of the point. In most long/lat systems, this is the latitude.
+ */
+ private double y;
+
+ /**
+ * The Z coordinate of the point. In most long/lat systems, this is a radius from the center of the earth, or the
+ * height / elevation over the ground.
+ */
+ private double z;
+
+ public Point(final Dimension dimension) {
+ super(dimension, Type.POINT);
+ }
+
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getZ() {
+ return z;
+ }
+
+ public void setZ(double z) {
+ this.z = z;
+ }
+
+ @Override
+ public EdmSimpleType getEdmSimpleType() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyPoint
+ : EdmSimpleType.GeometryPoint;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Polygon.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Polygon.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Polygon.java
new file mode 100644
index 0000000..f45d6a8
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/geospatial/Polygon.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.core.data.EdmSimpleType;
+
+/**
+ * Polygon.
+ */
+public class Polygon extends Geospatial {
+
+ private static final long serialVersionUID = 7797602503445391678L;
+
+ final ComposedGeospatial<Point> interior;
+
+ final ComposedGeospatial<Point> exterior;
+
+ /**
+ * Constructor.
+ *
+ * @param dimension dimension.
+ * @param interior interior points.
+ * @param exterior exterior points.
+ */
+ public Polygon(final Dimension dimension, final List<Point> interior, final List<Point> exterior) {
+ super(dimension, Type.POLYGON);
+ this.interior = new MultiPoint(dimension, interior);
+ this.exterior = new MultiPoint(dimension, exterior);
+ }
+
+ /**
+ * Gest interior points.
+ *
+ * @return interior points.
+ */
+ public ComposedGeospatial<Point> getInterior() {
+ return interior;
+ }
+
+ /**
+ * Gets exterior points.
+ *
+ * @return exterior points.I
+ */
+ public ComposedGeospatial<Point> getExterior() {
+ return exterior;
+ }
+
+ @Override
+ public EdmSimpleType getEdmSimpleType() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyPolygon
+ : EdmSimpleType.GeometryPolygon;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractEdmDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractEdmDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractEdmDeserializer.java
new file mode 100644
index 0000000..ac7d6cc
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractEdmDeserializer.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
+import java.io.IOException;
+import org.apache.olingo.odata4.client.api.ODataClient;
+import org.apache.olingo.odata4.client.core.edm.v4.ReturnTypeImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.annotation.ConstExprConstruct;
+
+public abstract class AbstractEdmDeserializer<T> extends JsonDeserializer<T> {
+
+ protected ODataClient client;
+
+ protected boolean isAnnotationConstExprConstruct(final JsonParser jp) throws IOException {
+ return ConstExprConstruct.Type.fromString(jp.getCurrentName()) != null;
+ }
+
+ protected ConstExprConstruct parseAnnotationConstExprConstruct(final JsonParser jp) throws IOException {
+ final ConstExprConstruct constExpr = new ConstExprConstruct();
+ constExpr.setType(ConstExprConstruct.Type.fromString(jp.getCurrentName()));
+ constExpr.setValue(jp.nextTextValue());
+ return constExpr;
+ }
+
+ protected ReturnTypeImpl parseReturnType(final JsonParser jp, final String elementName) throws IOException {
+ ReturnTypeImpl returnType;
+ if (elementName.equals(((FromXmlParser) jp).getStaxReader().getLocalName())) {
+ returnType = new ReturnTypeImpl();
+ returnType.setType(jp.nextTextValue());
+ } else {
+ jp.nextToken();
+ returnType = jp.getCodec().readValue(jp, ReturnTypeImpl.class);
+ }
+ return returnType;
+ }
+
+ protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException;
+
+ @Override
+ public T deserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ client = (ODataClient) ctxt.findInjectableValue(ODataClient.class.getName(), null, null);
+ return doDeserialize(jp, ctxt);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractJacksonTool.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractJacksonTool.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractJacksonTool.java
new file mode 100644
index 0000000..b524ba9
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractJacksonTool.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import com.fasterxml.aalto.stax.InputFactoryImpl;
+import com.fasterxml.aalto.stax.OutputFactoryImpl;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.InjectableValues;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler;
+import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
+import com.fasterxml.jackson.dataformat.xml.XmlFactory;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import java.io.IOException;
+import org.apache.olingo.odata4.client.api.ODataClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+abstract class AbstractJacksonTool {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(AbstractJacksonTool.class);
+
+ protected final ODataClient client;
+
+ protected AbstractJacksonTool(final ODataClient client) {
+ this.client = client;
+ }
+
+ protected ObjectMapper getObjectMapper() {
+ final ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ mapper.setInjectableValues(new InjectableValues.Std().addValue(ODataClient.class, client));
+
+ mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(),
+ mapper.getSerializationConfig().withAttribute(ODataClient.class, client),
+ mapper.getSerializerFactory()));
+
+ return mapper;
+ }
+
+ protected XmlMapper getXmlMapper() {
+ final XmlMapper xmlMapper = new XmlMapper(
+ new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
+
+ xmlMapper.setInjectableValues(new InjectableValues.Std().addValue(ODataClient.class, client));
+
+ xmlMapper.addHandler(new DeserializationProblemHandler() {
+
+ @Override
+ public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp,
+ final JsonDeserializer<?> deserializer, final Object beanOrClass, final String propertyName)
+ throws IOException, JsonProcessingException {
+
+ // skip any unknown property
+ LOG.warn("Skipping unknown property {}", propertyName);
+ ctxt.getParser().skipChildren();
+ return true;
+ }
+ });
+ return xmlMapper;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataDeserializer.java
new file mode 100644
index 0000000..2cfc974
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataDeserializer.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import java.io.InputStream;
+import org.apache.olingo.odata4.client.api.ODataClient;
+import org.apache.olingo.odata4.client.api.data.ODataDeserializer;
+import org.apache.olingo.odata4.client.core.utils.XMLUtils;
+import org.w3c.dom.Element;
+
+public abstract class AbstractODataDeserializer extends AbstractJacksonTool implements ODataDeserializer {
+
+ private static final long serialVersionUID = -4244158979195609909L;
+
+// private final AtomDeserializer atomDeserializer;
+ public AbstractODataDeserializer(final ODataClient client) {
+ super(client);
+// this.atomDeserializer = new AtomDeserializer(client);
+ }
+
+// @Override
+// @SuppressWarnings("unchecked")
+// public <T extends Feed> T toFeed(final InputStream input, final Class<T> reference) {
+// T entry;
+//
+// if (AtomFeed.class.equals(reference)) {
+// entry = (T) toAtomFeed(input);
+// } else {
+// entry = (T) toJSONFeed(input);
+// }
+//
+// return entry;
+// }
+//
+// @Override
+// @SuppressWarnings("unchecked")
+// public <T extends Entry> T toEntry(final InputStream input, final Class<T> reference) {
+// T entry;
+//
+// if (AtomEntry.class.equals(reference)) {
+// entry = (T) toAtomEntry(input);
+//
+// } else {
+// entry = (T) toJSONEntry(input);
+// }
+//
+// return entry;
+// }
+//
+// @Override
+// public Element toPropertyDOM(final InputStream input, final ODataFormat format) {
+// return format == ODataFormat.XML
+// ? toPropertyDOMFromXML(input)
+// : toPropertyDOMFromJSON(input);
+// }
+//
+// @Override
+// public LinkCollection toLinkCollection(final InputStream input, final ODataFormat format) {
+// return format == ODataFormat.XML
+// ? toLinkCollectionFromXML(input)
+// : toLinkCollectionFromJSON(input);
+// }
+//
+// @Override
+// public ODataError toODataError(final InputStream input, final boolean isXML) {
+// return isXML
+// ? toODataErrorFromXML(input)
+// : toODataErrorFromJSON(input);
+// }
+//
+ @Override
+ public Element toDOM(final InputStream input) {
+ return XMLUtils.PARSER.deserialize(input);
+ }
+//
+// /*
+// * ------------------ Protected methods ------------------
+// */
+// protected AtomFeed toAtomFeed(final InputStream input) {
+// try {
+// return atomDeserializer.feed(toDOM(input));
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While deserializing Atom feed", e);
+// }
+// }
+//
+// protected AtomEntry toAtomEntry(final InputStream input) {
+// try {
+// return atomDeserializer.entry(toDOM(input));
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While deserializing Atom entry", e);
+// }
+// }
+//
+// protected JSONFeed toJSONFeed(final InputStream input) {
+// try {
+// return getObjectMapper().readValue(input, JSONFeed.class);
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While deserializing JSON feed", e);
+// }
+// }
+//
+// protected abstract AbstractJSONEntry toJSONEntry(final InputStream input);
+//
+// protected Element toPropertyDOMFromXML(final InputStream input) {
+// return toDOM(input);
+// }
+//
+// protected Element toPropertyDOMFromJSON(final InputStream input) {
+// try {
+// return getObjectMapper().readValue(input, JSONProperty.class).getContent();
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While deserializing JSON property", e);
+// }
+// }
+//
+// protected XMLLinkCollection toLinkCollectionFromXML(final InputStream input) {
+// final Element root = toDOM(input);
+//
+// final NodeList uris = root.getOwnerDocument().getElementsByTagName(ODataConstants.ELEM_URI);
+//
+// final List<URI> links = new ArrayList<URI>();
+// for (int i = 0; i < uris.getLength(); i++) {
+// links.add(URI.create(uris.item(i).getTextContent()));
+// }
+//
+// final NodeList next = root.getElementsByTagName(ODataConstants.NEXT_LINK_REL);
+// final XMLLinkCollection linkCollection = next.getLength() > 0
+// ? new XMLLinkCollection(URI.create(next.item(0).getTextContent()))
+// : new XMLLinkCollection();
+// linkCollection.setLinks(links);
+//
+// return linkCollection;
+// }
+//
+// protected JSONLinkCollection toLinkCollectionFromJSON(final InputStream input) {
+// try {
+// return getObjectMapper().readValue(input, JSONLinkCollection.class);
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While deserializing JSON $links", e);
+// }
+// }
+//
+// protected XMLODataError toODataErrorFromXML(final InputStream input) {
+// try {
+// final XmlMapper xmlMapper = new XmlMapper(
+// new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
+// return xmlMapper.readValue(input, XMLODataError.class);
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While deserializing XML error", e);
+// }
+// }
+//
+// protected JSONODataError toODataErrorFromJSON(final InputStream input) {
+// try {
+// return getObjectMapper().readValue(input, JSONODataErrorBundle.class).getError();
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While deserializing JSON error", e);
+// }
+// }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataReader.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataReader.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataReader.java
new file mode 100644
index 0000000..0e45ca5
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataReader.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import org.apache.olingo.odata4.client.api.ODataClient;
+import org.apache.olingo.odata4.client.api.data.ODataReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractODataReader implements ODataReader {
+
+ private static final long serialVersionUID = -1988865870981207079L;
+
+ /**
+ * Logger.
+ */
+ protected static final Logger LOG = LoggerFactory.getLogger(AbstractODataReader.class);
+
+ protected final ODataClient client;
+
+ protected AbstractODataReader(final ODataClient client) {
+ this.client = client;
+ }
+
+// @Override
+// public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
+// return client.getBinder().getODataEntitySet(
+// client.getDeserializer().toFeed(input, ResourceFactory.feedClassForFormat(format)));
+// }
+//
+// @Override
+// public ODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
+// return client.getBinder().getODataEntity(
+// client.getDeserializer().toEntry(input, ResourceFactory.entryClassForFormat(format)));
+// }
+//
+// @Override
+// public ODataProperty readProperty(final InputStream input, final ODataFormat format) {
+// final Element property = client.getDeserializer().toPropertyDOM(input, format);
+//
+// // The ODataProperty object is used either for actual entity properties and for invoke result
+// // (when return type is neither an entity nor a collection of entities).
+// // Such formats are mostly the same except for collections: an entity property looks like
+// // <aproperty m:type="Collection(AType)">
+// // <element>....</element>
+// // </aproperty>
+// //
+// // while an invoke result with returnType="Collection(AnotherType)" looks like
+// // <functionImportName>
+// // <element m:type="AnotherType">...</element>
+// // <functionImportName>
+// //
+// // The code below is meant for "normalizing" the latter into
+// // <functionImportName m:type="Collection(AnotherType)">
+// // <element m:type="AnotherType">...</element>
+// // <functionImportName>
+// final String type = property.getAttribute(ODataConstants.ATTR_M_TYPE);
+// final NodeList elements = property.getElementsByTagName(ODataConstants.ELEM_ELEMENT);
+// if (StringUtils.isBlank(type) && elements != null && elements.getLength() > 0) {
+// final Node elementType = elements.item(0).getAttributes().getNamedItem(ODataConstants.ATTR_M_TYPE);
+// if (elementType != null) {
+// property.setAttribute(ODataConstants.ATTR_M_TYPE, "Collection(" + elementType.getTextContent() + ")");
+// }
+// }
+//
+// return client.getBinder().getProperty(property);
+// }
+//
+// @Override
+// public ODataLinkCollection readLinks(final InputStream input, final ODataFormat format) {
+// return client.getBinder().getLinkCollection(
+// client.getDeserializer().toLinkCollection(input, format));
+// }
+//
+// @Override
+// public ODataError readError(final InputStream inputStream, final boolean isXML) {
+// return client.getDeserializer().toODataError(inputStream, isXML);
+// }
+//
+// @Override
+// @SuppressWarnings("unchecked")
+// public <T> T read(final InputStream src, final String format, final Class<T> reference) {
+// Object res;
+//
+// try {
+// if (ODataEntitySetIterator.class.isAssignableFrom(reference)) {
+// res = new ODataEntitySetIterator(client, src, ODataPubFormat.fromString(format));
+// } else if (ODataEntitySet.class.isAssignableFrom(reference)) {
+// res = readEntitySet(src, ODataPubFormat.fromString(format));
+// } else if (ODataEntity.class.isAssignableFrom(reference)) {
+// res = readEntity(src, ODataPubFormat.fromString(format));
+// } else if (ODataProperty.class.isAssignableFrom(reference)) {
+// res = readProperty(src, ODataFormat.fromString(format));
+// } else if (ODataLinkCollection.class.isAssignableFrom(reference)) {
+// res = readLinks(src, ODataFormat.fromString(format));
+// } else if (ODataValue.class.isAssignableFrom(reference)) {
+// res = client.getPrimitiveValueBuilder().
+// setType(ODataValueFormat.fromString(format) == ODataValueFormat.TEXT
+// ? EdmSimpleType.String : EdmSimpleType.Stream).
+// setText(IOUtils.toString(src)).
+// build();
+// } else if (AbstractEdmMetadata.class.isAssignableFrom(reference)) {
+// res = readMetadata(src);
+// } else if (ODataServiceDocument.class.isAssignableFrom(reference)) {
+// res = readServiceDocument(src, ODataFormat.fromString(format));
+// } else if (ODataError.class.isAssignableFrom(reference)) {
+// res = readError(src, !format.toString().contains("json"));
+// } else {
+// throw new IllegalArgumentException("Invalid reference type " + reference);
+// }
+// } catch (Exception e) {
+// LOG.warn("Cast error", e);
+// res = null;
+// } finally {
+// if (!ODataEntitySetIterator.class.isAssignableFrom(reference)) {
+// IOUtils.closeQuietly(src);
+// }
+// }
+//
+// return (T) res;
+// }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataSerializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataSerializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataSerializer.java
new file mode 100644
index 0000000..2dc3c57
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/AbstractODataSerializer.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import org.apache.olingo.odata4.client.api.ODataClient;
+import org.apache.olingo.odata4.client.api.data.ODataSerializer;
+import org.apache.olingo.odata4.client.core.utils.XMLUtils;
+import org.w3c.dom.Node;
+
+public abstract class AbstractODataSerializer extends AbstractJacksonTool implements ODataSerializer {
+
+ private static final long serialVersionUID = -357777648541325363L;
+
+// private final AtomSerializer atomSerializer;
+ public AbstractODataSerializer(final ODataClient client) {
+ super(client);
+// this.atomSerializer = new AtomSerializer(client);
+ }
+
+// @Override
+// public <T extends Feed> void feed(final T obj, final OutputStream out) {
+// feed(obj, new OutputStreamWriter(out));
+// }
+//
+// @Override
+// public <T extends Feed> void feed(final T obj, final Writer writer) {
+// if (obj instanceof AtomFeed) {
+// atom((AtomFeed) obj, writer);
+// } else {
+// json((JSONFeed) obj, writer);
+// }
+// }
+//
+// @Override
+// public <T extends Entry> void entry(final T obj, final OutputStream out) {
+// entry(obj, new OutputStreamWriter(out));
+// }
+//
+// @Override
+// public <T extends Entry> void entry(final T obj, final Writer writer) {
+// if (obj instanceof AtomEntry) {
+// atom((AtomEntry) obj, writer);
+// } else {
+// json((JSONEntry) obj, writer);
+// }
+// }
+//
+// @Override
+// public void property(final Element element, final ODataFormat format, final OutputStream out) {
+// property(element, format, new OutputStreamWriter(out));
+// }
+//
+// @Override
+// public void property(final Element element, final ODataFormat format, final Writer writer) {
+// if (format == ODataFormat.XML) {
+// dom(element, writer);
+// } else {
+// json(element, writer);
+// }
+// }
+//
+// @Override
+// public void link(final ODataLink link, final ODataFormat format, final OutputStream out) {
+// link(link, format, new OutputStreamWriter(out));
+// }
+//
+// @Override
+// public void link(final ODataLink link, final ODataFormat format, final Writer writer) {
+// if (format == ODataFormat.XML) {
+// xmlLink(link, writer);
+// } else {
+// jsonLink(link, writer);
+// }
+// }
+//
+ @Override
+ public void dom(final Node content, final OutputStream out) {
+ dom(content, new OutputStreamWriter(out));
+ }
+
+ @Override
+ public void dom(final Node content, final Writer writer) {
+ XMLUtils.PARSER.serialize(content, writer);
+ }
+//
+// /*
+// * ------------------ Protected methods ------------------
+// */
+// protected <T extends AbstractPayloadObject> void atom(final T obj, final Writer writer) {
+// try {
+// dom(atomSerializer.serialize(obj), writer);
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While serializing Atom object", e);
+// }
+// }
+//
+// protected <T extends AbstractPayloadObject> void json(final T obj, final Writer writer) {
+// try {
+// getObjectMapper().writeValue(writer, obj);
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While serializing JSON object", e);
+// }
+// }
+//
+// protected void json(final Element element, final Writer writer) {
+// try {
+// final JSONProperty property = new JSONProperty();
+// property.setContent(element);
+// getObjectMapper().writeValue(writer, property);
+// } catch (IOException e) {
+// throw new IllegalArgumentException("While serializing JSON property", e);
+// }
+// }
+//
+// protected void xmlLink(final ODataLink link, final Writer writer) {
+// try {
+// final DocumentBuilder builder = XMLUtils.DOC_BUILDER_FACTORY.newDocumentBuilder();
+// final Document doc = builder.newDocument();
+// final Element uri = doc.createElementNS(
+// client.getWorkingVersion().getNamespaceMap().get(ODataVersion.NS_DATASERVICES),
+// ODataConstants.ELEM_URI);
+// uri.appendChild(doc.createTextNode(link.getLink().toASCIIString()));
+//
+// dom(uri, writer);
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While serializing XML link", e);
+// }
+// }
+//
+// protected void jsonLink(final ODataLink link, final Writer writer) {
+// final ObjectMapper mapper = getObjectMapper();
+// final ObjectNode uri = mapper.createObjectNode();
+// uri.put(ODataConstants.JSON_URL, link.getLink().toASCIIString());
+//
+// try {
+// mapper.writeValue(writer, uri);
+// } catch (Exception e) {
+// throw new IllegalArgumentException("While serializing JSON link", e);
+// }
+// }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/ComplexTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/ComplexTypeDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/ComplexTypeDeserializer.java
new file mode 100644
index 0000000..46f5bfa
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/ComplexTypeDeserializer.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.odata4.client.core.edm.AbstractComplexType;
+import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+public class ComplexTypeDeserializer extends AbstractEdmDeserializer<AbstractComplexType> {
+
+ @Override
+ protected AbstractComplexType doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractComplexType complexType = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.edm.v3.ComplexTypeImpl()
+ : new org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ complexType.setName(jp.nextTextValue());
+ } else if ("Abstract".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ setAbstractEntityType(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("BaseType".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ setBaseType(jp.nextTextValue());
+ } else if ("OpenType".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ setOpenType(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("Property".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (complexType instanceof org.apache.olingo.odata4.client.core.edm.v3.ComplexTypeImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.ComplexTypeImpl) complexType).
+ getProperties().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v3.PropertyImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ getProperties().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v4.PropertyImpl.class));
+ }
+ } else if ("NavigationProperty".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ getNavigationProperties().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v4.NavigationPropertyImpl.class));
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.ComplexTypeImpl) complexType).
+ setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ }
+ }
+ }
+
+ return complexType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityContainerDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityContainerDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityContainerDeserializer.java
new file mode 100644
index 0000000..1fa365e
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityContainerDeserializer.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.odata4.client.core.edm.AbstractEntityContainer;
+import org.apache.olingo.odata4.client.core.edm.v3.AssociationSetImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.ActionImportImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.SingletonImpl;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+@SuppressWarnings("rawtypes")
+public class EntityContainerDeserializer extends AbstractEdmDeserializer<AbstractEntityContainer> {
+
+ @Override
+ protected AbstractEntityContainer doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractEntityContainer entityContainer = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl()
+ : new org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ entityContainer.setName(jp.nextTextValue());
+ } else if ("Extends".equals(jp.getCurrentName())) {
+ entityContainer.setExtends(jp.nextTextValue());
+ } else if ("LazyLoadingEnabled".equals(jp.getCurrentName())) {
+ entityContainer.setLazyLoadingEnabled(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("IsDefaultEntityContainer".equals(jp.getCurrentName())) {
+ entityContainer.setDefaultEntityContainer(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("EntitySet".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (entityContainer instanceof org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl) entityContainer).
+ getEntitySets().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v3.EntitySetImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl) entityContainer).
+ getEntitySets().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v4.EntitySetImpl.class));
+ }
+ } else if ("AssociationSet".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl) entityContainer).
+ getAssociationSets().add(jp.getCodec().readValue(jp, AssociationSetImpl.class));
+ } else if ("Singleton".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl) entityContainer).
+ getSingletons().add(jp.getCodec().readValue(jp, SingletonImpl.class));
+ } else if ("ActionImport".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl) entityContainer).
+ getActionImports().add(jp.getCodec().readValue(jp, ActionImportImpl.class));
+ } else if ("FunctionImport".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (entityContainer instanceof org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.EntityContainerImpl) entityContainer).
+ getFunctionImports().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v3.FunctionImportImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl) entityContainer).
+ getFunctionImports().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v4.FunctionImportImpl.class));
+ }
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityContainerImpl) entityContainer).
+ setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ }
+ }
+ }
+
+ return entityContainer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityKeyDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityKeyDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityKeyDeserializer.java
new file mode 100644
index 0000000..7610817
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityKeyDeserializer.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.olingo.odata4.client.core.edm.EntityKeyImpl;
+import org.apache.olingo.odata4.client.core.edm.PropertyRefImpl;
+
+public class EntityKeyDeserializer extends AbstractEdmDeserializer<EntityKeyImpl> {
+
+ @Override
+ protected EntityKeyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final EntityKeyImpl entityKey = new EntityKeyImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+
+ if (token == JsonToken.FIELD_NAME && "PropertyRef".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ entityKey.getPropertyRefs().add(jp.getCodec().readValue(jp, PropertyRefImpl.class));
+ }
+ }
+
+ return entityKey;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntitySetDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntitySetDeserializer.java
new file mode 100644
index 0000000..4b9e66b
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntitySetDeserializer.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.odata4.client.core.edm.AbstractEntitySet;
+import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.NavigationPropertyBindingImpl;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+public class EntitySetDeserializer extends AbstractEdmDeserializer<AbstractEntitySet> {
+
+ @Override
+ protected AbstractEntitySet doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractEntitySet entitySet = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.edm.v3.EntitySetImpl()
+ : new org.apache.olingo.odata4.client.core.edm.v4.EntitySetImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ entitySet.setName(jp.nextTextValue());
+ } else if ("EntityType".equals(jp.getCurrentName())) {
+ entitySet.setEntityType(jp.nextTextValue());
+ } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntitySetImpl) entitySet).
+ setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntitySetImpl) entitySet).
+ getNavigationPropertyBindings().add(
+ jp.getCodec().readValue(jp, NavigationPropertyBindingImpl.class));
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntitySetImpl) entitySet).
+ setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ }
+ }
+ }
+
+ return entitySet;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityTypeDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityTypeDeserializer.java
new file mode 100644
index 0000000..c6fa3a4
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EntityTypeDeserializer.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.odata4.client.core.edm.AbstractEntityType;
+import org.apache.olingo.odata4.client.core.edm.EntityKeyImpl;
+import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+public class EntityTypeDeserializer extends AbstractEdmDeserializer<AbstractEntityType> {
+
+ @Override
+ protected AbstractEntityType doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractEntityType entityType = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.edm.v3.EntityTypeImpl()
+ : new org.apache.olingo.odata4.client.core.edm.v4.EntityTypeImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ entityType.setName(jp.nextTextValue());
+ } else if ("Abstract".equals(jp.getCurrentName())) {
+ entityType.setAbstractEntityType(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("BaseType".equals(jp.getCurrentName())) {
+ entityType.setBaseType(jp.nextTextValue());
+ } else if ("OpenType".equals(jp.getCurrentName())) {
+ entityType.setOpenType(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("HasStream".equals(jp.getCurrentName())) {
+ entityType.setHasStream(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("Key".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ entityType.setKey(jp.getCodec().readValue(jp, EntityKeyImpl.class));
+ } else if ("Property".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (entityType instanceof org.apache.olingo.odata4.client.core.edm.v3.EntityTypeImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.EntityTypeImpl) entityType).
+ getProperties().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v3.PropertyImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityTypeImpl) entityType).
+ getProperties().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v4.PropertyImpl.class));
+ }
+ } else if ("NavigationProperty".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (entityType instanceof org.apache.olingo.odata4.client.core.edm.v3.EntityTypeImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.EntityTypeImpl) entityType).
+ getNavigationProperties().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v3.NavigationPropertyImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityTypeImpl) entityType).
+ getNavigationProperties().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v4.NavigationPropertyImpl.class));
+ }
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EntityTypeImpl) entityType).
+ setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ }
+ }
+ }
+
+ return entityType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EnumTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EnumTypeDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EnumTypeDeserializer.java
new file mode 100644
index 0000000..9d3a563
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/EnumTypeDeserializer.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import java.io.IOException;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.odata4.client.core.edm.AbstractEnumType;
+import org.apache.olingo.odata4.client.core.edm.v4.AnnotationImpl;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+public class EnumTypeDeserializer extends AbstractEdmDeserializer<AbstractEnumType> {
+
+ @Override
+ protected AbstractEnumType doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractEnumType enumType = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.edm.v3.EnumTypeImpl()
+ : new org.apache.olingo.odata4.client.core.edm.v4.EnumTypeImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("Name".equals(jp.getCurrentName())) {
+ enumType.setName(jp.nextTextValue());
+ } else if ("UnderlyingType".equals(jp.getCurrentName())) {
+ enumType.setUnderlyingType(jp.nextTextValue());
+ } else if ("IsFlags".equals(jp.getCurrentName())) {
+ enumType.setFlags(BooleanUtils.toBoolean(jp.nextTextValue()));
+ } else if ("Member".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ if (enumType instanceof org.apache.olingo.odata4.client.core.edm.v3.EnumTypeImpl) {
+ ((org.apache.olingo.odata4.client.core.edm.v3.EnumTypeImpl) enumType).
+ getMembers().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v3.MemberImpl.class));
+ } else {
+ ((org.apache.olingo.odata4.client.core.edm.v4.EnumTypeImpl) enumType).
+ getMembers().add(jp.getCodec().readValue(jp,
+ org.apache.olingo.odata4.client.core.edm.v4.MemberImpl.class));
+ }
+ } else if ("Annotation".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ ((org.apache.olingo.odata4.client.core.edm.v4.EnumTypeImpl) enumType).
+ setAnnotation(jp.getCodec().readValue(jp, AnnotationImpl.class));
+ }
+ }
+ }
+
+ return enumType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/4f927e76/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/InjectableSerializerProvider.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/InjectableSerializerProvider.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/InjectableSerializerProvider.java
new file mode 100644
index 0000000..e5e8b93
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/impl/InjectableSerializerProvider.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.odata4.client.core.data.impl;
+
+import com.fasterxml.jackson.databind.SerializationConfig;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
+import com.fasterxml.jackson.databind.ser.SerializerFactory;
+
+class InjectableSerializerProvider extends DefaultSerializerProvider {
+
+ private static final long serialVersionUID = 3432260063063739646L;
+
+ public InjectableSerializerProvider(
+ final SerializerProvider src, final SerializationConfig config, final SerializerFactory factory) {
+
+ super(src, config, factory);
+ }
+
+ @Override
+ public InjectableSerializerProvider createInstance(
+ final SerializationConfig config, final SerializerFactory factory) {
+
+ return this;
+ }
+
+}