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/03/07 15:27:28 UTC
[2/4] [OLINGO-190] V3 service document deserializer merged,
V4 implemented
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/ComposedGeospatial.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/ComposedGeospatial.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/ComposedGeospatial.java
new file mode 100644
index 0000000..bdff17c
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/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.api.domain.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/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/Geospatial.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/Geospatial.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/Geospatial.java
new file mode 100644
index 0000000..47f830b
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/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.api.domain.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.api.domain.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/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/GeospatialCollection.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/GeospatialCollection.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/GeospatialCollection.java
new file mode 100644
index 0000000..732d5a2
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/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.api.domain.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.domain.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/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/LineString.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/LineString.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/LineString.java
new file mode 100644
index 0000000..8b8c6ac
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/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.api.domain.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.domain.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/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/MultiLineString.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/MultiLineString.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/MultiLineString.java
new file mode 100644
index 0000000..b849ecb
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/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.api.domain.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.domain.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/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/MultiPoint.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/MultiPoint.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/MultiPoint.java
new file mode 100644
index 0000000..6b68aea
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/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.api.domain.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.domain.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/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/MultiPolygon.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/MultiPolygon.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/MultiPolygon.java
new file mode 100644
index 0000000..a20286b
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/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.api.domain.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.domain.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/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/Point.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/Point.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/Point.java
new file mode 100644
index 0000000..13948fb
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/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.api.domain.geospatial;
+
+import org.apache.olingo.odata4.client.api.domain.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/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/Polygon.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/Polygon.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/geospatial/Polygon.java
new file mode 100644
index 0000000..87159cb
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/domain/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.api.domain.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.domain.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/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataBinder.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataBinder.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataBinder.java
new file mode 100644
index 0000000..6468650
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataBinder.java
@@ -0,0 +1,121 @@
+/*
+ * 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.api.op;
+
+import java.io.Serializable;
+import org.apache.olingo.odata4.client.api.data.ServiceDocument;
+import org.apache.olingo.odata4.client.api.domain.ODataServiceDocument;
+
+public interface ODataBinder extends Serializable {
+
+ /**
+ * Gets <tt>ODataServiceDocument</tt> from the given service document resource.
+ *
+ * @param resource service document resource.
+ * @return <tt>ODataServiceDocument</tt> object.
+ */
+ ODataServiceDocument getODataServiceDocument(ServiceDocument resource);
+
+ /**
+ * Gets a <tt>FeedResource</tt> from the given OData entity set.
+ *
+ * @param <T> feed resource type.
+ * @param feed OData entity set.
+ * @param reference reference class.
+ * @return <tt>FeedResource</tt> object.
+ */
+// <T extends Feed> T getFeed(ODataEntitySet feed, Class<T> reference);
+ /**
+ * Gets an <tt>EntryResource</tt> from the given OData entity.
+ *
+ * @param <T> entry resource type.
+ * @param entity OData entity.
+ * @param reference reference class.
+ * @return <tt>EntryResource</tt> object.
+ */
+// <T extends Entry> T getEntry(ODataEntity entity, Class<T> reference);
+ /**
+ * Gets an <tt>EntryResource</tt> from the given OData entity.
+ *
+ * @param <T> entry resource type.
+ * @param entity OData entity.
+ * @param reference reference class.
+ * @param setType whether to explicitly output type information.
+ * @return <tt>EntryResource</tt> object.
+ */
+// <T extends Entry> T getEntry(ODataEntity entity, Class<T> reference, boolean setType);
+ /**
+ * Gets the given OData property as DOM element.
+ *
+ * @param prop OData property.
+ * @return <tt>Element</tt> object.
+ */
+// Element toDOMElement(ODataProperty prop);
+// ODataLinkCollection getLinkCollection(LinkCollection linkCollection);
+ /**
+ * Gets <tt>ODataEntitySet</tt> from the given feed resource.
+ *
+ * @param resource feed resource.
+ * @return <tt>ODataEntitySet</tt> object.
+ */
+// ODataEntitySet getODataEntitySet(Feed resource);
+ /**
+ * Gets <tt>ODataEntitySet</tt> from the given feed resource.
+ *
+ * @param resource feed resource.
+ * @param defaultBaseURI default base URI.
+ * @return <tt>ODataEntitySet</tt> object.
+ */
+// ODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI);
+ /**
+ * Gets <tt>ODataEntity</tt> from the given entry resource.
+ *
+ * @param resource entry resource.
+ * @return <tt>ODataEntity</tt> object.
+ */
+// ODataEntity getODataEntity(Entry resource);
+ /**
+ * Gets <tt>ODataEntity</tt> from the given entry resource.
+ *
+ * @param resource entry resource.
+ * @param defaultBaseURI default base URI.
+ * @return <tt>ODataEntity</tt> object.
+ */
+// ODataEntity getODataEntity(Entry resource, URI defaultBaseURI);
+ /**
+ * Gets a <tt>LinkResource</tt> from the given OData link.
+ *
+ * @param <T> link resource type.
+ * @param link OData link.
+ * @param reference reference class.
+ * @return <tt>LinkResource</tt> object.
+ */
+// @SuppressWarnings("unchecked")
+// <T extends Link> T getLinkResource(ODataLink link, Class<T> reference);
+
+ /**
+ * Gets an <tt>ODataProperty</tt> from the given DOM element.
+ *
+ * @param property content.
+ * @return <tt>ODataProperty</tt> object.
+ */
+// ODataProperty getProperty(Element property);
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.java
index 8d6fc62..047983d 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.java
@@ -20,7 +20,9 @@ package org.apache.olingo.odata4.client.api.op;
import java.io.InputStream;
import java.io.Serializable;
+import org.apache.olingo.odata4.client.api.data.ServiceDocument;
import org.apache.olingo.odata4.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.odata4.client.api.format.ODataFormat;
import org.w3c.dom.Element;
/**
@@ -37,7 +39,8 @@ public interface ODataDeserializer extends Serializable {
* @param format OData service document format.
* @return ServiceDocumentResource object.
*/
-// ServiceDocument toServiceDocument(InputStream input, ODataFormat format);
+ ServiceDocument toServiceDocument(InputStream input, ODataFormat format);
+
/**
* Gets a feed object from the given InputStream.
*
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java
index a933919..1686c91 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java
@@ -20,6 +20,8 @@ package org.apache.olingo.odata4.client.api.op;
import java.io.InputStream;
import java.io.Serializable;
+import org.apache.olingo.odata4.client.api.domain.ODataServiceDocument;
+import org.apache.olingo.odata4.client.api.format.ODataFormat;
import org.apache.olingo.odata4.commons.api.edm.Edm;
/**
@@ -46,7 +48,8 @@ public interface ODataReader extends Serializable {
* @param format de-serialize as XML or JSON
* @return List of URIs.
*/
- //ODataServiceDocument readServiceDocument(InputStream input, ODataFormat format);
+ ODataServiceDocument readServiceDocument(InputStream input, ODataFormat format);
+
/**
* De-Serializes a stream into an OData entity set.
*
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/uri/SegmentType.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/uri/SegmentType.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/uri/SegmentType.java
new file mode 100644
index 0000000..a029c0d
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/uri/SegmentType.java
@@ -0,0 +1,55 @@
+/*
+ * 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.api.uri;
+
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * URI Segment types.
+ */
+public enum SegmentType {
+
+ ENTITYSET,
+ ENTITYTYPE,
+ KEY,
+ KEY_AS_SEGMENT,
+ NAVIGATION,
+ STRUCTURAL,
+ VALUE("$value"),
+ FUNCTIONIMPORT,
+ METADATA("$metadata"),
+ BATCH("$batch"),
+ LINKS("$links"),
+ COUNT("$count"),
+ SERVICEROOT;
+
+ private String value;
+
+ private SegmentType() {
+ this.value = StringUtils.EMPTY;
+ }
+
+ private SegmentType(final String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/utils/XMLUtils.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/utils/XMLUtils.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/utils/XMLUtils.java
index b717d87..e1d580a 100644
--- a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/utils/XMLUtils.java
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/utils/XMLUtils.java
@@ -23,8 +23,8 @@ import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.odata4.client.api.Constants;
-import org.apache.olingo.odata4.client.api.data.EdmSimpleType;
-import org.apache.olingo.odata4.client.api.data.geospatial.Geospatial;
+import org.apache.olingo.odata4.client.api.domain.EdmSimpleType;
+import org.apache.olingo.odata4.client.api.domain.geospatial.Geospatial;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/AbstractODataClient.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/AbstractODataClient.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/AbstractODataClient.java
index 337a40d..47adcaa 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/AbstractODataClient.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/AbstractODataClient.java
@@ -19,8 +19,8 @@
package org.apache.olingo.odata4.client.core;
import org.apache.olingo.odata4.client.api.ODataClient;
-import org.apache.olingo.odata4.client.api.data.ODataGeospatialValue;
-import org.apache.olingo.odata4.client.api.data.ODataPrimitiveValue;
+import org.apache.olingo.odata4.client.api.domain.ODataGeospatialValue;
+import org.apache.olingo.odata4.client.api.domain.ODataPrimitiveValue;
abstract class AbstractODataClient implements ODataClient {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/ODataV3Client.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/ODataV3Client.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/ODataV3Client.java
index 4555c8c..77b9617 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/ODataV3Client.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/ODataV3Client.java
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.odata4.client.core;
+import org.apache.olingo.odata4.client.core.op.impl.v3.ODataBinderImpl;
import org.apache.olingo.odata4.client.core.op.impl.v3.ODataDeserializerImpl;
import org.apache.olingo.odata4.client.core.op.impl.v3.ODataReaderImpl;
import org.apache.olingo.odata4.client.core.op.impl.v3.ODataSerializerImpl;
@@ -30,18 +31,15 @@ public class ODataV3Client extends AbstractODataClient {
private final V3Configuration configuration = new V3Configuration();
// private final V3FilterFactory filterFactory = new V3FilterFactory();
-//
private final ODataDeserializerImpl deserializer = new ODataDeserializerImpl(this);
-//
private final ODataSerializerImpl serializer = new ODataSerializerImpl(this);
private final ODataReaderImpl reader = new ODataReaderImpl(this);
// private final ODataWriterImpl writer = new ODataWriterImpl(this);
-//
-// private final ODataBinderImpl binder = new ODataBinderImpl(this);
-//
+ private final ODataBinderImpl binder = new ODataBinderImpl(this);
+
// private final ODataObjectFactoryImpl objectFactory = new ODataObjectFactoryImpl(this);
//
// private final V3RetrieveRequestFactory retrieveReqFact = new V3RetrieveRequestFactory(this);
@@ -100,12 +98,11 @@ public class ODataV3Client extends AbstractODataClient {
// public ODataWriterImpl getWriter() {
// return writer;
// }
-//
-// @Override
-// public ODataBinderImpl getBinder() {
-// return binder;
-// }
-//
+ @Override
+ public ODataBinderImpl getBinder() {
+ return binder;
+ }
+
// @Override
// public ODataObjectFactoryImpl getObjectFactory() {
// return objectFactory;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/ODataV4Client.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/ODataV4Client.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/ODataV4Client.java
index 6fdc8b0..06195d8 100644
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/ODataV4Client.java
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/ODataV4Client.java
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.odata4.client.core;
+import org.apache.olingo.odata4.client.core.op.impl.v4.ODataBinderImpl;
import org.apache.olingo.odata4.client.core.op.impl.v4.ODataDeserializerImpl;
import org.apache.olingo.odata4.client.core.op.impl.v4.ODataReaderImpl;
import org.apache.olingo.odata4.client.core.op.impl.v4.ODataSerializerImpl;
@@ -30,18 +31,15 @@ public class ODataV4Client extends AbstractODataClient {
private final V4Configuration configuration = new V4Configuration();
// private final V4FilterFactory filterFactory = new V4FilterFactory();
-//
private final ODataDeserializerImpl deserializer = new ODataDeserializerImpl(this);
-//
private final ODataSerializerImpl serializer = new ODataSerializerImpl(this);
private final ODataReaderImpl reader = new ODataReaderImpl(this);
// private final ODataWriterImpl writer = new ODataWriterImpl(this);
-//
-// private final ODataBinderImpl binder = new ODataBinderImpl(this);
-//
+ private final ODataBinderImpl binder = new ODataBinderImpl(this);
+
// private final ODataObjectFactoryImpl objectFactory = new ODataObjectFactoryImpl(this);
//
// private final V4RetrieveRequestFactory retrieveReqFact = new V4RetrieveRequestFactory(this);
@@ -99,12 +97,11 @@ public class ODataV4Client extends AbstractODataClient {
// public ODataWriterImpl getWriter() {
// return writer;
// }
-//
-// @Override
-// public ODataBinderImpl getBinder() {
-// return binder;
-// }
-//
+ @Override
+ public ODataBinderImpl getBinder() {
+ return binder;
+ }
+
// @Override
// public ODataObjectFactoryImpl getObjectFactory() {
// return objectFactory;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/AbstractServiceDocument.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/AbstractServiceDocument.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/AbstractServiceDocument.java
new file mode 100644
index 0000000..c841b40
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/AbstractServiceDocument.java
@@ -0,0 +1,145 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+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.api.data.ServiceDocument;
+import org.apache.olingo.odata4.client.api.data.ServiceDocumentItem;
+
+public abstract class AbstractServiceDocument implements ServiceDocument {
+
+ private String title;
+
+ private final List<ServiceDocumentItem> entitySets = new ArrayList<ServiceDocumentItem>();
+
+ @Override
+ public String getMetadataContext() {
+ return null;
+ }
+
+ @Override
+ public String getMetadataETag() {
+ return null;
+ }
+
+ @Override
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(final String title) {
+ this.title = title;
+ }
+
+ protected ServiceDocumentItem getByName(final List<ServiceDocumentItem> elements, final String name) {
+ ServiceDocumentItem result = null;
+ for (ServiceDocumentItem element : elements) {
+ if (name.equals(element.getName())) {
+ result = element;
+ }
+ }
+ return result;
+ }
+
+ protected ServiceDocumentItem getByTitle(final List<ServiceDocumentItem> elements, final String title) {
+ ServiceDocumentItem result = null;
+ for (ServiceDocumentItem element : elements) {
+ if (title.equals(element.getTitle())) {
+ result = element;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public List<ServiceDocumentItem> getEntitySets() {
+ return entitySets;
+ }
+
+ @Override
+ public ServiceDocumentItem getEntitySetByName(final String name) {
+ return getByName(getEntitySets(), name);
+ }
+
+ @Override
+ public ServiceDocumentItem getEntitySetByTitle(final String title) {
+ return getByTitle(getEntitySets(), title);
+ }
+
+ @Override
+ public List<ServiceDocumentItem> getFunctionImports() {
+ return Collections.<ServiceDocumentItem>emptyList();
+ }
+
+ @Override
+ public ServiceDocumentItem getFunctionImportByName(final String name) {
+ return getByName(getFunctionImports(), name);
+ }
+
+ @Override
+ public ServiceDocumentItem getFunctionImportByTitle(final String title) {
+ return getByTitle(getFunctionImports(), title);
+ }
+
+ @Override
+ public List<ServiceDocumentItem> getSingletons() {
+ return Collections.<ServiceDocumentItem>emptyList();
+ }
+
+ @Override
+ public ServiceDocumentItem getSingletonByName(final String name) {
+ return getByName(getSingletons(), name);
+ }
+
+ @Override
+ public ServiceDocumentItem getSingletonByTitle(final String title) {
+ return getByTitle(getSingletons(), title);
+ }
+
+ @Override
+ public List<ServiceDocumentItem> getRelatedServiceDocuments() {
+ return Collections.<ServiceDocumentItem>emptyList();
+ }
+
+ @Override
+ public ServiceDocumentItem getRelatedServiceDocumentByTitle(final String title) {
+ return getByTitle(getRelatedServiceDocuments(), title);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/JSONServiceDocumentDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/JSONServiceDocumentDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/JSONServiceDocumentDeserializer.java
new file mode 100644
index 0000000..33b4bdf
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/JSONServiceDocumentDeserializer.java
@@ -0,0 +1,82 @@
+/*
+ * 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 com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.util.Iterator;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.odata4.client.api.ODataConstants;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+public class JSONServiceDocumentDeserializer extends ODataJacksonDeserializer<AbstractServiceDocument> {
+
+ @Override
+ protected AbstractServiceDocument doDeserialize(final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final ObjectNode tree = (ObjectNode) parser.getCodec().readTree(parser);
+
+ final AbstractServiceDocument serviceDocument = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.data.v3.JSONServiceDocumentImpl()
+ : new org.apache.olingo.odata4.client.core.data.v4.JSONServiceDocumentImpl();
+
+ if (tree.hasNonNull(ODataConstants.JSON_METADATA)
+ && serviceDocument instanceof org.apache.olingo.odata4.client.core.data.v3.JSONServiceDocumentImpl) {
+
+ ((org.apache.olingo.odata4.client.core.data.v3.JSONServiceDocumentImpl) serviceDocument).
+ setMetadata(tree.get(ODataConstants.JSON_METADATA).textValue());
+ }
+ if (tree.hasNonNull(ODataConstants.JSON_CONTEXT)
+ && serviceDocument instanceof org.apache.olingo.odata4.client.core.data.v4.JSONServiceDocumentImpl) {
+
+ ((org.apache.olingo.odata4.client.core.data.v4.JSONServiceDocumentImpl) serviceDocument).
+ setMetadataContext(tree.get(ODataConstants.JSON_CONTEXT).textValue());
+ }
+
+ for (final Iterator<JsonNode> itor = tree.get(ODataConstants.JSON_VALUE).elements(); itor.hasNext();) {
+ final JsonNode node = itor.next();
+
+ final ServiceDocumentItemImpl item = new ServiceDocumentItemImpl();
+ item.setName(node.get("name").asText());
+ if (node.has("title")) {
+ item.setTitle(node.get("title").asText());
+ }
+ item.setHref(node.get("url").asText());
+
+ final String kind = node.has("kind") ? node.get("kind").asText() : null;
+ if (StringUtils.isBlank(kind) || "EntitySet".equals(kind)) {
+ serviceDocument.getEntitySets().add(item);
+ } else if ("Singleton".equals(kind)) {
+ serviceDocument.getSingletons().add(item);
+ } else if ("FunctionImport".equals(kind)) {
+ serviceDocument.getFunctionImports().add(item);
+ } else if ("ServiceDocument".equals(kind)) {
+ serviceDocument.getRelatedServiceDocuments().add(item);
+ }
+ }
+
+ return serviceDocument;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataJacksonDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataJacksonDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataJacksonDeserializer.java
new file mode 100644
index 0000000..c5864f2
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataJacksonDeserializer.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;
+
+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 java.io.IOException;
+import org.apache.olingo.odata4.client.api.ODataClient;
+
+abstract class ODataJacksonDeserializer<T> extends JsonDeserializer<T> {
+
+ protected ODataClient client;
+
+ 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/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataJacksonSerializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataJacksonSerializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataJacksonSerializer.java
new file mode 100644
index 0000000..4e44277
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataJacksonSerializer.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;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import java.io.IOException;
+import org.apache.olingo.odata4.client.api.ODataClient;
+
+abstract class ODataJacksonSerializer<T> extends JsonSerializer<T> {
+
+ protected ODataClient client;
+
+ protected abstract void doSerialize(T value, JsonGenerator jgen, SerializerProvider provider)
+ throws IOException, JsonProcessingException;
+
+ @Override
+ public void serialize(final T value, final JsonGenerator jgen, final SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+
+ client = (ODataClient) provider.getAttribute(ODataClient.class);
+ doSerialize(value, jgen, provider);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ServiceDocumentItemImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ServiceDocumentItemImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ServiceDocumentItemImpl.java
new file mode 100644
index 0000000..3d4610a
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ServiceDocumentItemImpl.java
@@ -0,0 +1,78 @@
+/*
+ * 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 com.fasterxml.jackson.annotation.JsonProperty;
+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.api.data.ServiceDocumentItem;
+
+public class ServiceDocumentItemImpl implements ServiceDocumentItem {
+
+ private String name;
+
+ private String title;
+
+ @JsonProperty("url")
+ private String href;
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(final String title) {
+ this.title = title;
+ }
+
+ @Override
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(final String href) {
+ this.href = href;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return EqualsBuilder.reflectionEquals(this, obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return HashCodeBuilder.reflectionHashCode(this);
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/XMLServiceDocumentDeserializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/XMLServiceDocumentDeserializer.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/XMLServiceDocumentDeserializer.java
new file mode 100644
index 0000000..749a420
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/XMLServiceDocumentDeserializer.java
@@ -0,0 +1,118 @@
+/*
+ * 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 com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
+import java.io.IOException;
+import java.net.URI;
+import org.apache.olingo.odata4.client.api.data.ServiceDocument;
+import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
+
+public class XMLServiceDocumentDeserializer extends ODataJacksonDeserializer<ServiceDocument> {
+
+ private String getTitle(final JsonParser jp) throws IOException {
+ String title = jp.nextTextValue();
+ if (title == null) {
+ jp.nextToken();
+ jp.nextToken();
+ jp.nextToken();
+ title = jp.nextTextValue();
+ }
+ return title;
+ }
+
+ private ServiceDocumentItemImpl deserializeElement(final JsonParser jp, final String elementName)
+ throws IOException {
+
+ final ServiceDocumentItemImpl element = new ServiceDocumentItemImpl();
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT
+ || !elementName.equals(((FromXmlParser) jp).getStaxReader().getLocalName()); jp.nextToken()) {
+
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("href".equals(jp.getCurrentName())) {
+ element.setHref(jp.nextTextValue());
+ } else if ("name".equals(jp.getCurrentName())) {
+ element.setName(jp.nextTextValue());
+ } else if ("title".equals(jp.getCurrentName())) {
+ element.setTitle(getTitle(jp));
+ }
+ }
+ }
+
+ return element;
+ }
+
+ @Override
+ protected ServiceDocument doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+
+ final AbstractServiceDocument sdoc = ODataServiceVersion.V30 == client.getServiceVersion()
+ ? new org.apache.olingo.odata4.client.core.data.v3.XMLServiceDocumentImpl()
+ : new org.apache.olingo.odata4.client.core.data.v4.XMLServiceDocumentImpl();
+
+ for (; jp.getCurrentToken() != JsonToken.END_OBJECT
+ || !"service".equals(((FromXmlParser) jp).getStaxReader().getLocalName()); jp.nextToken()) {
+
+ final JsonToken token = jp.getCurrentToken();
+ if (token == JsonToken.FIELD_NAME) {
+ if ("base".equals(jp.getCurrentName())) {
+ if (sdoc instanceof org.apache.olingo.odata4.client.core.data.v3.XMLServiceDocumentImpl) {
+ ((org.apache.olingo.odata4.client.core.data.v3.XMLServiceDocumentImpl) sdoc).
+ setBaseURI(URI.create(jp.nextTextValue()));
+ } else {
+ ((org.apache.olingo.odata4.client.core.data.v4.XMLServiceDocumentImpl) sdoc).
+ setBaseURI(URI.create(jp.nextTextValue()));
+ }
+ } else if ("context".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.odata4.client.core.data.v4.XMLServiceDocumentImpl) sdoc).
+ setMetadataContext(jp.nextTextValue());
+ } else if ("metadata-etag".equals(jp.getCurrentName())) {
+ ((org.apache.olingo.odata4.client.core.data.v4.XMLServiceDocumentImpl) sdoc).
+ setMetadataETag(jp.nextTextValue());
+ } else if ("workspace".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ jp.nextToken();
+ if ("title".equals(jp.getCurrentName())) {
+ sdoc.setTitle(getTitle(jp));
+ }
+ } else if ("collection".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ sdoc.getEntitySets().add(deserializeElement(jp, "collection"));
+ } else if ("function-import".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ sdoc.getFunctionImports().add(deserializeElement(jp, "function-import"));
+ } else if ("singleton".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ sdoc.getSingletons().add(deserializeElement(jp, "singleton"));
+ } else if ("service-document".equals(jp.getCurrentName())) {
+ jp.nextToken();
+ sdoc.getRelatedServiceDocuments().add(deserializeElement(jp, "service-document"));
+ }
+ }
+ }
+
+ return sdoc;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v3/JSONServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v3/JSONServiceDocumentImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v3/JSONServiceDocumentImpl.java
new file mode 100644
index 0000000..28db339
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v3/JSONServiceDocumentImpl.java
@@ -0,0 +1,65 @@
+/*
+ * 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.v3;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import java.net.URI;
+import org.apache.olingo.odata4.client.api.uri.SegmentType;
+import org.apache.olingo.odata4.client.core.data.AbstractServiceDocument;
+import org.apache.olingo.odata4.client.core.data.JSONServiceDocumentDeserializer;
+
+/**
+ * Service document, represented via JSON.
+ */
+@JsonDeserialize(using = JSONServiceDocumentDeserializer.class)
+public class JSONServiceDocumentImpl extends AbstractServiceDocument {
+
+ private static final long serialVersionUID = 4195734928526398830L;
+
+ private String metadata;
+
+ @Override
+ public URI getBaseURI() {
+ URI baseURI = null;
+ if (metadata != null) {
+ final String metadataURI = getMetadata();
+ baseURI = URI.create(metadataURI.substring(0, metadataURI.indexOf(SegmentType.METADATA.getValue())));
+ }
+
+ return baseURI;
+ }
+
+ /**
+ * Gets the metadata URI.
+ *
+ * @return the metadata URI
+ */
+ public String getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * Sets the metadata URI.
+ *
+ * @param metadata metadata URI.
+ */
+ public void setMetadata(final String metadata) {
+ this.metadata = metadata;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v3/XMLServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v3/XMLServiceDocumentImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v3/XMLServiceDocumentImpl.java
new file mode 100644
index 0000000..caed09c
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v3/XMLServiceDocumentImpl.java
@@ -0,0 +1,46 @@
+/*
+ * 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.v3;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import java.net.URI;
+import org.apache.olingo.odata4.client.api.data.ServiceDocument;
+import org.apache.olingo.odata4.client.core.data.AbstractServiceDocument;
+import org.apache.olingo.odata4.client.core.data.XMLServiceDocumentDeserializer;
+
+@JsonDeserialize(using = XMLServiceDocumentDeserializer.class)
+public class XMLServiceDocumentImpl extends AbstractServiceDocument implements ServiceDocument {
+
+ private URI baseURI;
+
+ @Override
+ public URI getBaseURI() {
+ return this.baseURI;
+ }
+
+ /**
+ * Sets base URI.
+ *
+ * @param baseURI base URI.
+ */
+ public void setBaseURI(final URI baseURI) {
+ this.baseURI = baseURI;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/AbstractServiceDocument.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/AbstractServiceDocument.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/AbstractServiceDocument.java
new file mode 100644
index 0000000..152c058
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/AbstractServiceDocument.java
@@ -0,0 +1,88 @@
+/*
+ * 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.v4;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.odata4.client.api.data.ServiceDocumentItem;
+
+public abstract class AbstractServiceDocument
+ extends org.apache.olingo.odata4.client.core.data.AbstractServiceDocument {
+
+ private URI baseURI;
+
+ private String metadataContext;
+
+ private String metadataETag;
+
+ private List<ServiceDocumentItem> functionImports = new ArrayList<ServiceDocumentItem>();
+
+ private List<ServiceDocumentItem> singletons = new ArrayList<ServiceDocumentItem>();
+
+ private List<ServiceDocumentItem> relatedServiceDocuments = new ArrayList<ServiceDocumentItem>();
+
+ @Override
+ public URI getBaseURI() {
+ return this.baseURI;
+ }
+
+ /**
+ * Sets base URI.
+ *
+ * @param baseURI base URI.
+ */
+ public void setBaseURI(final URI baseURI) {
+ this.baseURI = baseURI;
+ }
+
+ @Override
+ public String getMetadataContext() {
+ return metadataContext;
+ }
+
+ public void setMetadataContext(final String metadataContext) {
+ this.metadataContext = metadataContext;
+ }
+
+ @Override
+ public String getMetadataETag() {
+ return metadataETag;
+ }
+
+ public void setMetadataETag(final String metadataETag) {
+ this.metadataETag = metadataETag;
+ }
+
+ @Override
+ public List<ServiceDocumentItem> getFunctionImports() {
+ return functionImports;
+ }
+
+ @Override
+ public List<ServiceDocumentItem> getSingletons() {
+ return singletons;
+ }
+
+ @Override
+ public List<ServiceDocumentItem> getRelatedServiceDocuments() {
+ return relatedServiceDocuments;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/JSONServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/JSONServiceDocumentImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/JSONServiceDocumentImpl.java
new file mode 100644
index 0000000..82dfb9c
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/JSONServiceDocumentImpl.java
@@ -0,0 +1,41 @@
+/*
+ * 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.v4;
+
+import org.apache.olingo.odata4.client.core.data.JSONServiceDocumentDeserializer;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import java.net.URI;
+import org.apache.olingo.odata4.client.api.data.ServiceDocument;
+import org.apache.olingo.odata4.client.api.uri.SegmentType;
+
+@JsonDeserialize(using = JSONServiceDocumentDeserializer.class)
+public class JSONServiceDocumentImpl extends AbstractServiceDocument implements ServiceDocument {
+
+ @Override
+ public URI getBaseURI() {
+ URI baseURI = null;
+ if (getMetadataContext() != null) {
+ final String metadataURI = getMetadataContext();
+ baseURI = URI.create(metadataURI.substring(0, metadataURI.indexOf(SegmentType.METADATA.getValue())));
+ }
+
+ return baseURI;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e6248155/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/XMLServiceDocumentImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/XMLServiceDocumentImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/XMLServiceDocumentImpl.java
new file mode 100644
index 0000000..7142df2
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/v4/XMLServiceDocumentImpl.java
@@ -0,0 +1,28 @@
+/*
+ * 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.v4;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import org.apache.olingo.odata4.client.api.data.ServiceDocument;
+import org.apache.olingo.odata4.client.core.data.XMLServiceDocumentDeserializer;
+
+@JsonDeserialize(using = XMLServiceDocumentDeserializer.class)
+public class XMLServiceDocumentImpl extends AbstractServiceDocument implements ServiceDocument {
+
+}