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 10:09:06 UTC
[17/57] [abbrv] [OLINGO-169] Introducing V3 and V4 metadata parsing
tests - still using dummy Edm interfaces
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/Geospatial.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/Geospatial.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/Geospatial.java
new file mode 100644
index 0000000..858cf5e
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/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.api.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.api.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/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/GeospatialCollection.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/GeospatialCollection.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/GeospatialCollection.java
new file mode 100644
index 0000000..509c6e1
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/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.api.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.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/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/LineString.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/LineString.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/LineString.java
new file mode 100644
index 0000000..de8b9f1
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/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.api.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.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/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/MultiLineString.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/MultiLineString.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/MultiLineString.java
new file mode 100644
index 0000000..426f108
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/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.api.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.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/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/MultiPoint.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/MultiPoint.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/MultiPoint.java
new file mode 100644
index 0000000..6488598
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/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.api.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.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/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/MultiPolygon.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/MultiPolygon.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/MultiPolygon.java
new file mode 100644
index 0000000..8b7137d
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/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.api.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.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/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/Point.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/Point.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/Point.java
new file mode 100644
index 0000000..8e96d57
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/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.api.data.geospatial;
+
+import org.apache.olingo.odata4.client.api.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/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/Polygon.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/Polygon.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/data/geospatial/Polygon.java
new file mode 100644
index 0000000..a6166ed
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/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.api.data.geospatial;
+
+import java.util.List;
+import org.apache.olingo.odata4.client.api.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/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmType.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmType.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmType.java
new file mode 100644
index 0000000..5a480d7
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmType.java
@@ -0,0 +1,108 @@
+/*
+ * 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.edm;
+
+import org.apache.olingo.odata4.client.api.data.EdmSimpleType;
+
+public interface EdmType {
+
+ /**
+ * Checks if is a collection.
+ *
+ * @return 'TRUE' if is a collection; 'FALSE' otherwise.
+ */
+ boolean isCollection();
+
+ /**
+ * Checks if is a simple type.
+ *
+ * @return 'TRUE' if is a simple type; 'FALSE' otherwise.
+ */
+ boolean isSimpleType();
+
+ /**
+ * Gets type as a simple type.
+ *
+ * @return simple type. An <tt>EdmTypeNotFoundException</tt> will be raised if it is not a simple type.
+ */
+ EdmSimpleType getSimpleType();
+
+ /**
+ * Checks if is an enum type.
+ *
+ * @return 'TRUE' if is an enum type; 'FALSE' otherwise.
+ */
+ boolean isEnumType();
+
+ /**
+ * Gets type as enum type.
+ *
+ * @return enum type. An <tt>EdmTypeNotFoundException</tt> will be raised if it is not an enum type.
+ */
+ EnumType getEnumType();
+
+ /**
+ * Checks if is a complex type.
+ *
+ * @return 'TRUE' if is a complex type; 'FALSE' otherwise.
+ */
+ boolean isComplexType();
+
+ /**
+ * Gets type as complex type.
+ *
+ * @return complex type. An <tt>EdmTypeNotFoundException</tt> will be raised if it is not a complex type.
+ */
+ ComplexType getComplexType();
+
+ /**
+ * Checks if is an entity type.
+ *
+ * @return 'TRUE' if is an entity type; 'FALSE' otherwise.
+ */
+ boolean isEntityType();
+
+ /**
+ * Gets type as entity type.
+ *
+ * @return entity type. An <tt>EdmTypeNotFoundException</tt> will be raised if it is not an entity type.
+ */
+ EntityType getEntityType();
+
+ /**
+ * Gets base type.
+ *
+ * @return base type.
+ */
+ String getBaseType();
+
+ /**
+ * Gets type expression.
+ *
+ * @return type expression.
+ */
+ String getTypeExpression();
+
+ /**
+ * Gets namespace or alias retrieved from the provided type expression.
+ *
+ * @return namespace or alias.
+ */
+ String getNamespaceOrAlias();
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmTypeNotFoundException.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmTypeNotFoundException.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmTypeNotFoundException.java
new file mode 100644
index 0000000..6928f98
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/edm/EdmTypeNotFoundException.java
@@ -0,0 +1,37 @@
+/*
+ * 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.edm;
+
+/**
+ * This exception indicates that a certain type is not found.
+ */
+public class EdmTypeNotFoundException extends RuntimeException {
+
+ private static final long serialVersionUID = 1685118875699966611L;
+
+ /**
+ * Constructor.
+ *
+ * @param type type in object.
+ * @param typeExpression type expression.
+ */
+ public EdmTypeNotFoundException(final Class<?> type, final String typeExpression) {
+ super("No " + type.getSimpleName() + " found in " + typeExpression);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/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
new file mode 100644
index 0000000..73b3b7e
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataDeserializer.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.api.op;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import org.apache.olingo.odata4.client.api.edm.Edmx;
+import org.w3c.dom.Element;
+
+/**
+ * Utility class for serialization.
+ */
+public interface ODataDeserializer extends Serializable {
+
+ Edmx toMetadata(InputStream input);
+
+ /**
+ * Gets the ServiceDocumentResource object represented by the given InputStream.
+ *
+ * @param input stream to be de-serialized.
+ * @param format OData service document format.
+ * @return ServiceDocumentResource object.
+ */
+// ServiceDocument toServiceDocument(InputStream input, ODataFormat format);
+ /**
+ * Gets a feed object from the given InputStream.
+ *
+ * @param <T> reference class type
+ * @param input stream to be de-serialized.
+ * @param reference reference class (AtomFeed.class, JSONFeed.class).
+ * @return FeedResource instance.
+ */
+// <T extends Feed> T toFeed(InputStream input, Class<T> reference);
+ /**
+ * Gets an entry object from the given InputStream.
+ *
+ * @param <T> reference class type
+ * @param input stream to be de-serialized.
+ * @param reference reference class (AtomEntry.class, JSONV3Entry.class).
+ * @return EntryResource instance.
+ */
+// <T extends Entry> T toEntry(InputStream input, Class<T> reference);
+ /**
+ * Gets a DOM representation of the given InputStream.
+ *
+ * @param input stream to be de-serialized.
+ * @param format OData format.
+ * @return DOM.
+ */
+// Element toPropertyDOM(InputStream input, ODataFormat format);
+ /**
+ * Gets a list of links from the given InputStream.
+ *
+ * @param input stream to be de-serialized.
+ * @param format OData format.
+ * @return de-serialized links.
+ */
+// LinkCollection toLinkCollection(InputStream input, ODataFormat format);
+ /**
+ * Gets the ODataError object represented by the given InputStream.
+ *
+ * @param input stream to be parsed and de-serialized.
+ * @param isXML 'TRUE' if the error is represented by XML; 'FALSE' otherwise.
+ * @return
+ */
+// ODataError toODataError(InputStream input, boolean isXML);
+ /**
+ * Parses the given input into a DOM tree.
+ *
+ * @param input stream to be parsed and de-serialized.
+ * @return DOM tree
+ */
+ Element toDOM(InputStream input);
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/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
new file mode 100644
index 0000000..b8c2dd5
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataReader.java
@@ -0,0 +1,102 @@
+/*
+ * 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.InputStream;
+import java.io.Serializable;
+import org.apache.olingo.odata4.client.api.ODataError;
+import org.apache.olingo.odata4.client.api.edm.EdmMetadata;
+
+/**
+ * OData reader.
+ * <br/>
+ * Use this class to de-serialize an OData response body.
+ * <br/>
+ * This class provides method helpers to de-serialize an entire feed, a set of entities and a single entity as well.
+ */
+public interface ODataReader extends Serializable {
+
+ /**
+ * Parses a stream into metadata representation.
+ *
+ * @param input stream to de-serialize.
+ * @return metadata representation.
+ */
+ EdmMetadata readMetadata(InputStream input);
+
+ /**
+ * Parses an OData service document.
+ *
+ * @param input stream to de-serialize.
+ * @param format de-serialize as XML or JSON
+ * @return List of URIs.
+ */
+ //ODataServiceDocument readServiceDocument(InputStream input, ODataFormat format);
+ /**
+ * De-Serializes a stream into an OData entity set.
+ *
+ * @param input stream to de-serialize.
+ * @param format de-serialize as AtomFeed or JSONFeed
+ * @return de-serialized entity set.
+ */
+ //ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
+ /**
+ * Parses a stream taking care to de-serializes the first OData entity found.
+ *
+ * @param input stream to de-serialize.
+ * @param format de-serialize as AtomEntry or JSONEntry
+ * @return entity de-serialized.
+ */
+ //ODataEntity readEntity(InputStream input, ODataPubFormat format);
+ /**
+ * Parses a stream taking care to de-serialize the first OData entity property found.
+ *
+ * @param input stream to de-serialize.
+ * @param format de-serialize as XML or JSON
+ * @return OData entity property de-serialized.
+ */
+ //ODataProperty readProperty(InputStream input, ODataFormat format);
+ /**
+ * Parses a $links request response.
+ *
+ * @param input stream to de-serialize.
+ * @param format de-serialize as XML or JSON
+ * @return List of URIs.
+ */
+ //ODataLinkCollection readLinks(InputStream input, ODataFormat format);
+ /**
+ * Parses a stream into an OData error.
+ *
+ * @param inputStream stream to de-serialize.
+ * @param isXML 'TRUE' if the error is in XML format.
+ * @return OData error.
+ */
+// ODataError readError(InputStream inputStream, boolean isXML);
+
+ /**
+ * Parses a stream into the object type specified by the given reference.
+ *
+ * @param <T> expected object type.
+ * @param src input stream.
+ * @param format format
+ * @param reference reference.
+ * @return read object.
+ */
+ //<T> T read(InputStream src, String format, Class<T> reference);
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataSerializer.java b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataSerializer.java
new file mode 100644
index 0000000..8b8d5ac
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/op/ODataSerializer.java
@@ -0,0 +1,120 @@
+/**
+ * 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.OutputStream;
+import java.io.Serializable;
+import java.io.Writer;
+import org.apache.olingo.odata4.client.api.format.ODataFormat;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Utility class for serialization.
+ */
+public interface ODataSerializer extends Serializable {
+
+ /**
+ * Writes <tt>FeedResource</tt> object onto the given stream.
+ *
+ * @param <T> feed resource type.
+ * @param obj object to be streamed.
+ * @param out output stream.
+ */
+// <T extends Feed> void feed(T obj, OutputStream out);
+
+ /**
+ * Writes <tt>FeedResource</tt> object by the given writer.
+ *
+ * @param <T> feed resource type.
+ * @param obj object to be streamed.
+ * @param writer writer.
+ */
+// <T extends Feed> void feed(T obj, Writer writer);
+
+ /**
+ * Writes <tt>EntryResource</tt> object onto the given stream.
+ *
+ * @param <T> entry resource type.
+ * @param obj object to be streamed.
+ * @param out output stream.
+ */
+// <T extends Entry> void entry(T obj, OutputStream out);
+
+ /**
+ * Writes <tt>EntryResource</tt> object by the given writer.
+ *
+ * @param <T> entry resource type.
+ * @param obj object to be streamed.
+ * @param writer writer.
+ */
+// <T extends Entry> void entry(T obj, Writer writer);
+
+ /**
+ * Writes entry content onto the given stream.
+ *
+ * @param element element to be streamed.
+ * @param format streaming format.
+ * @param out output stream.
+ */
+// void property(Element element, ODataFormat format, OutputStream out);
+
+ /**
+ * Writes entry content by the given writer.
+ *
+ * @param element element to be streamed.
+ * @param format streaming format.
+ * @param writer writer.
+ */
+// void property(Element element, ODataFormat format, Writer writer);
+
+ /**
+ * Writes OData link onto the given stream.
+ *
+ * @param link OData link to be streamed.
+ * @param format streaming format.
+ * @param out output stream.
+ */
+// void link(ODataLink link, ODataFormat format, OutputStream out);
+
+ /**
+ * Writes OData link by the given writer.
+ *
+ * @param link OData link to be streamed.
+ * @param format streaming format.
+ * @param writer writer.
+ */
+// void link(ODataLink link, ODataFormat format, Writer writer);
+
+ /**
+ * Writes DOM object onto the given stream.
+ *
+ * @param content DOM to be streamed.
+ * @param out output stream.
+ */
+ void dom(Node content, OutputStream out);
+
+ /**
+ * Writes DOM object by the given writer.
+ *
+ * @param content DOM to be streamed.
+ * @param writer writer.
+ */
+ void dom(Node content, Writer writer);
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/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
new file mode 100644
index 0000000..b717d87
--- /dev/null
+++ b/odata4-lib/odata4-client-api/src/main/java/org/apache/olingo/odata4/client/api/utils/XMLUtils.java
@@ -0,0 +1,176 @@
+/*
+ * 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.utils;
+
+import java.util.ArrayList;
+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.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * XML utilities.
+ */
+public final class XMLUtils {
+
+ /**
+ * DOM factory.
+ */
+ public static final DocumentBuilderFactory DOC_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
+
+ private XMLUtils() {
+ // Empty private constructor for static utility classes
+ }
+
+ /**
+ * Gets XML node name.
+ *
+ * @param node node.
+ * @return node name.
+ */
+ public static String getSimpleName(final Node node) {
+ return node.getLocalName() == null
+ ? node.getNodeName().substring(node.getNodeName().indexOf(':') + 1)
+ : node.getLocalName();
+ }
+
+ /**
+ * Gets the given node's children of the given type.
+ *
+ * @param node parent.
+ * @param nodetype searched child type.
+ * @return children.
+ */
+ public static List<Node> getChildNodes(final Node node, final short nodetype) {
+ final List<Node> result = new ArrayList<Node>();
+
+ final NodeList children = node.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ final Node child = children.item(i);
+ if (child.getNodeType() == nodetype) {
+ result.add(child);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Gets the given node's children with the given name.
+ *
+ * @param node parent.
+ * @param name searched child name.
+ * @return children.
+ */
+ public static List<Element> getChildElements(final Element node, final String name) {
+ final List<Element> result = new ArrayList<Element>();
+
+ if (StringUtils.isNotBlank(name)) {
+ final NodeList children = node.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ final Node child = children.item(i);
+ if ((child instanceof Element) && name.equals(child.getNodeName())) {
+ result.add((Element) child);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Checks if the given node has <tt>element</tt> children.
+ *
+ * @param node parent.
+ * @return 'TRUE' if the given node has at least one <tt>element</tt> child; 'FALSE' otherwise.
+ */
+ public static boolean hasElementsChildNode(final Node node) {
+ boolean found = false;
+
+ for (Node child : getChildNodes(node, Node.ELEMENT_NODE)) {
+ if (Constants.ELEM_ELEMENT.equals(XMLUtils.getSimpleName(child))) {
+ found = true;
+ }
+ }
+
+ return found;
+ }
+
+ /**
+ * Checks if the given node has only text children.
+ *
+ * @param node parent.
+ * @return 'TRUE' if the given node has only text children; 'FALSE' otherwise.
+ */
+ public static boolean hasOnlyTextChildNodes(final Node node) {
+ boolean result = true;
+ final NodeList children = node.getChildNodes();
+ for (int i = 0; result && i < children.getLength(); i++) {
+ final Node child = children.item(i);
+ if (child.getNodeType() != Node.TEXT_NODE) {
+ result = false;
+ }
+ }
+
+ return result;
+ }
+
+ public static EdmSimpleType simpleTypeForNode(final Geospatial.Dimension dimension, final Node node) {
+ EdmSimpleType type = null;
+
+ if (Constants.ELEM_POINT.equals(node.getNodeName())) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyPoint
+ : EdmSimpleType.GeometryPoint;
+ } else if (Constants.ELEM_MULTIPOINT.equals(node.getNodeName())) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyMultiPoint
+ : EdmSimpleType.GeometryMultiPoint;
+ } else if (Constants.ELEM_LINESTRING.equals(node.getNodeName())) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyLineString
+ : EdmSimpleType.GeometryLineString;
+ } else if (Constants.ELEM_MULTILINESTRING.equals(node.getNodeName())) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyMultiLineString
+ : EdmSimpleType.GeometryMultiLineString;
+ } else if (Constants.ELEM_POLYGON.equals(node.getNodeName())) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyPolygon
+ : EdmSimpleType.GeometryPolygon;
+ } else if (Constants.ELEM_MULTIPOLYGON.equals(node.getNodeName())) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyMultiPolygon
+ : EdmSimpleType.GeometryMultiPolygon;
+ } else if (Constants.ELEM_GEOCOLLECTION.equals(node.getNodeName())
+ || Constants.ELEM_GEOMEMBERS.equals(node.getNodeName())) {
+
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmSimpleType.GeographyCollection
+ : EdmSimpleType.GeometryCollection;
+ }
+
+ return type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/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 15a51c0..337a40d 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.core.data.ODataGeospatialValue;
-import org.apache.olingo.odata4.client.core.data.ODataPrimitiveValue;
+import org.apache.olingo.odata4.client.api.data.ODataGeospatialValue;
+import org.apache.olingo.odata4.client.api.data.ODataPrimitiveValue;
abstract class AbstractODataClient implements ODataClient {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/EdmSimpleType.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/EdmSimpleType.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/EdmSimpleType.java
deleted file mode 100644
index 08e974b..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/EdmSimpleType.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * 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.math.BigDecimal;
-import java.net.URI;
-import java.util.UUID;
-import org.apache.olingo.odata4.client.core.data.geospatial.Geospatial;
-import org.apache.olingo.odata4.client.core.data.geospatial.GeospatialCollection;
-import org.apache.olingo.odata4.client.core.data.geospatial.LineString;
-import org.apache.olingo.odata4.client.core.data.geospatial.MultiLineString;
-import org.apache.olingo.odata4.client.core.data.geospatial.MultiPoint;
-import org.apache.olingo.odata4.client.core.data.geospatial.MultiPolygon;
-import org.apache.olingo.odata4.client.core.data.geospatial.Point;
-import org.apache.olingo.odata4.client.core.data.geospatial.Polygon;
-import org.apache.olingo.odata4.commons.api.edm.constants.ODataServiceVersion;
-
-/**
- * Represent the primitive types of the Entity Data Model (EDM).
- *
- * @see http://dl.windowsazure.com/javadoc/com/microsoft/windowsazure/services/table/models/EdmType.html
- * <p>
- * For an overview of the available EDM primitive data types and names, see the <a
- * href="http://www.odata.org/developers/protocols/overview#AbstractTypeSystem">Primitive Data Types</a> section of the
- * <a href="http://www.odata.org/developers/protocols/overview">OData Protocol Overview</a>.
- * </p>
- * <p>
- * The Abstract Type System used to define the primitive types supported by OData is defined in detail in <a
- * href="http://msdn.microsoft.com/en-us/library/dd541474.aspx">[MC-CSDL] (section 2.2.1).</a>
- * </p>
- */
-public enum EdmSimpleType {
-
- /**
- * The absence of a value.
- */
- Null(Void.class),
- /**
- * An array of bytes.
- */
- Binary(byte[].class),
- /**
- * A Boolean value.
- */
- Boolean(Boolean.class),
- /**
- * Unsigned 8-bit integer value.
- */
- Byte(Integer.class),
- /**
- * A signed 8-bit integer value.
- */
- SByte(Byte.class),
- /**
- * A 64-bit value expressed as Coordinated Universal Time (UTC).
- */
- DateTime(new ODataServiceVersion[]{ODataServiceVersion.V30}, ODataTimestamp.class, "yyyy-MM-dd'T'HH:mm:ss"),
- /**
- * Date without a time-zone offset.
- */
- Date(new ODataServiceVersion[]{ODataServiceVersion.V40}, ODataTimestamp.class, "yyyy-MM-dd"),
- /**
- * Date and time as an Offset in minutes from GMT.
- */
- DateTimeOffset(ODataTimestamp.class, "yyyy-MM-dd'T'HH:mm:ss"),
- /**
- * The time of day with values ranging from 0:00:00.x to 23:59:59.y, where x and y depend upon the precision.
- */
- Time(new ODataServiceVersion[]{ODataServiceVersion.V30}, ODataDuration.class),
- /**
- * The time of day with values ranging from 0:00:00.x to 23:59:59.y, where x and y depend upon the precision.
- */
- TimeOfDay(new ODataServiceVersion[]{ODataServiceVersion.V40}, ODataDuration.class),
- /**
- * Signed duration in days, hours, minutes, and (sub)seconds.
- */
- Duration(new ODataServiceVersion[]{ODataServiceVersion.V40}, ODataDuration.class),
- /**
- * Numeric values with fixed precision and scale.
- */
- Decimal(BigDecimal.class, "#.#######################"),
- /**
- * A floating point number with 7 digits precision.
- */
- Single(Float.class, "#.#######E0"),
- /**
- * A 64-bit double-precision floating point value.
- */
- Double(Double.class, "#.#######################E0"),
- // --- Geospatial ---
- Geography(Geospatial.class),
- GeographyPoint(Point.class),
- GeographyLineString(LineString.class),
- GeographyPolygon(Polygon.class),
- GeographyMultiPoint(MultiPoint.class),
- GeographyMultiLineString(MultiLineString.class),
- GeographyMultiPolygon(MultiPolygon.class),
- GeographyCollection(GeospatialCollection.class),
- Geometry(Geospatial.class),
- GeometryPoint(Point.class),
- GeometryLineString(LineString.class),
- GeometryPolygon(Polygon.class),
- GeometryMultiPoint(MultiPoint.class),
- GeometryMultiLineString(MultiLineString.class),
- GeometryMultiPolygon(MultiPolygon.class),
- GeometryCollection(GeospatialCollection.class),
- /**
- * A 128-bit globally unique identifier.
- */
- Guid(UUID.class),
- /**
- * A 16-bit integer value.
- */
- Int16(Short.class),
- /**
- * A 32-bit integer value.
- */
- Int32(Integer.class),
- /**
- * A 64-bit integer value.
- */
- Int64(Long.class),
- /**
- * A UTF-16-encoded value. String values may be up to 64 KB in size.
- */
- String(String.class),
- /**
- * Resource stream (for media entities).
- */
- Stream(URI.class);
-
- private final Class<?> clazz;
-
- private final String pattern;
-
- private final ODataServiceVersion[] versions;
-
- /**
- * Constructor (all OData versions).
- *
- * @param clazz type.
- */
- EdmSimpleType(final Class<?> clazz) {
- this(ODataServiceVersion.values(), clazz, null);
- }
-
- /**
- * Constructor.
- *
- * @param versions supported OData versions.
- * @param clazz type.
- */
- EdmSimpleType(final ODataServiceVersion[] versions, final Class<?> clazz) {
- this(versions, clazz, null);
- }
-
- /**
- * Constructor (all OData versions).
- *
- * @param clazz type.
- * @param pattern pattern.
- */
- EdmSimpleType(final Class<?> clazz, final String pattern) {
- this(ODataServiceVersion.values(), clazz, pattern);
- }
-
- /**
- * Constructor.
- *
- * @param versions supported OData versions.
- * @param clazz type.
- * @param pattern pattern.
- */
- EdmSimpleType(final ODataServiceVersion[] versions, final Class<?> clazz, final String pattern) {
- this.clazz = clazz;
- this.pattern = pattern;
- this.versions = versions.clone();
- }
-
- /**
- * Gets pattern.
- *
- * @return pattern.
- */
- public String pattern() {
- return pattern;
- }
-
- /**
- * Gets corresponding java type.
- *
- * @return java type.
- */
- public Class<?> javaType() {
- return this.clazz;
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public String toString() {
- return namespace() + "." + name();
- }
-
- /**
- * Checks if is a geospatial type.
- *
- * @return <tt>true</tt> if is geospatial type; <tt>false</tt> otherwise.
- */
- public boolean isGeospatial() {
- return name().startsWith("Geo");
- }
-
- /**
- * Checks if the given type is a geospatial type.
- *
- * @param type type.
- * @return <tt>true</tt> if is geospatial type; <tt>false</tt> otherwise.
- */
- public static boolean isGeospatial(final String type) {
- return type != null && type.startsWith(namespace() + ".Geo");
- }
-
- /**
- * Gets <tt>EdmSimpleType</tt> from string.
- *
- * @param value string value type.
- * @return <tt>EdmSimpleType</tt> object.
- */
- public static EdmSimpleType fromValue(final String value) {
- final String noNsValue = value.substring(4);
- for (EdmSimpleType edmSimpleType : EdmSimpleType.values()) {
- if (edmSimpleType.name().equals(noNsValue)) {
- return edmSimpleType;
- }
- }
- throw new IllegalArgumentException(value);
- }
-
- /**
- * Gets <tt>EdmSimpleType</tt> from object instance.
- *
- * @param workingVersion OData version.
- * @param obj object.
- * @return <tt>EdmSimpleType</tt> object.
- */
- public static EdmSimpleType fromObject(final ODataServiceVersion workingVersion, final Object obj) {
- for (EdmSimpleType edmSimpleType : EdmSimpleType.values()) {
- if (edmSimpleType.javaType().equals(obj.getClass())) {
- return edmSimpleType == DateTimeOffset || edmSimpleType == DateTime || edmSimpleType == Date
- ? ((ODataTimestamp) obj).isOffset()
- ? DateTimeOffset : workingVersion == ODataServiceVersion.V30 ? DateTime : Date
- : edmSimpleType;
- }
- }
- throw new IllegalArgumentException(obj.getClass().getSimpleName() + " is not a simple type");
- }
-
- /**
- * Gets namespace.
- *
- * @return namespace.
- */
- public static String namespace() {
- return "Edm";
- }
-
- public ODataServiceVersion[] getSupportedVersions() {
- return versions.clone();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataCollectionValue.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataCollectionValue.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataCollectionValue.java
deleted file mode 100644
index 4635336..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataCollectionValue.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.Iterator;
-import java.util.List;
-
-/**
- * OData collection property value.
- */
-public class ODataCollectionValue extends ODataValue implements Iterable<ODataValue> {
-
- private static final long serialVersionUID = -3665659846001987187L;
-
- /**
- * Type name;
- */
- private final String typeName;
-
- /**
- * Values.
- */
- private final List<ODataValue> values = new ArrayList<ODataValue>();
-
- /**
- * Constructor.
- *
- * @param typeName type name.
- */
- public ODataCollectionValue(final String typeName) {
- this.typeName = typeName;
- }
-
- /**
- * Adds a value to the collection.
- *
- * @param value value to be added.
- */
- public void add(final ODataValue value) {
- if (value.isPrimitive() || value.isComplex()) {
- values.add(value);
- }
- }
-
- /**
- * Value iterator.
- *
- * @return value iterator.
- */
- @Override
- public Iterator<ODataValue> iterator() {
- return values.iterator();
- }
-
- /**
- * Gets value type name.
- *
- * @return value type name.
- */
- public String getTypeName() {
- return typeName;
- }
-
- /**
- * Gets collection size.
- *
- * @return collection size.
- */
- public int size() {
- return values.size();
- }
-
- /**
- * Checks if collection is empty.
- *
- * @return 'TRUE' if empty; 'FALSE' otherwise.
- */
- public boolean isEmpty() {
- return values.isEmpty();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataComplexValue.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataComplexValue.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataComplexValue.java
deleted file mode 100644
index b146e06..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataComplexValue.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * OData complex property value.
- */
-public class ODataComplexValue extends ODataValue implements Iterable<ODataProperty> {
-
- private static final long serialVersionUID = -1878555027714020431L;
-
- /**
- * Type name.
- */
- private final String typeName;
-
- /**
- * Complex type fields.
- */
- private final Map<String, ODataProperty> fields = new LinkedHashMap<String, ODataProperty>();
-
- /**
- * Constructor.
- *
- * @param typeName type name.
- */
- public ODataComplexValue(final String typeName) {
- this.typeName = typeName;
- }
-
- /**
- * Adds field to the complex type.
- *
- * @param field field to be added.
- */
- public void add(final ODataProperty field) {
- fields.put(field.getName(), field);
- }
-
- /**
- * Gets field.
- *
- * @param name name of the field to be retrieved.
- * @return requested field.
- */
- public ODataProperty get(final String name) {
- return fields.get(name);
- }
-
- /**
- * Complex property fields iterator.
- *
- * @return fields iterator.
- */
- @Override
- public Iterator<ODataProperty> iterator() {
- return fields.values().iterator();
- }
-
- /**
- * Gest value type name.
- *
- * @return value type name.
- */
- public String getTypeName() {
- return typeName;
- }
-
- /**
- * Gets number of fields.
- *
- * @return number of fields.
- */
- public int size() {
- return fields.size();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataDuration.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataDuration.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataDuration.java
deleted file mode 100644
index 1724f75..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataDuration.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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 javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.DatatypeFactory;
-import javax.xml.datatype.Duration;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-
-/**
- * Helper class for handling time (as duration) primitive values.
- *
- * @see com.msopentech.odatajclient.engine.data.metadata.edm.EdmSimpleType#TIME
- * @see Duration
- */
-public final class ODataDuration implements Serializable {
-
- private static final long serialVersionUID = 778404231943967899L;
-
- private final Duration duration;
-
- public ODataDuration(final String input) {
- try {
- final DatatypeFactory dtFactory = DatatypeFactory.newInstance();
- this.duration = dtFactory.newDuration(input);
- } catch (DatatypeConfigurationException e) {
- throw new IllegalArgumentException("Could not parse '" + input + "' as Duration", e);
- }
- }
-
- public ODataDuration(final Duration duration) {
- this.duration = duration;
- }
-
- public Duration getDuration() {
- return duration;
- }
-
- /**
- * {@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 this.duration.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataGeospatialValue.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataGeospatialValue.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataGeospatialValue.java
deleted file mode 100644
index 40a664e..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataGeospatialValue.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/**
- * 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.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
-import org.apache.olingo.odata4.client.api.Constants;
-import org.apache.olingo.odata4.client.api.ODataClient;
-import org.apache.olingo.odata4.client.core.data.EdmSimpleType;
-import org.apache.olingo.odata4.client.core.data.geospatial.Geospatial;
-import org.apache.olingo.odata4.client.core.data.geospatial.GeospatialCollection;
-import org.apache.olingo.odata4.client.core.data.geospatial.LineString;
-import org.apache.olingo.odata4.client.core.data.geospatial.MultiLineString;
-import org.apache.olingo.odata4.client.core.data.geospatial.MultiPoint;
-import org.apache.olingo.odata4.client.core.data.geospatial.MultiPolygon;
-import org.apache.olingo.odata4.client.core.data.geospatial.Point;
-import org.apache.olingo.odata4.client.core.data.geospatial.Polygon;
-import org.apache.olingo.odata4.client.core.utils.XMLUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class ODataGeospatialValue extends ODataPrimitiveValue {
-
- private static final long serialVersionUID = -3984105137562291082L;
-
- /**
- * Geospatial value builder.
- */
- public static class Builder extends AbstractBuilder {
-
- private final ODataGeospatialValue ogv;
-
- /**
- * Constructor.
- */
- public Builder(final ODataClient client) {
- super(client);
- this.ogv = new ODataGeospatialValue(client);
- }
-
- /**
- * Sets the given value provided as a DOM tree.
- *
- * @param tree value.
- * @return the current builder.
- */
- public Builder setTree(final Element tree) {
- this.ogv.tree = tree;
- return this;
- }
-
- /**
- * Sets the actual object value.
- *
- * @param value value.
- * @return the current builder.
- */
- public <T extends Geospatial> Builder setValue(final T value) {
- this.ogv.value = value;
- return this;
- }
-
- /**
- * Sets actual value type.
- *
- * @param type type.
- * @return the current builder.
- */
- public Builder setType(final EdmSimpleType type) {
- isSupported(type);
-
- if (!type.isGeospatial()) {
- throw new IllegalArgumentException(
- "Use " + ODataPrimitiveValue.class.getSimpleName() + " for non-geospatial types");
- }
-
- if (type == EdmSimpleType.Geography || type == EdmSimpleType.Geometry) {
- throw new IllegalArgumentException(
- type + "is not an instantiable type. "
- + "An entity can declare a property to be of type Geometry. "
- + "An instance of an entity MUST NOT have a value of type Geometry. "
- + "Each value MUST be of some subtype.");
- }
- this.ogv.type = type;
- return this;
- }
-
- /**
- * Builds the geospatial value.
- *
- * @return <tt>ODataGeospatialValue</tt> object.
- */
- public ODataGeospatialValue build() {
- if (this.ogv.tree == null && this.ogv.value == null) {
- throw new IllegalArgumentException("Must provide either tree or value");
- }
- if (this.ogv.tree != null && this.ogv.value != null) {
- throw new IllegalArgumentException("Cannot provide both tree and value");
- }
-
- if (this.ogv.type == null) {
- throw new IllegalArgumentException("Must provide geospatial type");
- }
-
- if (this.ogv.tree != null) {
- this.ogv.value = this.ogv.parseTree(this.ogv.tree, this.ogv.type);
- }
- if (this.ogv.value != null) {
- this.ogv.tree = this.ogv.parseGeospatial((Geospatial) this.ogv.value);
- }
-
- return this.ogv;
- }
- }
-
- /**
- * DOM tree.
- */
- private Element tree;
-
- /**
- * Protected constructor, need to use the builder to instantiate this class.
- *
- * @see Builder
- */
- protected ODataGeospatialValue(final ODataClient client) {
- super(client);
- }
-
- private Geospatial.Dimension getDimension() {
- Geospatial.Dimension dimension;
-
- switch (this.type) {
- case Geography:
- case GeographyCollection:
- case GeographyLineString:
- case GeographyMultiLineString:
- case GeographyPoint:
- case GeographyMultiPoint:
- case GeographyPolygon:
- case GeographyMultiPolygon:
- dimension = Geospatial.Dimension.GEOGRAPHY;
- break;
-
- default:
- dimension = Geospatial.Dimension.GEOMETRY;
- }
-
- return dimension;
- }
-
- private List<Point> parsePoints(final NodeList posList) {
- final List<Point> result = new ArrayList<Point>();
- for (int i = 0; i < posList.getLength(); i++) {
- final String[] pointInfo = posList.item(i).getTextContent().split(" ");
- final Point point = new Point(getDimension());
- point.setX(Double.valueOf(pointInfo[0]));
- point.setY(Double.valueOf(pointInfo[1]));
-
- result.add(point);
- }
- return result;
- }
-
- private LineString parseLineString(final Element element) {
- return new LineString(getDimension(),
- parsePoints(element.getElementsByTagName(Constants.ELEM_POS)));
- }
-
- private Polygon parsePolygon(final Element element) {
- List<Point> extPoints = null;
- final Element exterior =
- (Element) element.getElementsByTagName(Constants.ELEM_POLYGON_EXTERIOR).item(0);
- if (exterior != null) {
- extPoints = parsePoints(
- ((Element) exterior.getElementsByTagName(Constants.ELEM_POLYGON_LINEARRING).item(0)).
- getElementsByTagName(Constants.ELEM_POS));
- }
- List<Point> intPoints = null;
- final Element interior =
- (Element) element.getElementsByTagName(Constants.ELEM_POLYGON_INTERIOR).item(0);
- if (interior != null) {
- intPoints = parsePoints(
- ((Element) interior.getElementsByTagName(Constants.ELEM_POLYGON_LINEARRING).item(0)).
- getElementsByTagName(Constants.ELEM_POS));
- }
-
- return new Polygon(getDimension(), intPoints, extPoints);
- }
-
- /**
- * Parses given tree as geospatial value.
- */
- private Geospatial parseTree(final Element tree, final EdmSimpleType type) {
- Geospatial value;
-
- switch (type) {
- case GeographyPoint:
- case GeometryPoint:
- value = parsePoints(tree.getElementsByTagName(Constants.ELEM_POS)).get(0);
- break;
-
- case GeographyMultiPoint:
- case GeometryMultiPoint:
- final Element pMembs =
- (Element) tree.getElementsByTagName(Constants.ELEM_POINTMEMBERS).item(0);
- final List<Point> points = pMembs == null
- ? Collections.<Point>emptyList()
- : parsePoints(pMembs.getElementsByTagName(Constants.ELEM_POS));
- value = new MultiPoint(getDimension(), points);
- break;
-
- case GeographyLineString:
- case GeometryLineString:
- value = parseLineString(tree);
- break;
-
- case GeographyMultiLineString:
- case GeometryMultiLineString:
- final Element mlMembs =
- (Element) tree.getElementsByTagName(Constants.ELEM_LINESTRINGMEMBERS).item(0);
- final List<LineString> lineStrings;
- if (mlMembs == null) {
- lineStrings = Collections.<LineString>emptyList();
- } else {
- lineStrings = new ArrayList<LineString>();
- final NodeList lineStringNodes = mlMembs.getElementsByTagName(Constants.ELEM_LINESTRING);
- for (int i = 0; i < lineStringNodes.getLength(); i++) {
- lineStrings.add(parseLineString((Element) lineStringNodes.item(i)));
- }
- }
- value = new MultiLineString(getDimension(), lineStrings);
- break;
-
- case GeographyPolygon:
- case GeometryPolygon:
- value = parsePolygon(tree);
- break;
-
- case GeographyMultiPolygon:
- case GeometryMultiPolygon:
- final Element mpMembs =
- (Element) tree.getElementsByTagName(Constants.ELEM_SURFACEMEMBERS).item(0);
- final List<Polygon> polygons;
- if (mpMembs == null) {
- polygons = Collections.<Polygon>emptyList();
- } else {
- polygons = new ArrayList<Polygon>();
- final NodeList polygonNodes = mpMembs.getElementsByTagName(Constants.ELEM_POLYGON);
- for (int i = 0; i < polygonNodes.getLength(); i++) {
- polygons.add(parsePolygon((Element) polygonNodes.item(i)));
- }
- }
- value = new MultiPolygon(getDimension(), polygons);
- break;
-
- case GeographyCollection:
- case GeometryCollection:
- final Element cMembs =
- (Element) tree.getElementsByTagName(Constants.ELEM_GEOMEMBERS).item(0);
- final List<Geospatial> geospatials;
- if (cMembs == null) {
- geospatials = Collections.<Geospatial>emptyList();
- } else {
- geospatials = new ArrayList<Geospatial>();
- for (Node geom : XMLUtils.getChildNodes(cMembs, Node.ELEMENT_NODE)) {
- geospatials.add(
- parseTree((Element) geom, XMLUtils.simpleTypeForNode(getDimension(), geom)));
- }
- }
- value = new GeospatialCollection(getDimension(), geospatials);
- break;
-
- default:
- value = null;
- }
-
- return value;
- }
-
- private void parsePoints(final Element parent, final Iterator<Point> itor, final boolean wrap) {
- while (itor.hasNext()) {
- final Point point = itor.next();
-
- final Element pos = parent.getOwnerDocument().
- createElementNS(Constants.NS_GML, Constants.ELEM_POS);
- pos.appendChild(parent.getOwnerDocument().createTextNode(
- Double.toString(point.getX()) + " " + point.getY()));
-
- final Element appendable;
- if (wrap) {
- final Element epoint = parent.getOwnerDocument().
- createElementNS(Constants.NS_GML, Constants.ELEM_POINT);
- parent.appendChild(epoint);
- appendable = epoint;
- } else {
- appendable = parent;
- }
- appendable.appendChild(pos);
- }
- }
-
- private void parseLineStrings(final Element parent, final Iterator<LineString> itor, final boolean wrap) {
- while (itor.hasNext()) {
- final LineString lineString = itor.next();
-
- final Element appendable;
- if (wrap) {
- final Element eLineString = parent.getOwnerDocument().
- createElementNS(Constants.NS_GML, Constants.ELEM_LINESTRING);
- parent.appendChild(eLineString);
- appendable = eLineString;
- } else {
- appendable = parent;
- }
- parsePoints(appendable, lineString.iterator(), false);
- }
- }
-
- private void parsePolygons(final Element parent, final Iterator<Polygon> itor, final boolean wrap) {
- while (itor.hasNext()) {
- final Polygon polygon = itor.next();
-
- final Element appendable;
- if (wrap) {
- final Element ePolygon = parent.getOwnerDocument().createElementNS(
- Constants.NS_GML, Constants.ELEM_POLYGON);
- parent.appendChild(ePolygon);
- appendable = ePolygon;
- } else {
- appendable = parent;
- }
-
- if (!polygon.getExterior().isEmpty()) {
- final Element exterior = parent.getOwnerDocument().createElementNS(
- Constants.NS_GML, Constants.ELEM_POLYGON_EXTERIOR);
- appendable.appendChild(exterior);
- final Element linearRing = parent.getOwnerDocument().createElementNS(
- Constants.NS_GML, Constants.ELEM_POLYGON_LINEARRING);
- exterior.appendChild(linearRing);
-
- parsePoints(linearRing, polygon.getExterior().iterator(), false);
- }
- if (!polygon.getInterior().isEmpty()) {
- final Element interior = parent.getOwnerDocument().createElementNS(
- Constants.NS_GML, Constants.ELEM_POLYGON_INTERIOR);
- appendable.appendChild(interior);
- final Element linearRing = parent.getOwnerDocument().createElementNS(
- Constants.NS_GML, Constants.ELEM_POLYGON_LINEARRING);
- interior.appendChild(linearRing);
-
- parsePoints(linearRing, polygon.getInterior().iterator(), false);
- }
- }
- }
-
- private Element parseGeospatial(final Geospatial value) {
- final DocumentBuilder builder;
- try {
- builder = XMLUtils.DOC_BUILDER_FACTORY.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- throw new IllegalStateException("Failure initializing Geospatial DOM tree", e);
- }
- final Document doc = builder.newDocument();
-
- final Element tree;
-
- switch (value.getEdmSimpleType()) {
- case GeographyPoint:
- case GeometryPoint:
- tree = doc.createElementNS(Constants.NS_GML, Constants.ELEM_POINT);
-
- parsePoints(tree, Collections.singleton((Point) value).iterator(), false);
- break;
-
- case GeometryMultiPoint:
- case GeographyMultiPoint:
- tree = doc.createElementNS(Constants.NS_GML, Constants.ELEM_MULTIPOINT);
-
- final Element pMembs = doc.createElementNS(Constants.NS_GML, Constants.ELEM_POINTMEMBERS);
- tree.appendChild(pMembs);
-
- parsePoints(pMembs, ((MultiPoint) value).iterator(), true);
- break;
-
- case GeometryLineString:
- case GeographyLineString:
- tree = doc.createElementNS(Constants.NS_GML, Constants.ELEM_LINESTRING);
-
- parseLineStrings(tree, Collections.singleton((LineString) value).iterator(), false);
- break;
-
- case GeometryMultiLineString:
- case GeographyMultiLineString:
- tree = doc.createElementNS(Constants.NS_GML, Constants.ELEM_MULTILINESTRING);
-
- final Element mlMembs =
- doc.createElementNS(Constants.NS_GML, Constants.ELEM_LINESTRINGMEMBERS);
- tree.appendChild(mlMembs);
-
- parseLineStrings(mlMembs, ((MultiLineString) value).iterator(), true);
- break;
-
- case GeographyPolygon:
- case GeometryPolygon:
- tree = doc.createElementNS(Constants.NS_GML, Constants.ELEM_POLYGON);
- parsePolygons(tree, Collections.singleton(((Polygon) value)).iterator(), false);
- break;
-
- case GeographyMultiPolygon:
- case GeometryMultiPolygon:
- tree = doc.createElementNS(Constants.NS_GML, Constants.ELEM_MULTIPOLYGON);
-
- final Element mpMembs =
- doc.createElementNS(Constants.NS_GML, Constants.ELEM_SURFACEMEMBERS);
- tree.appendChild(mpMembs);
-
- parsePolygons(mpMembs, ((MultiPolygon) value).iterator(), true);
- break;
-
- case GeographyCollection:
- case GeometryCollection:
- tree = doc.createElementNS(Constants.NS_GML, Constants.ELEM_GEOCOLLECTION);
-
- final Element gMembs =
- doc.createElementNS(Constants.NS_GML, Constants.ELEM_GEOMEMBERS);
- tree.appendChild(gMembs);
-
- final Iterator<Geospatial> itor = ((GeospatialCollection) value).iterator();
- while (itor.hasNext()) {
- final Geospatial geospatial = itor.next();
- gMembs.appendChild(doc.importNode(parseGeospatial(geospatial), true));
- }
- break;
-
- default:
- tree = null;
- }
-
- return tree;
- }
-
- public Element toTree() {
- return this.tree;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final ODataGeospatialValue other = (ODataGeospatialValue) obj;
- return this.tree.isEqualNode(other.tree);
- }
-
- @Override
- public String toString() {
- final StringWriter writer = new StringWriter();
- client.getSerializer().dom(this.tree, writer);
- return writer.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/e7135610/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataInvokeResult.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataInvokeResult.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataInvokeResult.java
deleted file mode 100644
index 0a759b3..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/data/ODataInvokeResult.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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;
-
-/**
- * Marker interface for any OData domain object that can be returned by an operation invocation.
- *
- * @see ODataEntitySet
- * @see ODataEntity
- * @see ODataProperty
- * @see ODataNoContent
- */
-public interface ODataInvokeResult {
-}