You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/02/17 16:45:36 UTC
[27/28] [OLINGO-161] Refactored Java package names
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/JsonReader.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/JsonReader.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/JsonReader.java
new file mode 100644
index 0000000..1777cff
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/JsonReader.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.deserializer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.olingo.odata4.client.api.deserializer.ConsumerException;
+import org.apache.olingo.odata4.client.api.deserializer.Entity;
+import org.apache.olingo.odata4.client.api.deserializer.EntitySet;
+import org.apache.olingo.odata4.client.api.deserializer.Property;
+import org.apache.olingo.odata4.client.api.deserializer.Reader;
+import org.apache.olingo.odata4.client.api.deserializer.StructuralProperty;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+
+public class JsonReader implements Reader {
+
+ @Override
+ public EntitySet readEntitySet(final InputStream in) throws ConsumerException {
+
+ JsonFactory jsonFactory = new JsonFactory();
+ // or, for data binding, org.codehaus.jackson.mapper.MappingJsonFactory
+ try {
+ JsonParser jp = jsonFactory.createParser(in);
+ EntitySetBuilder entitySet = new EntitySetBuilder(jp);
+ return entitySet.buildEntitySet();
+ } catch (JsonParseException e) {
+ throw new ConsumerException("JSON Parsing failed.", e);
+ } catch (IOException e) {
+ throw new ConsumerException("JSON Parsing failed.", e);
+ }
+ }
+
+ @Override
+ public Entity readEntity(final InputStream in) throws ConsumerException {
+ Entity entity = null;
+
+ JsonFactory jsonFactory = new JsonFactory();
+ // or, for data binding, org.codehaus.jackson.mapper.MappingJsonFactory
+ try {
+ JsonParser jp = jsonFactory.createParser(in);
+ PropertyCollectionBuilder builder = new PropertyCollectionBuilder(jp);
+ builder.parseNext();
+ entity = builder.buildEntity();
+ } catch (JsonParseException e) {
+ throw new ConsumerException("JSON Parsing failed.", e);
+ } catch (IOException e) {
+ throw new ConsumerException("JSON Parsing failed.", e);
+ }
+
+ return entity;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.olingo.core.consumer.Reader#parseProperty(java.io.InputStream)
+ */
+ @Override
+ public Property readProperty(final InputStream in) throws ConsumerException {
+ Entity entity = readEntity(in);
+
+ Map<String, StructuralProperty> properties = entity.getStructuralProperties();
+ if (properties.size() == 1) {
+ return properties.values().iterator().next();
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/NavigationPropertyImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/NavigationPropertyImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/NavigationPropertyImpl.java
new file mode 100644
index 0000000..e69fd37
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/NavigationPropertyImpl.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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.deserializer;
+
+import org.apache.olingo.odata4.client.api.deserializer.NavigationProperty;
+
+public class NavigationPropertyImpl implements NavigationProperty {
+
+ private final String name;
+ private String associationLink;
+ private String navigationLink;
+
+ public NavigationPropertyImpl(final String name) {
+ this.name = parseName(name);
+ }
+
+ public NavigationPropertyImpl(final String name, final String link) {
+ this(name);
+ updateLink(name, link);
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getAssociationLink() {
+ return associationLink;
+ }
+
+ @Override
+ public String getNavigationLink() {
+ return navigationLink;
+ }
+
+ public void updateLink(final String name, final String link) {
+ String regexNavigationLink = ".*@odata.navigationLink$";
+ String regexAssociationLink = ".*@odata.associationLink$";
+ if (name.matches(regexNavigationLink)) {
+ navigationLink = link;
+ } else if (name.matches(regexAssociationLink)) {
+ associationLink = link;
+ }
+ }
+
+ private String parseName(final String nameToParse) {
+ String[] split = nameToParse.split("@");
+ if (split.length == 2) {
+ return split[0];
+ } else {
+ throw new IllegalArgumentException("Got OData Navigation with unparseable format '"
+ + nameToParse + "'.");
+ }
+ }
+
+ public void updateLink(final NavigationProperty navigationProperty) {
+ if (navigationProperty.getAssociationLink() != null) {
+ associationLink = navigationProperty.getAssociationLink();
+ }
+ if (navigationProperty.getNavigationLink() != null) {
+ navigationLink = navigationProperty.getNavigationLink();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "NavigationPropertyImpl [name=" + name + ", associationLink=" + associationLink
+ + ", navigationLink=" + navigationLink + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PrimitiveValue.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PrimitiveValue.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PrimitiveValue.java
new file mode 100644
index 0000000..f510c1b
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PrimitiveValue.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.deserializer;
+
+import org.apache.olingo.odata4.client.api.deserializer.Value;
+
+public class PrimitiveValue implements Value {
+
+ private final Object content;
+
+ public PrimitiveValue(final Object content) {
+ this.content = content;
+ }
+
+ @Override
+ public boolean isComplex() {
+ return false;
+ }
+
+ @Override
+ public Object getContent() {
+ return content;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getContentAs(final T type) {
+ return (T) content;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(content);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PropertyCollection.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PropertyCollection.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PropertyCollection.java
new file mode 100644
index 0000000..ce21036
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PropertyCollection.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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.deserializer;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata4.client.api.deserializer.AnnotationProperty;
+import org.apache.olingo.odata4.client.api.deserializer.NavigationProperty;
+import org.apache.olingo.odata4.client.api.deserializer.Property;
+import org.apache.olingo.odata4.client.api.deserializer.StructuralProperty;
+
+abstract class PropertyCollection {
+ protected Map<String, AnnotationProperty> annotationProperties = new HashMap<String, AnnotationProperty>();
+ protected Map<String, NavigationProperty> navigationProperties = new HashMap<String, NavigationProperty>();
+ protected Map<String, StructuralProperty> structuralProperties = new HashMap<String, StructuralProperty>();
+
+ public PropertyCollection() {}
+
+ protected PropertyCollection(final Map<String, AnnotationProperty> annotationProperties,
+ final Map<String, NavigationProperty> navigationProperties,
+ final Map<String, StructuralProperty> structuralProperties) {
+ this.annotationProperties = annotationProperties;
+ this.navigationProperties = navigationProperties;
+ this.structuralProperties = structuralProperties;
+ }
+
+ public List<Property> getProperties() {
+ int initialCapacity = annotationProperties.size() + navigationProperties.size() + structuralProperties.size();
+
+ List<Property> properties = new ArrayList<Property>(initialCapacity);
+ properties.addAll(annotationProperties.values());
+ properties.addAll(navigationProperties.values());
+ properties.addAll(structuralProperties.values());
+
+ return properties;
+ }
+
+ public Map<String, AnnotationProperty> getAnnotationProperties() {
+ return Collections.unmodifiableMap(annotationProperties);
+ }
+
+ public Map<String, NavigationProperty> getNavigationProperties() {
+ return Collections.unmodifiableMap(navigationProperties);
+ }
+
+ public Map<String, StructuralProperty> getStructuralProperties() {
+ return Collections.unmodifiableMap(structuralProperties);
+ }
+
+ public void addProperty(final Property property) {
+ if (property == null) {
+ throw new IllegalArgumentException("Property parameter MUST NOT be NULL.");
+ }
+
+ if (property instanceof NavigationPropertyImpl) {
+ NavigationPropertyImpl navProperty = (NavigationPropertyImpl) navigationProperties.get(property.getName());
+ if (navProperty == null) {
+ navigationProperties.put(property.getName(), (NavigationPropertyImpl) property);
+ } else {
+ NavigationProperty temp = (NavigationProperty) property;
+ navProperty.updateLink(temp);
+ }
+ } else if (property instanceof AnnotationPropertyImpl) {
+ annotationProperties.put(property.getName(), (AnnotationPropertyImpl) property);
+ } else if (property instanceof StructuralProperty) {
+ structuralProperties.put(property.getName(), (StructuralProperty) property);
+ } else {
+ throw new IllegalArgumentException("Unknown class '" + property.getClass() + "'.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PropertyCollectionBuilder.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PropertyCollectionBuilder.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PropertyCollectionBuilder.java
new file mode 100644
index 0000000..37b1202
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/PropertyCollectionBuilder.java
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * 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.deserializer;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.olingo.odata4.client.api.deserializer.AnnotationProperty;
+import org.apache.olingo.odata4.client.api.deserializer.ComplexValue;
+import org.apache.olingo.odata4.client.api.deserializer.Entity;
+import org.apache.olingo.odata4.client.api.deserializer.NavigationProperty;
+import org.apache.olingo.odata4.client.api.deserializer.Property;
+import org.apache.olingo.odata4.client.api.deserializer.StructuralProperty;
+import org.apache.olingo.odata4.client.api.deserializer.Value;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+
+public class PropertyCollectionBuilder extends PropertyCollection {
+ private JsonParser parser;
+ private EntitySetImpl enclosingEntitySet;
+
+ public PropertyCollectionBuilder(final JsonParser parser) {
+ this.parser = parser;
+ }
+
+ private PropertyCollectionBuilder() {};
+
+ public PropertyCollectionBuilder(final JsonParser jp, final EntitySetImpl entitySet) {
+ this(jp);
+ enclosingEntitySet = entitySet;
+ }
+
+ public Entity buildEntity() {
+ Entity v = new EntityImpl(annotationProperties, navigationProperties, structuralProperties);
+ resetProperties();
+ return v;
+ }
+
+ public ComplexValue buildComplexValue() {
+ ComplexValue v = new ComplexValueImpl(annotationProperties, navigationProperties, structuralProperties);
+ resetProperties();
+ return v;
+ }
+
+ private void resetProperties() {
+ annotationProperties = new HashMap<String, AnnotationProperty>();
+ navigationProperties = new HashMap<String, NavigationProperty>();
+ structuralProperties = new HashMap<String, StructuralProperty>();
+ }
+
+ private PropertyCollectionBuilder next = null;
+
+ public boolean hasNext() throws JsonParseException, IOException {
+ if (parser.isClosed()) {
+ return false;
+ }
+ next = parseNextObject(parser, this);
+ return (next != null);
+ }
+
+ public boolean parseNext() {
+ try {
+ if (hasNext()) {
+ if (next != null) {
+ return true;
+ }
+
+ if (next == null) {
+ parser.close();
+ return false;
+ }
+ return true;
+ }
+ } catch (JsonParseException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return false;
+
+ }
+
+ /**
+ *
+ * @param jp
+ * @param builder
+ * @return
+ * @throws IOException
+ * @throws JsonParseException
+ */
+ private PropertyCollectionBuilder parseNextObject(final JsonParser jp, final PropertyCollectionBuilder builder)
+ throws JsonParseException, IOException {
+ boolean endReached = readToStartObjectOrEnd(jp);
+ if (endReached) {
+ return null;
+ }
+
+ //
+ String currentFieldName = null;
+ List<Value> values = null;
+
+ while (jp.nextToken() != null) {
+ JsonToken token = jp.getCurrentToken();
+ switch (token) {
+ case START_OBJECT:
+ if (currentFieldName != null) {
+ ComplexValue cvp = parseNextObject(jp, new PropertyCollectionBuilder()).buildComplexValue();
+ if (values == null) {
+ builder.addProperty(new StructuralPropertyImpl(currentFieldName, cvp));
+ } else {
+ values.add(cvp);
+ }
+ }
+ break;
+ case END_OBJECT:
+ return builder;
+ case START_ARRAY:
+ values = new ArrayList<Value>();
+ break;
+ case END_ARRAY:
+ if (values != null) {
+ builder.addProperty(new StructuralPropertyImpl(currentFieldName, values));
+ values = null;
+ }
+ break;
+ case FIELD_NAME:
+ currentFieldName = jp.getCurrentName();
+ break;
+ case NOT_AVAILABLE:
+ break;
+ case VALUE_EMBEDDED_OBJECT:
+ break;
+ case VALUE_NULL:
+ Property nullProperty = createProperty(jp.getCurrentName(), null);
+ builder.addProperty(nullProperty);
+ break;
+ case VALUE_FALSE:
+ case VALUE_NUMBER_FLOAT:
+ case VALUE_NUMBER_INT:
+ case VALUE_STRING:
+ case VALUE_TRUE:
+ if (values == null) {
+ Property property = createProperty(jp.getCurrentName(), jp.getValueAsString());
+ builder.addProperty(property);
+ } else {
+ PrimitiveValue value = new PrimitiveValue(jp.getValueAsString());
+ values.add(value);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ return null;
+ }
+
+ private boolean readToStartObjectOrEnd(final JsonParser jp) throws IOException, JsonParseException {
+ JsonToken endToken = JsonToken.START_OBJECT;
+ JsonToken token = jp.getCurrentToken() == null ? jp.nextToken() : jp.getCurrentToken();
+ while (token != null && token != endToken) {
+ if (enclosingEntitySet != null) {
+ switch (token) {
+ case VALUE_FALSE:
+ case VALUE_NUMBER_FLOAT:
+ case VALUE_NUMBER_INT:
+ case VALUE_TRUE:
+ case VALUE_STRING:
+ enclosingEntitySet.addAnnotation(jp.getCurrentName(), jp.getValueAsString());
+ break;
+ default:
+ break;
+ }
+ }
+ //
+ token = jp.nextToken();
+ }
+
+ return token == null;
+ }
+
+ private Property createProperty(final String name, final String value) {
+ if (name.contains("@")) {
+ return new NavigationPropertyImpl(name, value);
+ } else if (name.contains(".")) {
+ return new AnnotationPropertyImpl(name, value);
+ } else {
+ return new StructuralPropertyImpl(name, new PrimitiveValue(value));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/StructuralPropertyImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/StructuralPropertyImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/StructuralPropertyImpl.java
new file mode 100644
index 0000000..b83083f
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/client/core/deserializer/StructuralPropertyImpl.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata4.client.core.deserializer;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.olingo.odata4.client.api.deserializer.StructuralProperty;
+import org.apache.olingo.odata4.client.api.deserializer.Value;
+
+public class StructuralPropertyImpl implements StructuralProperty {
+
+ private final List<Value> values;
+ private final String name;
+ private final boolean containsCollection;
+
+ public StructuralPropertyImpl(final String name, final Value value) {
+ this(name, false, value);
+ }
+
+ public StructuralPropertyImpl(final String name, final List<Value> values) {
+ // XXX: ugly -> refactore
+ this(name, true, values.toArray(new Value[0]));
+ }
+
+ public StructuralPropertyImpl(final String name, final boolean asCollection, final Value... value) {
+ if (value == null || value.length == 0) {
+ throw new IllegalArgumentException("Missing or NULL value argument.");
+ }
+
+ containsCollection = asCollection;
+ this.name = name;
+ values = new ArrayList<Value>(value.length);
+ for (Value v : value) {
+ values.add(v);
+ }
+ }
+
+ @Override
+ public Value getValue() {
+ return values.get(0);
+ }
+
+ @Override
+ public List<Value> getValues() {
+ return Collections.unmodifiableList(values);
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public boolean containsCollection() {
+ return containsCollection;
+ }
+
+ @Override
+ public String toString() {
+ return "StructuralPropertyImpl [name=" + name + ", containsCollection=" + containsCollection
+ + ", values=" + values + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/ODataConsumerImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/ODataConsumerImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/ODataConsumerImpl.java
deleted file mode 100644
index ec61bba..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/ODataConsumerImpl.java
+++ /dev/null
@@ -1,33 +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.consumer.core;
-
-import org.apache.olingo.odata4.commons.api.edm.Edm;
-import org.apache.olingo.odata4.commons.api.edm.provider.EdmProvider;
-import org.apache.olingo.odata4.commons.core.ODataCommonsCoreImpl;
-import org.apache.olingo.odata4.consumer.api.ODataConsumer;
-
-public class ODataConsumerImpl extends ODataConsumer {
-
- @Override
- public Edm createEdm(final EdmProvider provider) {
- return new ODataCommonsCoreImpl().createEdm(provider);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/AnnotationPropertyImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/AnnotationPropertyImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/AnnotationPropertyImpl.java
deleted file mode 100644
index f404f02..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/AnnotationPropertyImpl.java
+++ /dev/null
@@ -1,52 +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.consumer.core.deserializer;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.AnnotationProperty;
-
-public class AnnotationPropertyImpl implements AnnotationProperty {
-
- private final String name;
- private final String value;
-
- public AnnotationPropertyImpl(final String name, final String value) {
- this.name = name;
- this.value = value;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String getValue() {
- return value;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "AnnotationPropertyImpl [name=" + name + ", value=" + value + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/ComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/ComplexValueImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/ComplexValueImpl.java
deleted file mode 100644
index e50cecf..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/ComplexValueImpl.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.consumer.core.deserializer;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.AnnotationProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.ComplexValue;
-import org.apache.olingo.odata4.consumer.api.deserializer.NavigationProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.StructuralProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.Value;
-
-public class ComplexValueImpl extends PropertyCollection implements ComplexValue {
-
- public ComplexValueImpl() {}
-
- public ComplexValueImpl(final Map<String, AnnotationProperty> annotationProperties,
- final Map<String, NavigationProperty> navigationProperties,
- final Map<String, StructuralProperty> structuralProperties) {
- super(annotationProperties, navigationProperties, structuralProperties);
- }
-
- @Override
- public Value getValue(final String name) {
- StructuralProperty property = structuralProperties.get(name);
- if (property == null) {
- return null;
- }
- return property.getValue();
- }
-
- @Override
- public Map<String, AnnotationProperty> getAnnotationProperties() {
- return Collections.unmodifiableMap(annotationProperties);
- }
-
- @Override
- public Map<String, NavigationProperty> getNavigationProperties() {
- return Collections.unmodifiableMap(navigationProperties);
- }
-
- @Override
- public boolean isComplex() {
- return true;
- }
-
- @Override
- public Map<String, StructuralProperty> getContent() {
- return Collections.unmodifiableMap(structuralProperties);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getContentAs(final T type) {
- return (T) getContent();
- }
-
- @Override
- public String toString() {
- return "ComplexValueImpl [annotations=" + annotationProperties + ", navigationProperties=" + navigationProperties
- + ", properties=" + structuralProperties + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntityImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntityImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntityImpl.java
deleted file mode 100644
index dd48083..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntityImpl.java
+++ /dev/null
@@ -1,124 +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.consumer.core.deserializer;
-
-import java.util.Map;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.AnnotationProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.Entity;
-import org.apache.olingo.odata4.consumer.api.deserializer.NavigationProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.Property;
-import org.apache.olingo.odata4.consumer.api.deserializer.StructuralProperty;
-
-public class EntityImpl extends PropertyCollection implements Entity {
-
- public EntityImpl() {}
-
- public EntityImpl(final Map<String, AnnotationProperty> annotationProperties,
- final Map<String, NavigationProperty> navigationProperties,
- final Map<String, StructuralProperty> structuralProperties) {
- super(annotationProperties, navigationProperties, structuralProperties);
- }
-
- @Override
- public String getODataMetaDataEtag() {
- return getAnnotationValue("odata.metadataEtag");
- }
-
- @Override
- public String getODataType() {
- return getAnnotationValue("odata.type");
- }
-
- @Override
- public Long getODataCount() {
- return Long.valueOf(getAnnotationValue("odata.count"));
- }
-
- @Override
- public String getODataNextLink() {
- return getAnnotationValue("odata.nextLink");
- }
-
- @Override
- public String getODataDeltaLink() {
- return getAnnotationValue("odata.deltaLink");
- }
-
- @Override
- public String getODataReadLink() {
- return getAnnotationValue("odata.readLink");
- }
-
- @Override
- public String getODataContext() {
- return getAnnotationValue("odata.context");
- }
-
- @Override
- public String getODataId() {
- return getAnnotationValue("odata.id");
- }
-
- @Override
- public String getODataETag() {
- return getAnnotationValue("odata.etag");
- }
-
- @Override
- public String getODataEditLink() {
- return getAnnotationValue("odata.editLink");
- }
-
- @Override
- public Object getPropertyContent(final String name) {
- StructuralProperty property = structuralProperties.get(name);
- if (property != null) {
- return property.getValue().getContent();
- }
- return null;
- }
-
- @Override
- public Property getProperty(final String name) {
- Property p = structuralProperties.get(name);
- if (p == null) {
- p = annotationProperties.get(name);
- }
- if (p == null) {
- p = navigationProperties.get(name);
- }
- return p;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T extends Property> T getProperty(final String name, final Class<T> clazz) {
- Property p = getProperty(name);
- return (T) p;
- }
-
- private String getAnnotationValue(final String key) {
- AnnotationProperty prop = annotationProperties.get(key);
- if (prop == null) {
- return null;
- }
- return prop.getValue();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntitySetBuilder.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntitySetBuilder.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntitySetBuilder.java
deleted file mode 100644
index 35a98d8..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntitySetBuilder.java
+++ /dev/null
@@ -1,68 +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.consumer.core.deserializer;
-
-import java.io.IOException;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.EntitySet;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
-
-public class EntitySetBuilder {
-
- private final JsonParser parser;
-
- public EntitySetBuilder(final JsonParser jp) {
- parser = jp;
- }
-
- public EntitySet buildEntitySet() throws JsonParseException, IOException {
- return parseEntitySet(parser);
- }
-
- private EntitySet parseEntitySet(final JsonParser jp) throws JsonParseException, IOException {
- EntitySetImpl entitySet = new EntitySetImpl();
- boolean arrayStarted = false;
-
- while (jp.nextToken() != null) {
- JsonToken token = jp.getCurrentToken();
- switch (token) {
- case START_ARRAY:
- PropertyCollectionBuilder builder = new PropertyCollectionBuilder(jp, entitySet);
- entitySet.setPropertyCollectionBuilder(builder);
- arrayStarted = true;
- break;
- case START_OBJECT:
- if (arrayStarted) {
- return entitySet;
- }
- break;
- case VALUE_NUMBER_INT:
- case VALUE_STRING:
- entitySet.addAnnotation(jp.getCurrentName(), jp.getValueAsString());
- default:
- break;
- }
- }
-
- return entitySet;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntitySetImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntitySetImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntitySetImpl.java
deleted file mode 100644
index 2b55e4c..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/EntitySetImpl.java
+++ /dev/null
@@ -1,113 +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.consumer.core.deserializer;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.Entity;
-import org.apache.olingo.odata4.consumer.api.deserializer.EntitySet;
-
-import com.fasterxml.jackson.core.JsonParseException;
-
-public class EntitySetImpl implements EntitySet, Iterator<Entity> {
-
- private String odataContext;
- private Long odataCount;
- private String odataNextLink;
- private String odataDeltaLink;
- private List<Entity> entities = null;
-
- private PropertyCollectionBuilder propertyCollectionsBuilder;
-
- @Override
- public String getODataContext() {
- return odataContext;
- }
-
- @Override
- public Long getODataCount() {
- return odataCount;
- }
-
- @Override
- public String getODataNextLink() {
- return odataNextLink;
- }
-
- @Override
- public String getODataDeltaLink() {
- return odataDeltaLink;
- }
-
- public void addAnnotation(final String name, final String value) {
- if ("odata.context".equalsIgnoreCase(name)) {
- odataContext = value;
- } else if ("odata.deltaLink".equalsIgnoreCase(name)) {
- odataDeltaLink = value;
- } else if ("odata.count".equalsIgnoreCase(name)) {
- odataCount = Long.parseLong(value);
- } else if ("odata.nextLink".equalsIgnoreCase(name)) {
- odataNextLink = value;
- }
- }
-
- @Override
- public List<Entity> getEntities() {
- if (entities == null) {
- entities = new ArrayList<Entity>();
-
- while (propertyCollectionsBuilder.parseNext()) {
- entities.add(propertyCollectionsBuilder.buildEntity());
- }
- }
-
- return entities;
- }
-
- public void setPropertyCollectionBuilder(final PropertyCollectionBuilder builder) {
- propertyCollectionsBuilder = builder;
- }
-
- @Override
- public boolean hasNext() {
- try {
- return propertyCollectionsBuilder.hasNext();
- } catch (JsonParseException e) {} catch (IOException e) {}
- return false;
- }
-
- @Override
- public Entity next() {
- if (propertyCollectionsBuilder.parseNext()) {
- return propertyCollectionsBuilder.buildEntity();
- }
- return null;
- }
-
- @Override
- public void remove() {}
-
- @Override
- public Iterator<Entity> iterator() {
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/JsonReader.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/JsonReader.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/JsonReader.java
deleted file mode 100644
index 2129a92..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/JsonReader.java
+++ /dev/null
@@ -1,89 +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.consumer.core.deserializer;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.ConsumerException;
-import org.apache.olingo.odata4.consumer.api.deserializer.Entity;
-import org.apache.olingo.odata4.consumer.api.deserializer.EntitySet;
-import org.apache.olingo.odata4.consumer.api.deserializer.Property;
-import org.apache.olingo.odata4.consumer.api.deserializer.Reader;
-import org.apache.olingo.odata4.consumer.api.deserializer.StructuralProperty;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-
-public class JsonReader implements Reader {
-
- @Override
- public EntitySet readEntitySet(final InputStream in) throws ConsumerException {
-
- JsonFactory jsonFactory = new JsonFactory();
- // or, for data binding, org.codehaus.jackson.mapper.MappingJsonFactory
- try {
- JsonParser jp = jsonFactory.createParser(in);
- EntitySetBuilder entitySet = new EntitySetBuilder(jp);
- return entitySet.buildEntitySet();
- } catch (JsonParseException e) {
- throw new ConsumerException("JSON Parsing failed.", e);
- } catch (IOException e) {
- throw new ConsumerException("JSON Parsing failed.", e);
- }
- }
-
- @Override
- public Entity readEntity(final InputStream in) throws ConsumerException {
- Entity entity = null;
-
- JsonFactory jsonFactory = new JsonFactory();
- // or, for data binding, org.codehaus.jackson.mapper.MappingJsonFactory
- try {
- JsonParser jp = jsonFactory.createParser(in);
- PropertyCollectionBuilder builder = new PropertyCollectionBuilder(jp);
- builder.parseNext();
- entity = builder.buildEntity();
- } catch (JsonParseException e) {
- throw new ConsumerException("JSON Parsing failed.", e);
- } catch (IOException e) {
- throw new ConsumerException("JSON Parsing failed.", e);
- }
-
- return entity;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.olingo.core.consumer.Reader#parseProperty(java.io.InputStream)
- */
- @Override
- public Property readProperty(final InputStream in) throws ConsumerException {
- Entity entity = readEntity(in);
-
- Map<String, StructuralProperty> properties = entity.getStructuralProperties();
- if (properties.size() == 1) {
- return properties.values().iterator().next();
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/NavigationPropertyImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/NavigationPropertyImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/NavigationPropertyImpl.java
deleted file mode 100644
index 2a43ca8..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/NavigationPropertyImpl.java
+++ /dev/null
@@ -1,87 +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.consumer.core.deserializer;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.NavigationProperty;
-
-public class NavigationPropertyImpl implements NavigationProperty {
-
- private final String name;
- private String associationLink;
- private String navigationLink;
-
- public NavigationPropertyImpl(final String name) {
- this.name = parseName(name);
- }
-
- public NavigationPropertyImpl(final String name, final String link) {
- this(name);
- updateLink(name, link);
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String getAssociationLink() {
- return associationLink;
- }
-
- @Override
- public String getNavigationLink() {
- return navigationLink;
- }
-
- public void updateLink(final String name, final String link) {
- String regexNavigationLink = ".*@odata.navigationLink$";
- String regexAssociationLink = ".*@odata.associationLink$";
- if (name.matches(regexNavigationLink)) {
- navigationLink = link;
- } else if (name.matches(regexAssociationLink)) {
- associationLink = link;
- }
- }
-
- private String parseName(final String nameToParse) {
- String[] split = nameToParse.split("@");
- if (split.length == 2) {
- return split[0];
- } else {
- throw new IllegalArgumentException("Got OData Navigation with unparseable format '"
- + nameToParse + "'.");
- }
- }
-
- public void updateLink(final NavigationProperty navigationProperty) {
- if (navigationProperty.getAssociationLink() != null) {
- associationLink = navigationProperty.getAssociationLink();
- }
- if (navigationProperty.getNavigationLink() != null) {
- navigationLink = navigationProperty.getNavigationLink();
- }
- }
-
- @Override
- public String toString() {
- return "NavigationPropertyImpl [name=" + name + ", associationLink=" + associationLink
- + ", navigationLink=" + navigationLink + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PrimitiveValue.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PrimitiveValue.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PrimitiveValue.java
deleted file mode 100644
index 01e9b61..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PrimitiveValue.java
+++ /dev/null
@@ -1,51 +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.consumer.core.deserializer;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.Value;
-
-public class PrimitiveValue implements Value {
-
- private final Object content;
-
- public PrimitiveValue(final Object content) {
- this.content = content;
- }
-
- @Override
- public boolean isComplex() {
- return false;
- }
-
- @Override
- public Object getContent() {
- return content;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T getContentAs(final T type) {
- return (T) content;
- }
-
- @Override
- public String toString() {
- return String.valueOf(content);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PropertyCollection.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PropertyCollection.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PropertyCollection.java
deleted file mode 100644
index de5679a..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PropertyCollection.java
+++ /dev/null
@@ -1,91 +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.consumer.core.deserializer;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.AnnotationProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.NavigationProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.Property;
-import org.apache.olingo.odata4.consumer.api.deserializer.StructuralProperty;
-
-abstract class PropertyCollection {
- protected Map<String, AnnotationProperty> annotationProperties = new HashMap<String, AnnotationProperty>();
- protected Map<String, NavigationProperty> navigationProperties = new HashMap<String, NavigationProperty>();
- protected Map<String, StructuralProperty> structuralProperties = new HashMap<String, StructuralProperty>();
-
- public PropertyCollection() {}
-
- protected PropertyCollection(final Map<String, AnnotationProperty> annotationProperties,
- final Map<String, NavigationProperty> navigationProperties,
- final Map<String, StructuralProperty> structuralProperties) {
- this.annotationProperties = annotationProperties;
- this.navigationProperties = navigationProperties;
- this.structuralProperties = structuralProperties;
- }
-
- public List<Property> getProperties() {
- int initialCapacity = annotationProperties.size() + navigationProperties.size() + structuralProperties.size();
-
- List<Property> properties = new ArrayList<Property>(initialCapacity);
- properties.addAll(annotationProperties.values());
- properties.addAll(navigationProperties.values());
- properties.addAll(structuralProperties.values());
-
- return properties;
- }
-
- public Map<String, AnnotationProperty> getAnnotationProperties() {
- return Collections.unmodifiableMap(annotationProperties);
- }
-
- public Map<String, NavigationProperty> getNavigationProperties() {
- return Collections.unmodifiableMap(navigationProperties);
- }
-
- public Map<String, StructuralProperty> getStructuralProperties() {
- return Collections.unmodifiableMap(structuralProperties);
- }
-
- public void addProperty(final Property property) {
- if (property == null) {
- throw new IllegalArgumentException("Property parameter MUST NOT be NULL.");
- }
-
- if (property instanceof NavigationPropertyImpl) {
- NavigationPropertyImpl navProperty = (NavigationPropertyImpl) navigationProperties.get(property.getName());
- if (navProperty == null) {
- navigationProperties.put(property.getName(), (NavigationPropertyImpl) property);
- } else {
- NavigationProperty temp = (NavigationProperty) property;
- navProperty.updateLink(temp);
- }
- } else if (property instanceof AnnotationPropertyImpl) {
- annotationProperties.put(property.getName(), (AnnotationPropertyImpl) property);
- } else if (property instanceof StructuralProperty) {
- structuralProperties.put(property.getName(), (StructuralProperty) property);
- } else {
- throw new IllegalArgumentException("Unknown class '" + property.getClass() + "'.");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PropertyCollectionBuilder.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PropertyCollectionBuilder.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PropertyCollectionBuilder.java
deleted file mode 100644
index fa92ec4..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/PropertyCollectionBuilder.java
+++ /dev/null
@@ -1,211 +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.consumer.core.deserializer;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.AnnotationProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.ComplexValue;
-import org.apache.olingo.odata4.consumer.api.deserializer.Entity;
-import org.apache.olingo.odata4.consumer.api.deserializer.NavigationProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.Property;
-import org.apache.olingo.odata4.consumer.api.deserializer.StructuralProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.Value;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
-
-public class PropertyCollectionBuilder extends PropertyCollection {
- private JsonParser parser;
- private EntitySetImpl enclosingEntitySet;
-
- public PropertyCollectionBuilder(final JsonParser parser) {
- this.parser = parser;
- }
-
- private PropertyCollectionBuilder() {};
-
- public PropertyCollectionBuilder(final JsonParser jp, final EntitySetImpl entitySet) {
- this(jp);
- enclosingEntitySet = entitySet;
- }
-
- public Entity buildEntity() {
- Entity v = new EntityImpl(annotationProperties, navigationProperties, structuralProperties);
- resetProperties();
- return v;
- }
-
- public ComplexValue buildComplexValue() {
- ComplexValue v = new ComplexValueImpl(annotationProperties, navigationProperties, structuralProperties);
- resetProperties();
- return v;
- }
-
- private void resetProperties() {
- annotationProperties = new HashMap<String, AnnotationProperty>();
- navigationProperties = new HashMap<String, NavigationProperty>();
- structuralProperties = new HashMap<String, StructuralProperty>();
- }
-
- private PropertyCollectionBuilder next = null;
-
- public boolean hasNext() throws JsonParseException, IOException {
- if (parser.isClosed()) {
- return false;
- }
- next = parseNextObject(parser, this);
- return (next != null);
- }
-
- public boolean parseNext() {
- try {
- if (hasNext()) {
- if (next != null) {
- return true;
- }
-
- if (next == null) {
- parser.close();
- return false;
- }
- return true;
- }
- } catch (JsonParseException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return false;
-
- }
-
- /**
- *
- * @param jp
- * @param builder
- * @return
- * @throws IOException
- * @throws JsonParseException
- */
- private PropertyCollectionBuilder parseNextObject(final JsonParser jp, final PropertyCollectionBuilder builder)
- throws JsonParseException, IOException {
- boolean endReached = readToStartObjectOrEnd(jp);
- if (endReached) {
- return null;
- }
-
- //
- String currentFieldName = null;
- List<Value> values = null;
-
- while (jp.nextToken() != null) {
- JsonToken token = jp.getCurrentToken();
- switch (token) {
- case START_OBJECT:
- if (currentFieldName != null) {
- ComplexValue cvp = parseNextObject(jp, new PropertyCollectionBuilder()).buildComplexValue();
- if (values == null) {
- builder.addProperty(new StructuralPropertyImpl(currentFieldName, cvp));
- } else {
- values.add(cvp);
- }
- }
- break;
- case END_OBJECT:
- return builder;
- case START_ARRAY:
- values = new ArrayList<Value>();
- break;
- case END_ARRAY:
- if (values != null) {
- builder.addProperty(new StructuralPropertyImpl(currentFieldName, values));
- values = null;
- }
- break;
- case FIELD_NAME:
- currentFieldName = jp.getCurrentName();
- break;
- case NOT_AVAILABLE:
- break;
- case VALUE_EMBEDDED_OBJECT:
- break;
- case VALUE_NULL:
- Property nullProperty = createProperty(jp.getCurrentName(), null);
- builder.addProperty(nullProperty);
- break;
- case VALUE_FALSE:
- case VALUE_NUMBER_FLOAT:
- case VALUE_NUMBER_INT:
- case VALUE_STRING:
- case VALUE_TRUE:
- if (values == null) {
- Property property = createProperty(jp.getCurrentName(), jp.getValueAsString());
- builder.addProperty(property);
- } else {
- PrimitiveValue value = new PrimitiveValue(jp.getValueAsString());
- values.add(value);
- }
- break;
- default:
- break;
- }
- }
-
- return null;
- }
-
- private boolean readToStartObjectOrEnd(final JsonParser jp) throws IOException, JsonParseException {
- JsonToken endToken = JsonToken.START_OBJECT;
- JsonToken token = jp.getCurrentToken() == null ? jp.nextToken() : jp.getCurrentToken();
- while (token != null && token != endToken) {
- if (enclosingEntitySet != null) {
- switch (token) {
- case VALUE_FALSE:
- case VALUE_NUMBER_FLOAT:
- case VALUE_NUMBER_INT:
- case VALUE_TRUE:
- case VALUE_STRING:
- enclosingEntitySet.addAnnotation(jp.getCurrentName(), jp.getValueAsString());
- break;
- default:
- break;
- }
- }
- //
- token = jp.nextToken();
- }
-
- return token == null;
- }
-
- private Property createProperty(final String name, final String value) {
- if (name.contains("@")) {
- return new NavigationPropertyImpl(name, value);
- } else if (name.contains(".")) {
- return new AnnotationPropertyImpl(name, value);
- } else {
- return new StructuralPropertyImpl(name, new PrimitiveValue(value));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/StructuralPropertyImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/StructuralPropertyImpl.java b/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/StructuralPropertyImpl.java
deleted file mode 100644
index 5e88417..0000000
--- a/odata4-lib/odata4-client-core/src/main/java/org/apache/olingo/odata4/consumer/core/deserializer/StructuralPropertyImpl.java
+++ /dev/null
@@ -1,81 +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.consumer.core.deserializer;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.olingo.odata4.consumer.api.deserializer.StructuralProperty;
-import org.apache.olingo.odata4.consumer.api.deserializer.Value;
-
-public class StructuralPropertyImpl implements StructuralProperty {
-
- private final List<Value> values;
- private final String name;
- private final boolean containsCollection;
-
- public StructuralPropertyImpl(final String name, final Value value) {
- this(name, false, value);
- }
-
- public StructuralPropertyImpl(final String name, final List<Value> values) {
- // XXX: ugly -> refactore
- this(name, true, values.toArray(new Value[0]));
- }
-
- public StructuralPropertyImpl(final String name, final boolean asCollection, final Value... value) {
- if (value == null || value.length == 0) {
- throw new IllegalArgumentException("Missing or NULL value argument.");
- }
-
- containsCollection = asCollection;
- this.name = name;
- values = new ArrayList<Value>(value.length);
- for (Value v : value) {
- values.add(v);
- }
- }
-
- @Override
- public Value getValue() {
- return values.get(0);
- }
-
- @Override
- public List<Value> getValues() {
- return Collections.unmodifiableList(values);
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public boolean containsCollection() {
- return containsCollection;
- }
-
- @Override
- public String toString() {
- return "StructuralPropertyImpl [name=" + name + ", containsCollection=" + containsCollection
- + ", values=" + values + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/test/java/org/apache/olingo/odata4/client/core/ODataConsumerTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/test/java/org/apache/olingo/odata4/client/core/ODataConsumerTest.java b/odata4-lib/odata4-client-core/src/test/java/org/apache/olingo/odata4/client/core/ODataConsumerTest.java
new file mode 100644
index 0000000..91467fb
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/test/java/org/apache/olingo/odata4/client/core/ODataConsumerTest.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;
+
+import org.apache.olingo.odata4.client.api.ODataConsumer;
+import org.apache.olingo.odata4.commons.api.edm.provider.EdmProvider;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ODataConsumerTest {
+
+ private ODataConsumer consumer;
+
+ @Before
+ public void before() {
+ consumer = ODataConsumer.create();
+ }
+
+ @Test
+ public void edmtest() {
+ EdmProvider provider = null;
+ consumer.createEdm(provider);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/9593b53c/odata4-lib/odata4-client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderPerformance.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderPerformance.java b/odata4-lib/odata4-client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderPerformance.java
new file mode 100644
index 0000000..fb7f4a2
--- /dev/null
+++ b/odata4-lib/odata4-client-core/src/test/java/org/apache/olingo/odata4/client/core/deserializer/JsonReaderPerformance.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.deserializer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+
+import org.apache.olingo.odata4.client.api.deserializer.ComplexValue;
+import org.apache.olingo.odata4.client.api.deserializer.Property;
+import org.apache.olingo.odata4.client.api.deserializer.StructuralProperty;
+import org.apache.olingo.odata4.client.api.deserializer.Value;
+import org.apache.olingo.odata4.client.core.deserializer.JsonReader;
+import org.apache.olingo.odata4.client.core.testutil.StringHelper;
+import org.junit.Test;
+
+public class JsonReaderPerformance {
+
+ @Test
+ public void testComplexPropertyPerformance() throws Exception {
+ JsonReader consumer = new JsonReader();
+ int runs = 1000; // * 100;
+
+ InputStream in = JsonReaderPerformance.class.getResourceAsStream("/complexProperty.json");
+ String content = StringHelper.inputStreamToString(in);
+
+// System.out.println("Started...");
+ ComplexValue complex = null;
+// long startTime = System.currentTimeMillis();
+ for (int i = 0; i < runs; i++) {
+ Property property = consumer.readProperty(StringHelper.encapsulate(content));
+ complex = (ComplexValue) ((StructuralProperty) property).getValue();
+ }
+// long endTime = System.currentTimeMillis();
+
+// long duration = endTime - startTime;
+// System.out.println("Duration: " + duration + " ms");
+// System.out.println("Duration per run: " + (duration / (float) runs) + " ms");
+
+ testComplexProperty(complex);
+ }
+
+ private void testComplexProperty(final Value value) {
+ assertNotNull(value);
+ assertTrue(value.isComplex());
+
+ ComplexValue complex = (ComplexValue) value;
+
+ assertEquals("Obere Str. 57", complex.getValue("Street").getContent());
+ assertEquals("Berlin", complex.getValue("City").getContent());
+ assertNull(complex.getValue("Region").getContent());
+ assertEquals("D-12209", complex.getValue("PostalCode").getContent());
+ }
+}