http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueDeserializer.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueDeserializer.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueDeserializer.java
deleted file mode 100644
index f77fbd8..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueDeserializer.java
+++ /dev/null
@@ -1,57 +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.client.core.edm.xml.v4.annotation;
-
-import java.io.IOException;
-
-import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer;
-import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-
-public class PropertyValueDeserializer extends 
AbstractEdmDeserializer<PropertyValueImpl> {
-
-  @Override
-  protected PropertyValueImpl doDeserialize(final JsonParser jp, final 
DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
-
-    final PropertyValueImpl propValue = new PropertyValueImpl();
-
-    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
-      final JsonToken token = jp.getCurrentToken();
-      if (token == JsonToken.FIELD_NAME) {
-        if ("Property".equals(jp.getCurrentName())) {
-          propValue.setProperty(jp.nextTextValue());
-        } else if ("Annotation".equals(jp.getCurrentName())) {
-          propValue.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
-        } else if (isAnnotationConstExprConstruct(jp)) {
-          propValue.setValue(parseAnnotationConstExprConstruct(jp));
-        } else {
-          
propValue.setValue(jp.readValueAs(AbstractDynamicAnnotationExpression.class));
-        }
-      }
-    }
-
-    return propValue;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueImpl.java
deleted file mode 100644
index 2d7011d..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueImpl.java
+++ /dev/null
@@ -1,53 +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.client.core.edm.xml.v4.annotation;
-
-import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationExpression;
-import org.apache.olingo.client.api.edm.xml.v4.annotation.PropertyValue;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-@JsonDeserialize(using = PropertyValueDeserializer.class)
-public class PropertyValueImpl extends 
AbstractAnnotatableDynamicAnnotationExpression implements PropertyValue {
-
-  private static final long serialVersionUID = -8437649215282645228L;
-
-  private String property;
-
-  private AnnotationExpression value;
-
-  @Override
-  public String getProperty() {
-    return property;
-  }
-
-  public void setProperty(final String property) {
-    this.property = property;
-  }
-
-  @Override
-  public AnnotationExpression getValue() {
-    return value;
-  }
-
-  public void setValue(final AnnotationExpression value) {
-    this.value = value;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordDeserializer.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordDeserializer.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordDeserializer.java
deleted file mode 100644
index 2ff277d..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordDeserializer.java
+++ /dev/null
@@ -1,55 +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.client.core.edm.xml.v4.annotation;
-
-import java.io.IOException;
-
-import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer;
-import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-
-public class RecordDeserializer extends AbstractEdmDeserializer<RecordImpl> {
-
-  @Override
-  protected RecordImpl doDeserialize(final JsonParser jp, final 
DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
-
-    final RecordImpl record = new RecordImpl();
-
-    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
-      final JsonToken token = jp.getCurrentToken();
-      if (token == JsonToken.FIELD_NAME) {
-        if ("Type".equals(jp.getCurrentName())) {
-          record.setType(jp.nextTextValue());
-        } else if ("Annotation".equals(jp.getCurrentName())) {
-          record.getAnnotations().add(jp.readValueAs(AnnotationImpl.class));
-        } else {
-          
record.getPropertyValues().add(jp.readValueAs(PropertyValueImpl.class));
-        }
-      }
-    }
-
-    return record;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordImpl.java
deleted file mode 100644
index eb4e736..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordImpl.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.client.core.edm.xml.v4.annotation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.client.api.edm.xml.v4.annotation.PropertyValue;
-import org.apache.olingo.client.api.edm.xml.v4.annotation.Record;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-@JsonDeserialize(using = RecordDeserializer.class)
-public class RecordImpl extends AbstractAnnotatableDynamicAnnotationExpression 
implements Record {
-
-  private static final long serialVersionUID = 4275271751615410709L;
-
-  private String type;
-
-  private final List<PropertyValue> propertyValues = new 
ArrayList<PropertyValue>();
-
-  @Override
-  public String getType() {
-    return type;
-  }
-
-  public void setType(final String type) {
-    this.type = type;
-  }
-
-  @Override
-  public List<PropertyValue> getPropertyValues() {
-    return propertyValues;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.java
deleted file mode 100644
index 6852967..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.java
+++ /dev/null
@@ -1,62 +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.client.core.edm.xml.v4.annotation;
-
-import 
org.apache.olingo.client.api.edm.xml.v4.annotation.DynamicAnnotationExpression;
-import 
org.apache.olingo.client.api.edm.xml.v4.annotation.TwoParamsOpDynamicAnnotationExpression;
-
-public class TwoParamsOpDynamicAnnotationExpressionImpl
-        extends AbstractDynamicAnnotationExpression implements 
TwoParamsOpDynamicAnnotationExpression {
-
-  private static final long serialVersionUID = 6241842185452451946L;
-
-  private Type type;
-
-  private DynamicAnnotationExpression left;
-
-  private DynamicAnnotationExpression right;
-
-  @Override
-  public Type getType() {
-    return type;
-  }
-
-  public void setType(final Type type) {
-    this.type = type;
-  }
-
-  @Override
-  public DynamicAnnotationExpression getLeftExpression() {
-    return left;
-  }
-
-  public void setLeftExpression(final DynamicAnnotationExpression left) {
-    this.left = left;
-  }
-
-  @Override
-  public DynamicAnnotationExpression getRightExpression() {
-    return right;
-  }
-
-  public void setRightExpression(final DynamicAnnotationExpression right) {
-    this.right = right;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefDeserializer.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefDeserializer.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefDeserializer.java
deleted file mode 100644
index b6c9e71..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefDeserializer.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.client.core.edm.xml.v4.annotation;
-
-import java.io.IOException;
-
-import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.DeserializationContext;
-
-public class UrlRefDeserializer extends AbstractEdmDeserializer<UrlRefImpl> {
-
-  @Override
-  protected UrlRefImpl doDeserialize(final JsonParser jp, final 
DeserializationContext ctxt)
-          throws IOException, JsonProcessingException {
-
-    final UrlRefImpl urlref = new UrlRefImpl();
-
-    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
-      final JsonToken token = jp.getCurrentToken();
-      if (token == JsonToken.FIELD_NAME) {
-        if (isAnnotationConstExprConstruct(jp)) {
-          urlref.setValue(parseAnnotationConstExprConstruct(jp));
-        } else {
-          
urlref.setValue(jp.readValueAs(AbstractDynamicAnnotationExpression.class));
-        }
-      }
-    }
-
-    return urlref;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefImpl.java
deleted file mode 100644
index a7308a9..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefImpl.java
+++ /dev/null
@@ -1,42 +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.client.core.edm.xml.v4.annotation;
-
-import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationExpression;
-import org.apache.olingo.client.api.edm.xml.v4.annotation.UrlRef;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-
-@JsonDeserialize(using = UrlRefDeserializer.class)
-public class UrlRefImpl extends AbstractDynamicAnnotationExpression implements 
UrlRef {
-
-  private static final long serialVersionUID = -7693224811739000440L;
-
-  private AnnotationExpression value;
-
-  @Override
-  public AnnotationExpression getValue() {
-    return value;
-  }
-
-  public void setValue(final AnnotationExpression value) {
-    this.value = value;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataBinder.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataBinder.java
index 23587af..7a93bbe 100644
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataBinder.java
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/AbstractODataBinder.java
@@ -27,10 +27,10 @@ import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.EdmEnabledODataClient;
 import org.apache.olingo.client.api.data.ServiceDocument;
 import org.apache.olingo.client.api.data.ServiceDocumentItem;
 import org.apache.olingo.client.api.serialization.CommonODataBinder;
-import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
 import org.apache.olingo.client.core.uri.URIUtils;
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.data.ContextURL;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
new file mode 100644
index 0000000..b14ea6b
--- /dev/null
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java
@@ -0,0 +1,430 @@
+/*
+ * 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.client.core.serialization;
+
+import java.net.URI;
+import java.util.List;
+
+import org.apache.olingo.client.api.EdmEnabledODataClient;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.data.ServiceDocumentItem;
+import org.apache.olingo.client.api.serialization.ODataBinder;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.data.Annotatable;
+import org.apache.olingo.commons.api.data.Annotation;
+import org.apache.olingo.commons.api.data.DeletedEntity;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.DeltaLink;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntitySet;
+import org.apache.olingo.commons.api.data.Link;
+import org.apache.olingo.commons.api.data.Linked;
+import org.apache.olingo.commons.api.data.LinkedComplexValue;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataCollectionValue;
+import org.apache.olingo.commons.api.domain.ODataInlineEntity;
+import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
+import org.apache.olingo.commons.api.domain.ODataLinked;
+import org.apache.olingo.commons.api.domain.ODataServiceDocument;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.domain.v4.ODataAnnotatable;
+import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
+import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity.Reason;
+import org.apache.olingo.commons.api.domain.v4.ODataDelta;
+import org.apache.olingo.commons.api.domain.v4.ODataDeltaLink;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataLink;
+import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.domain.v4.ODataValuable;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmElement;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmTerm;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.core.data.AnnotationImpl;
+import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
+import org.apache.olingo.commons.core.data.PropertyImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataAnnotationImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataDeletedEntityImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataDeltaLinkImpl;
+import org.apache.olingo.commons.core.domain.v4.ODataPropertyImpl;
+import org.apache.olingo.commons.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.core.serialization.ContextURLParser;
+
+public class ODataBinderImpl extends AbstractODataBinder implements 
ODataBinder {
+
+  public ODataBinderImpl(final ODataClient client) {
+    super(client);
+  }
+
+  @Override
+  public boolean add(final CommonODataEntity entity, final CommonODataProperty 
property) {
+    return ((ODataEntity) entity).getProperties().add((ODataProperty) 
property);
+  }
+
+  @Override
+  protected boolean add(final CommonODataEntitySet entitySet, final 
CommonODataEntity entity) {
+    return ((ODataEntitySet) entitySet).getEntities().add((ODataEntity) 
entity);
+  }
+
+  @Override
+  public ODataServiceDocument getODataServiceDocument(final ServiceDocument 
resource) {
+    final ODataServiceDocument serviceDocument = 
super.getODataServiceDocument(resource);
+
+    for (ServiceDocumentItem functionImport : resource.getFunctionImports()) {
+      serviceDocument.getFunctionImports().put(
+              functionImport.getName() == null ? functionImport.getUrl() : 
functionImport.getName(),
+              URIUtils.getURI(resource.getBaseURI(), functionImport.getUrl()));
+    }
+    for (ServiceDocumentItem singleton : resource.getSingletons()) {
+      serviceDocument.getSingletons().put(
+              singleton.getName() == null ? singleton.getUrl() : 
singleton.getName(),
+              URIUtils.getURI(resource.getBaseURI(), singleton.getUrl()));
+    }
+    for (ServiceDocumentItem sdoc : resource.getRelatedServiceDocuments()) {
+      serviceDocument.getRelatedServiceDocuments().put(
+              sdoc.getName() == null ? sdoc.getUrl() : sdoc.getName(),
+              URIUtils.getURI(resource.getBaseURI(), sdoc.getUrl()));
+    }
+
+    return serviceDocument;
+  }
+
+  private void updateValuable(final Valuable propertyResource, final 
ODataValuable odataValuable) {
+    final Object propertyValue = getValue(odataValuable.getValue());
+    if (odataValuable.hasPrimitiveValue()) {
+      
propertyResource.setType(odataValuable.getPrimitiveValue().getTypeName());
+      propertyResource.setValue(
+              propertyValue instanceof Geospatial ? ValueType.GEOSPATIAL : 
ValueType.PRIMITIVE,
+              propertyValue);
+    } else if (odataValuable.hasEnumValue()) {
+      propertyResource.setType(odataValuable.getEnumValue().getTypeName());
+      propertyResource.setValue(ValueType.ENUM, propertyValue);
+    } else if (odataValuable.hasComplexValue()) {
+      propertyResource.setType(odataValuable.getComplexValue().getTypeName());
+      propertyResource.setValue(
+              propertyValue instanceof LinkedComplexValue ? 
ValueType.LINKED_COMPLEX : ValueType.COMPLEX,
+              propertyValue);
+    } else if (odataValuable.hasCollectionValue()) {
+      final 
ODataCollectionValue<org.apache.olingo.commons.api.domain.v4.ODataValue> 
collectionValue =
+              odataValuable.getCollectionValue();
+      propertyResource.setType(collectionValue.getTypeName());
+      final org.apache.olingo.commons.api.domain.v4.ODataValue value =
+              collectionValue.iterator().hasNext() ? 
collectionValue.iterator().next() : null;
+      ValueType valueType = ValueType.COLLECTION_PRIMITIVE;
+      if (value == null) {
+        valueType = ValueType.COLLECTION_PRIMITIVE;
+      } else if (value.isPrimitive()) {
+        valueType = value.asPrimitive().toValue() instanceof Geospatial
+                ? ValueType.COLLECTION_GEOSPATIAL : 
ValueType.COLLECTION_PRIMITIVE;
+      } else if (value.isEnum()) {
+        valueType = ValueType.COLLECTION_ENUM;
+      } else if (value.isLinkedComplex()) {
+        valueType = ValueType.COLLECTION_LINKED_COMPLEX;
+      } else if (value.isComplex()) {
+        valueType = ValueType.COLLECTION_COMPLEX;
+      }
+      propertyResource.setValue(valueType, propertyValue);
+    }
+  }
+
+  private void annotations(final ODataAnnotatable odataAnnotatable, final 
Annotatable annotatable) {
+    for (ODataAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) {
+      final Annotation annotation = new AnnotationImpl();
+
+      annotation.setTerm(odataAnnotation.getTerm());
+      annotation.setType(odataAnnotation.getValue().getTypeName());
+      updateValuable(annotation, odataAnnotation);
+
+      annotatable.getAnnotations().add(annotation);
+    }
+  }
+
+  @Override
+  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet) {
+    final EntitySet entitySet = super.getEntitySet(odataEntitySet);
+    entitySet.setDeltaLink(((ODataEntitySet) odataEntitySet).getDeltaLink());
+    annotations((ODataEntitySet) odataEntitySet, entitySet);
+    return entitySet;
+  }
+
+  @Override
+  protected void links(final ODataLinked odataLinked, final Linked linked) {
+    super.links(odataLinked, linked);
+
+    for (Link link : linked.getNavigationLinks()) {
+      final org.apache.olingo.commons.api.domain.ODataLink odataLink = 
odataLinked.getNavigationLink(link.getTitle());
+      if (!(odataLink instanceof ODataInlineEntity) && !(odataLink instanceof 
ODataInlineEntitySet)) {
+        annotations((ODataLink) odataLink, link);
+      }
+    }
+  }
+
+  @Override
+  public Entity getEntity(final CommonODataEntity odataEntity) {
+    final Entity entity = super.getEntity(odataEntity);
+    entity.setId(((ODataEntity) odataEntity).getId());
+    annotations((ODataEntity) odataEntity, entity);
+    return entity;
+  }
+
+  @Override
+  public Property getProperty(final CommonODataProperty property) {
+    final ODataProperty _property = (ODataProperty) property;
+
+    final Property propertyResource = new PropertyImpl();
+    propertyResource.setName(_property.getName());
+    updateValuable(propertyResource, _property);
+    annotations(_property, propertyResource);
+
+    return propertyResource;
+  }
+
+  @Override
+  @SuppressWarnings("unchecked")
+  protected Object getValue(final ODataValue value) {
+    Object valueResource;
+    if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
+            && ((org.apache.olingo.commons.api.domain.v4.ODataValue) 
value).isEnum()) {
+
+      valueResource =
+              ((org.apache.olingo.commons.api.domain.v4.ODataValue) 
value).asEnum().getValue();
+    } else {
+      valueResource = super.getValue(value);
+
+      if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
+              && ((org.apache.olingo.commons.api.domain.v4.ODataValue) 
value).isLinkedComplex()) {
+
+        final LinkedComplexValue lcValueResource = new 
LinkedComplexValueImpl();
+        lcValueResource.getValue().addAll((List<Property>) valueResource);
+
+        final ODataLinkedComplexValue linked =
+                ((org.apache.olingo.commons.api.domain.v4.ODataValue) 
value).asLinkedComplex();
+        annotations(linked, lcValueResource);
+        links(linked, lcValueResource);
+
+        valueResource = lcValueResource;
+      }
+    }
+    return valueResource;
+  }
+
+  private void odataAnnotations(final Annotatable annotatable, final 
ODataAnnotatable odataAnnotatable) {
+    for (Annotation annotation : annotatable.getAnnotations()) {
+      FullQualifiedName fqn = null;
+      if (client instanceof EdmEnabledODataClient) {
+        final EdmTerm term = ((EdmEnabledODataClient) client).getCachedEdm().
+                getTerm(new FullQualifiedName(annotation.getTerm()));
+        if (term != null) {
+          fqn = term.getType().getFullQualifiedName();
+        }
+      }
+
+      if (fqn == null && annotation.getType() != null) {
+        final EdmTypeInfo typeInfo = new 
EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build();
+        if (typeInfo.isPrimitiveType()) {
+          fqn = typeInfo.getPrimitiveTypeKind().getFullQualifiedName();
+        }
+      }
+
+      final ODataAnnotation odataAnnotation = new 
ODataAnnotationImpl(annotation.getTerm(),
+              (org.apache.olingo.commons.api.domain.v4.ODataValue) 
getODataValue(fqn, annotation, null, null));
+      odataAnnotatable.getAnnotations().add(odataAnnotation);
+    }
+  }
+
+  @Override
+  public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
+    final ODataEntitySet entitySet = (ODataEntitySet) 
super.getODataEntitySet(resource);
+
+    if (resource.getPayload().getDeltaLink() != null) {
+      final URI base = resource.getContextURL() == null
+              ? resource.getPayload().getBaseURI()
+              : 
ContextURLParser.parse(resource.getContextURL()).getServiceRoot();
+      entitySet.setDeltaLink(URIUtils.getURI(base, 
resource.getPayload().getDeltaLink()));
+    }
+    odataAnnotations(resource.getPayload(), entitySet);
+
+    return entitySet;
+  }
+
+  @Override
+  protected void odataNavigationLinks(final EdmType edmType,
+          final Linked linked, final ODataLinked odataLinked, final String 
metadataETag, final URI base) {
+
+    super.odataNavigationLinks(edmType, linked, odataLinked, metadataETag, 
base);
+    for (org.apache.olingo.commons.api.domain.ODataLink link : 
odataLinked.getNavigationLinks()) {
+      if (!(link instanceof ODataInlineEntity) && !(link instanceof 
ODataInlineEntitySet)) {
+        odataAnnotations(linked.getNavigationLink(link.getName()), 
(ODataAnnotatable) link);
+      }
+    }
+  }
+
+  @Override
+  public ODataEntity getODataEntity(final ResWrap<Entity> resource) {
+    final ODataEntity entity = (ODataEntity) super.getODataEntity(resource);
+
+    entity.setId(resource.getPayload().getId());
+    odataAnnotations(resource.getPayload(), entity);
+
+    return entity;
+  }
+
+  @Override
+  public ODataProperty getODataProperty(final ResWrap<Property> resource) {
+    final Property payload = resource.getPayload();
+    final EdmTypeInfo typeInfo = 
buildTypeInfo(ContextURLParser.parse(resource.getContextURL()),
+            resource.getMetadataETag(), payload.getName(), payload.getType());
+
+    final ODataProperty property = new ODataPropertyImpl(payload.getName(),
+            getODataValue(typeInfo == null ? null : 
typeInfo.getFullQualifiedName(),
+                    payload, resource.getContextURL(), 
resource.getMetadataETag()));
+    odataAnnotations(payload, property);
+
+    return property;
+  }
+
+  @Override
+  protected ODataProperty getODataProperty(final EdmType type, final Property 
resource) {
+    final EdmTypeInfo typeInfo = buildTypeInfo(type == null ? null : 
type.getFullQualifiedName(), resource.getType());
+
+    final ODataProperty property = new ODataPropertyImpl(resource.getName(),
+            getODataValue(typeInfo == null ? null : 
typeInfo.getFullQualifiedName(),
+                    resource, null, null));
+    odataAnnotations(resource, property);
+
+    return property;
+  }
+
+  @Override
+  protected ODataValue getODataValue(final FullQualifiedName type,
+          final Valuable valuable, final URI contextURL, final String 
metadataETag) {
+
+    // fixes enum values treated as primitive when no type information is 
available
+    if (client instanceof EdmEnabledODataClient && type != null) {
+      final EdmEnumType edmType = ((EdmEnabledODataClient) 
client).getEdm(metadataETag).getEnumType(type);
+      if (valuable.isPrimitive() && edmType != null) {
+        valuable.setValue(ValueType.ENUM, valuable.asPrimitive());
+      }
+    }
+
+    ODataValue value;
+    if (valuable.isEnum()) {
+      value = ((ODataClient) client).getObjectFactory().newEnumValue(type == 
null ? null : type.toString(),
+              valuable.asEnum().toString());
+    } else if (valuable.isLinkedComplex()) {
+      final ODataLinkedComplexValue lcValue =
+              ((ODataClient) 
client).getObjectFactory().newLinkedComplexValue(type == null ? null : 
type.toString());
+
+      EdmComplexType edmType = null;
+      if (client instanceof EdmEnabledODataClient && type != null) {
+        edmType = ((EdmEnabledODataClient) 
client).getEdm(metadataETag).getComplexType(type);
+      }
+
+      for (Property property : valuable.asLinkedComplex().getValue()) {
+        EdmType edmPropertyType = null;
+        if (edmType != null) {
+          final EdmElement edmProp = edmType.getProperty(property.getName());
+          if (edmProp != null) {
+            edmPropertyType = edmProp.getType();
+          }
+        }
+        lcValue.add(getODataProperty(edmPropertyType, property));
+      }
+
+      odataNavigationLinks(edmType, valuable.asLinkedComplex(), lcValue, 
metadataETag, contextURL);
+      odataAnnotations(valuable.asLinkedComplex(), lcValue);
+
+      value = lcValue;
+    } else {
+      value = super.getODataValue(type, valuable, contextURL, metadataETag);
+    }
+
+    return value;
+  }
+
+  @Override
+  public ODataDelta getODataDelta(final ResWrap<Delta> resource) {
+    final URI base = resource.getContextURL() == null
+            ? resource.getPayload().getBaseURI()
+            : 
ContextURLParser.parse(resource.getContextURL()).getServiceRoot();
+
+    final URI next = resource.getPayload().getNext();
+
+    final ODataDelta delta = next == null
+            ? ((ODataClient) client).getObjectFactory().newDelta()
+            : ((ODataClient) 
client).getObjectFactory().newDelta(URIUtils.getURI(base, 
next.toASCIIString()));
+
+    if (resource.getPayload().getCount() != null) {
+      delta.setCount(resource.getPayload().getCount());
+    }
+
+    if (resource.getPayload().getDeltaLink() != null) {
+      delta.setDeltaLink(URIUtils.getURI(base, 
resource.getPayload().getDeltaLink()));
+    }
+
+    for (Entity entityResource : resource.getPayload().getEntities()) {
+      add(delta, getODataEntity(
+              new ResWrap<Entity>(resource.getContextURL(), 
resource.getMetadataETag(), entityResource)));
+    }
+    for (DeletedEntity deletedEntity : 
resource.getPayload().getDeletedEntities()) {
+      final ODataDeletedEntityImpl impl = new ODataDeletedEntityImpl();
+      impl.setId(URIUtils.getURI(base, deletedEntity.getId()));
+      impl.setReason(Reason.valueOf(deletedEntity.getReason().name()));
+
+      delta.getDeletedEntities().add(impl);
+    }
+
+    odataAnnotations(resource.getPayload(), delta);
+
+    for (DeltaLink link : resource.getPayload().getAddedLinks()) {
+      final ODataDeltaLink impl = new ODataDeltaLinkImpl();
+      impl.setRelationship(link.getRelationship());
+      impl.setSource(URIUtils.getURI(base, link.getSource()));
+      impl.setTarget(URIUtils.getURI(base, link.getTarget()));
+
+      odataAnnotations(link, impl);
+
+      delta.getAddedLinks().add(impl);
+    }
+    for (DeltaLink link : resource.getPayload().getDeletedLinks()) {
+      final ODataDeltaLink impl = new ODataDeltaLinkImpl();
+      impl.setRelationship(link.getRelationship());
+      impl.setSource(URIUtils.getURI(base, link.getSource()));
+      impl.setTarget(URIUtils.getURI(base, link.getTarget()));
+
+      odataAnnotations(link, impl);
+
+      delta.getDeletedLinks().add(impl);
+    }
+
+    return delta;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataDeserializerImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataDeserializerImpl.java
new file mode 100644
index 0000000..abf3ceb
--- /dev/null
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataDeserializerImpl.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.serialization;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.client.api.serialization.ODataDeserializer;
+import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
+import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
+import org.apache.olingo.client.core.edm.xml.EdmxImpl;
+import org.apache.olingo.client.core.edm.xml.XMLMetadataImpl;
+import org.apache.olingo.commons.api.data.Delta;
+import org.apache.olingo.commons.api.data.ResWrap;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+import org.apache.olingo.commons.core.serialization.AtomDeserializer;
+import org.apache.olingo.commons.core.serialization.JsonDeltaDeserializer;
+
+public class ODataDeserializerImpl extends AbstractODataDeserializer 
implements ODataDeserializer {
+
+  private final ODataFormat format;
+
+  public ODataDeserializerImpl(final ODataServiceVersion version, final 
boolean serverMode, final ODataFormat format) {
+    super(version, serverMode, format);
+    this.format = format;
+  }
+
+  @Override
+  public XMLMetadata toMetadata(final InputStream input) {
+    try {
+      return new XMLMetadataImpl(getXmlMapper().readValue(input, 
EdmxImpl.class));
+    } catch (Exception e) {
+      throw new IllegalArgumentException("Could not parse as Edmx document", 
e);
+    }
+  }
+
+  @Override
+  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input) 
throws ODataDeserializerException {
+    return format == ODataFormat.XML ?
+        new XMLServiceDocumentDeserializer(version, 
false).toServiceDocument(input) :
+        new JSONServiceDocumentDeserializer(version, 
false).toServiceDocument(input);
+  }
+
+  @Override
+  public ResWrap<Delta> toDelta(final InputStream input) throws 
ODataDeserializerException {
+    try {
+      return format == ODataFormat.ATOM ?
+          new AtomDeserializer(version).delta(input) :
+          new JsonDeltaDeserializer(version, false).toDelta(input);
+    } catch (XMLStreamException e) {
+      throw new ODataDeserializerException(e);
+    } catch (final EdmPrimitiveTypeException e) {
+      throw new ODataDeserializerException(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
new file mode 100644
index 0000000..1480556
--- /dev/null
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataReaderImpl.java
@@ -0,0 +1,54 @@
+/*
+ * 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.client.core.serialization;
+
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.serialization.ODataReader;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
+
+public class ODataReaderImpl extends AbstractODataReader implements 
ODataReader {
+
+  public ODataReaderImpl(final ODataClient client) {
+    super(client);
+  }
+
+  @Override
+  public ODataEntitySet readEntitySet(final InputStream input, final 
ODataFormat format)
+      throws ODataDeserializerException {
+    return ((ODataClient) 
client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
+  }
+
+  @Override
+  public ODataEntity readEntity(final InputStream input, final ODataFormat 
format)
+      throws ODataDeserializerException {
+    return ((ODataClient) 
client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
+  }
+
+  @Override
+  public ODataProperty readProperty(final InputStream input, final ODataFormat 
format)
+      throws ODataDeserializerException {
+    return ((ODataClient) 
client).getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
deleted file mode 100644
index c9baa58..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataBinderImpl.java
+++ /dev/null
@@ -1,431 +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.client.core.serialization.v4;
-
-import java.net.URI;
-import java.util.List;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.api.data.ServiceDocumentItem;
-import org.apache.olingo.client.api.serialization.v4.ODataBinder;
-import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
-import org.apache.olingo.client.api.v4.ODataClient;
-import org.apache.olingo.client.core.serialization.AbstractODataBinder;
-import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.commons.api.data.Annotatable;
-import org.apache.olingo.commons.api.data.Annotation;
-import org.apache.olingo.commons.api.data.DeletedEntity;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.DeltaLink;
-import org.apache.olingo.commons.api.data.Entity;
-import org.apache.olingo.commons.api.data.EntitySet;
-import org.apache.olingo.commons.api.data.Link;
-import org.apache.olingo.commons.api.data.Linked;
-import org.apache.olingo.commons.api.data.LinkedComplexValue;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataCollectionValue;
-import org.apache.olingo.commons.api.domain.ODataInlineEntity;
-import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
-import org.apache.olingo.commons.api.domain.ODataLinked;
-import org.apache.olingo.commons.api.domain.ODataServiceDocument;
-import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.domain.v4.ODataAnnotatable;
-import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
-import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity.Reason;
-import org.apache.olingo.commons.api.domain.v4.ODataDelta;
-import org.apache.olingo.commons.api.domain.v4.ODataDeltaLink;
-import org.apache.olingo.commons.api.domain.v4.ODataEntity;
-import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.v4.ODataLink;
-import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
-import org.apache.olingo.commons.api.domain.v4.ODataProperty;
-import org.apache.olingo.commons.api.domain.v4.ODataValuable;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmElement;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmTerm;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.core.data.AnnotationImpl;
-import org.apache.olingo.commons.core.data.LinkedComplexValueImpl;
-import org.apache.olingo.commons.core.data.PropertyImpl;
-import org.apache.olingo.commons.core.domain.v4.ODataAnnotationImpl;
-import org.apache.olingo.commons.core.domain.v4.ODataDeletedEntityImpl;
-import org.apache.olingo.commons.core.domain.v4.ODataDeltaLinkImpl;
-import org.apache.olingo.commons.core.domain.v4.ODataPropertyImpl;
-import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-import org.apache.olingo.commons.core.serialization.ContextURLParser;
-
-public class ODataBinderImpl extends AbstractODataBinder implements 
ODataBinder {
-
-  public ODataBinderImpl(final ODataClient client) {
-    super(client);
-  }
-
-  @Override
-  public boolean add(final CommonODataEntity entity, final CommonODataProperty 
property) {
-    return ((ODataEntity) entity).getProperties().add((ODataProperty) 
property);
-  }
-
-  @Override
-  protected boolean add(final CommonODataEntitySet entitySet, final 
CommonODataEntity entity) {
-    return ((ODataEntitySet) entitySet).getEntities().add((ODataEntity) 
entity);
-  }
-
-  @Override
-  public ODataServiceDocument getODataServiceDocument(final ServiceDocument 
resource) {
-    final ODataServiceDocument serviceDocument = 
super.getODataServiceDocument(resource);
-
-    for (ServiceDocumentItem functionImport : resource.getFunctionImports()) {
-      serviceDocument.getFunctionImports().put(
-              functionImport.getName() == null ? functionImport.getUrl() : 
functionImport.getName(),
-              URIUtils.getURI(resource.getBaseURI(), functionImport.getUrl()));
-    }
-    for (ServiceDocumentItem singleton : resource.getSingletons()) {
-      serviceDocument.getSingletons().put(
-              singleton.getName() == null ? singleton.getUrl() : 
singleton.getName(),
-              URIUtils.getURI(resource.getBaseURI(), singleton.getUrl()));
-    }
-    for (ServiceDocumentItem sdoc : resource.getRelatedServiceDocuments()) {
-      serviceDocument.getRelatedServiceDocuments().put(
-              sdoc.getName() == null ? sdoc.getUrl() : sdoc.getName(),
-              URIUtils.getURI(resource.getBaseURI(), sdoc.getUrl()));
-    }
-
-    return serviceDocument;
-  }
-
-  private void updateValuable(final Valuable propertyResource, final 
ODataValuable odataValuable) {
-    final Object propertyValue = getValue(odataValuable.getValue());
-    if (odataValuable.hasPrimitiveValue()) {
-      
propertyResource.setType(odataValuable.getPrimitiveValue().getTypeName());
-      propertyResource.setValue(
-              propertyValue instanceof Geospatial ? ValueType.GEOSPATIAL : 
ValueType.PRIMITIVE,
-              propertyValue);
-    } else if (odataValuable.hasEnumValue()) {
-      propertyResource.setType(odataValuable.getEnumValue().getTypeName());
-      propertyResource.setValue(ValueType.ENUM, propertyValue);
-    } else if (odataValuable.hasComplexValue()) {
-      propertyResource.setType(odataValuable.getComplexValue().getTypeName());
-      propertyResource.setValue(
-              propertyValue instanceof LinkedComplexValue ? 
ValueType.LINKED_COMPLEX : ValueType.COMPLEX,
-              propertyValue);
-    } else if (odataValuable.hasCollectionValue()) {
-      final 
ODataCollectionValue<org.apache.olingo.commons.api.domain.v4.ODataValue> 
collectionValue =
-              odataValuable.getCollectionValue();
-      propertyResource.setType(collectionValue.getTypeName());
-      final org.apache.olingo.commons.api.domain.v4.ODataValue value =
-              collectionValue.iterator().hasNext() ? 
collectionValue.iterator().next() : null;
-      ValueType valueType = ValueType.COLLECTION_PRIMITIVE;
-      if (value == null) {
-        valueType = ValueType.COLLECTION_PRIMITIVE;
-      } else if (value.isPrimitive()) {
-        valueType = value.asPrimitive().toValue() instanceof Geospatial
-                ? ValueType.COLLECTION_GEOSPATIAL : 
ValueType.COLLECTION_PRIMITIVE;
-      } else if (value.isEnum()) {
-        valueType = ValueType.COLLECTION_ENUM;
-      } else if (value.isLinkedComplex()) {
-        valueType = ValueType.COLLECTION_LINKED_COMPLEX;
-      } else if (value.isComplex()) {
-        valueType = ValueType.COLLECTION_COMPLEX;
-      }
-      propertyResource.setValue(valueType, propertyValue);
-    }
-  }
-
-  private void annotations(final ODataAnnotatable odataAnnotatable, final 
Annotatable annotatable) {
-    for (ODataAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) {
-      final Annotation annotation = new AnnotationImpl();
-
-      annotation.setTerm(odataAnnotation.getTerm());
-      annotation.setType(odataAnnotation.getValue().getTypeName());
-      updateValuable(annotation, odataAnnotation);
-
-      annotatable.getAnnotations().add(annotation);
-    }
-  }
-
-  @Override
-  public EntitySet getEntitySet(final CommonODataEntitySet odataEntitySet) {
-    final EntitySet entitySet = super.getEntitySet(odataEntitySet);
-    entitySet.setDeltaLink(((ODataEntitySet) odataEntitySet).getDeltaLink());
-    annotations((ODataEntitySet) odataEntitySet, entitySet);
-    return entitySet;
-  }
-
-  @Override
-  protected void links(final ODataLinked odataLinked, final Linked linked) {
-    super.links(odataLinked, linked);
-
-    for (Link link : linked.getNavigationLinks()) {
-      final org.apache.olingo.commons.api.domain.ODataLink odataLink = 
odataLinked.getNavigationLink(link.getTitle());
-      if (!(odataLink instanceof ODataInlineEntity) && !(odataLink instanceof 
ODataInlineEntitySet)) {
-        annotations((ODataLink) odataLink, link);
-      }
-    }
-  }
-
-  @Override
-  public Entity getEntity(final CommonODataEntity odataEntity) {
-    final Entity entity = super.getEntity(odataEntity);
-    entity.setId(((ODataEntity) odataEntity).getId());
-    annotations((ODataEntity) odataEntity, entity);
-    return entity;
-  }
-
-  @Override
-  public Property getProperty(final CommonODataProperty property) {
-    final ODataProperty _property = (ODataProperty) property;
-
-    final Property propertyResource = new PropertyImpl();
-    propertyResource.setName(_property.getName());
-    updateValuable(propertyResource, _property);
-    annotations(_property, propertyResource);
-
-    return propertyResource;
-  }
-
-  @Override
-  @SuppressWarnings("unchecked")
-  protected Object getValue(final ODataValue value) {
-    Object valueResource;
-    if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
-            && ((org.apache.olingo.commons.api.domain.v4.ODataValue) 
value).isEnum()) {
-
-      valueResource =
-              ((org.apache.olingo.commons.api.domain.v4.ODataValue) 
value).asEnum().getValue();
-    } else {
-      valueResource = super.getValue(value);
-
-      if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
-              && ((org.apache.olingo.commons.api.domain.v4.ODataValue) 
value).isLinkedComplex()) {
-
-        final LinkedComplexValue lcValueResource = new 
LinkedComplexValueImpl();
-        lcValueResource.getValue().addAll((List<Property>) valueResource);
-
-        final ODataLinkedComplexValue linked =
-                ((org.apache.olingo.commons.api.domain.v4.ODataValue) 
value).asLinkedComplex();
-        annotations(linked, lcValueResource);
-        links(linked, lcValueResource);
-
-        valueResource = lcValueResource;
-      }
-    }
-    return valueResource;
-  }
-
-  private void odataAnnotations(final Annotatable annotatable, final 
ODataAnnotatable odataAnnotatable) {
-    for (Annotation annotation : annotatable.getAnnotations()) {
-      FullQualifiedName fqn = null;
-      if (client instanceof EdmEnabledODataClient) {
-        final EdmTerm term = ((EdmEnabledODataClient) client).getCachedEdm().
-                getTerm(new FullQualifiedName(annotation.getTerm()));
-        if (term != null) {
-          fqn = term.getType().getFullQualifiedName();
-        }
-      }
-
-      if (fqn == null && annotation.getType() != null) {
-        final EdmTypeInfo typeInfo = new 
EdmTypeInfo.Builder().setTypeExpression(annotation.getType()).build();
-        if (typeInfo.isPrimitiveType()) {
-          fqn = typeInfo.getPrimitiveTypeKind().getFullQualifiedName();
-        }
-      }
-
-      final ODataAnnotation odataAnnotation = new 
ODataAnnotationImpl(annotation.getTerm(),
-              (org.apache.olingo.commons.api.domain.v4.ODataValue) 
getODataValue(fqn, annotation, null, null));
-      odataAnnotatable.getAnnotations().add(odataAnnotation);
-    }
-  }
-
-  @Override
-  public ODataEntitySet getODataEntitySet(final ResWrap<EntitySet> resource) {
-    final ODataEntitySet entitySet = (ODataEntitySet) 
super.getODataEntitySet(resource);
-
-    if (resource.getPayload().getDeltaLink() != null) {
-      final URI base = resource.getContextURL() == null
-              ? resource.getPayload().getBaseURI()
-              : 
ContextURLParser.parse(resource.getContextURL()).getServiceRoot();
-      entitySet.setDeltaLink(URIUtils.getURI(base, 
resource.getPayload().getDeltaLink()));
-    }
-    odataAnnotations(resource.getPayload(), entitySet);
-
-    return entitySet;
-  }
-
-  @Override
-  protected void odataNavigationLinks(final EdmType edmType,
-          final Linked linked, final ODataLinked odataLinked, final String 
metadataETag, final URI base) {
-
-    super.odataNavigationLinks(edmType, linked, odataLinked, metadataETag, 
base);
-    for (org.apache.olingo.commons.api.domain.ODataLink link : 
odataLinked.getNavigationLinks()) {
-      if (!(link instanceof ODataInlineEntity) && !(link instanceof 
ODataInlineEntitySet)) {
-        odataAnnotations(linked.getNavigationLink(link.getName()), 
(ODataAnnotatable) link);
-      }
-    }
-  }
-
-  @Override
-  public ODataEntity getODataEntity(final ResWrap<Entity> resource) {
-    final ODataEntity entity = (ODataEntity) super.getODataEntity(resource);
-
-    entity.setId(resource.getPayload().getId());
-    odataAnnotations(resource.getPayload(), entity);
-
-    return entity;
-  }
-
-  @Override
-  public ODataProperty getODataProperty(final ResWrap<Property> resource) {
-    final Property payload = resource.getPayload();
-    final EdmTypeInfo typeInfo = 
buildTypeInfo(ContextURLParser.parse(resource.getContextURL()),
-            resource.getMetadataETag(), payload.getName(), payload.getType());
-
-    final ODataProperty property = new ODataPropertyImpl(payload.getName(),
-            getODataValue(typeInfo == null ? null : 
typeInfo.getFullQualifiedName(),
-                    payload, resource.getContextURL(), 
resource.getMetadataETag()));
-    odataAnnotations(payload, property);
-
-    return property;
-  }
-
-  @Override
-  protected ODataProperty getODataProperty(final EdmType type, final Property 
resource) {
-    final EdmTypeInfo typeInfo = buildTypeInfo(type == null ? null : 
type.getFullQualifiedName(), resource.getType());
-
-    final ODataProperty property = new ODataPropertyImpl(resource.getName(),
-            getODataValue(typeInfo == null ? null : 
typeInfo.getFullQualifiedName(),
-                    resource, null, null));
-    odataAnnotations(resource, property);
-
-    return property;
-  }
-
-  @Override
-  protected ODataValue getODataValue(final FullQualifiedName type,
-          final Valuable valuable, final URI contextURL, final String 
metadataETag) {
-
-    // fixes enum values treated as primitive when no type information is 
available
-    if (client instanceof EdmEnabledODataClient && type != null) {
-      final EdmEnumType edmType = ((EdmEnabledODataClient) 
client).getEdm(metadataETag).getEnumType(type);
-      if (valuable.isPrimitive() && edmType != null) {
-        valuable.setValue(ValueType.ENUM, valuable.asPrimitive());
-      }
-    }
-
-    ODataValue value;
-    if (valuable.isEnum()) {
-      value = ((ODataClient) client).getObjectFactory().newEnumValue(type == 
null ? null : type.toString(),
-              valuable.asEnum().toString());
-    } else if (valuable.isLinkedComplex()) {
-      final ODataLinkedComplexValue lcValue =
-              ((ODataClient) 
client).getObjectFactory().newLinkedComplexValue(type == null ? null : 
type.toString());
-
-      EdmComplexType edmType = null;
-      if (client instanceof EdmEnabledODataClient && type != null) {
-        edmType = ((EdmEnabledODataClient) 
client).getEdm(metadataETag).getComplexType(type);
-      }
-
-      for (Property property : valuable.asLinkedComplex().getValue()) {
-        EdmType edmPropertyType = null;
-        if (edmType != null) {
-          final EdmElement edmProp = edmType.getProperty(property.getName());
-          if (edmProp != null) {
-            edmPropertyType = edmProp.getType();
-          }
-        }
-        lcValue.add(getODataProperty(edmPropertyType, property));
-      }
-
-      odataNavigationLinks(edmType, valuable.asLinkedComplex(), lcValue, 
metadataETag, contextURL);
-      odataAnnotations(valuable.asLinkedComplex(), lcValue);
-
-      value = lcValue;
-    } else {
-      value = super.getODataValue(type, valuable, contextURL, metadataETag);
-    }
-
-    return value;
-  }
-
-  @Override
-  public ODataDelta getODataDelta(final ResWrap<Delta> resource) {
-    final URI base = resource.getContextURL() == null
-            ? resource.getPayload().getBaseURI()
-            : 
ContextURLParser.parse(resource.getContextURL()).getServiceRoot();
-
-    final URI next = resource.getPayload().getNext();
-
-    final ODataDelta delta = next == null
-            ? ((ODataClient) client).getObjectFactory().newDelta()
-            : ((ODataClient) 
client).getObjectFactory().newDelta(URIUtils.getURI(base, 
next.toASCIIString()));
-
-    if (resource.getPayload().getCount() != null) {
-      delta.setCount(resource.getPayload().getCount());
-    }
-
-    if (resource.getPayload().getDeltaLink() != null) {
-      delta.setDeltaLink(URIUtils.getURI(base, 
resource.getPayload().getDeltaLink()));
-    }
-
-    for (Entity entityResource : resource.getPayload().getEntities()) {
-      add(delta, getODataEntity(
-              new ResWrap<Entity>(resource.getContextURL(), 
resource.getMetadataETag(), entityResource)));
-    }
-    for (DeletedEntity deletedEntity : 
resource.getPayload().getDeletedEntities()) {
-      final ODataDeletedEntityImpl impl = new ODataDeletedEntityImpl();
-      impl.setId(URIUtils.getURI(base, deletedEntity.getId()));
-      impl.setReason(Reason.valueOf(deletedEntity.getReason().name()));
-
-      delta.getDeletedEntities().add(impl);
-    }
-
-    odataAnnotations(resource.getPayload(), delta);
-
-    for (DeltaLink link : resource.getPayload().getAddedLinks()) {
-      final ODataDeltaLink impl = new ODataDeltaLinkImpl();
-      impl.setRelationship(link.getRelationship());
-      impl.setSource(URIUtils.getURI(base, link.getSource()));
-      impl.setTarget(URIUtils.getURI(base, link.getTarget()));
-
-      odataAnnotations(link, impl);
-
-      delta.getAddedLinks().add(impl);
-    }
-    for (DeltaLink link : resource.getPayload().getDeletedLinks()) {
-      final ODataDeltaLink impl = new ODataDeltaLinkImpl();
-      impl.setRelationship(link.getRelationship());
-      impl.setSource(URIUtils.getURI(base, link.getSource()));
-      impl.setTarget(URIUtils.getURI(base, link.getTarget()));
-
-      odataAnnotations(link, impl);
-
-      delta.getDeletedLinks().add(impl);
-    }
-
-    return delta;
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
deleted file mode 100644
index 30f4cb0..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataDeserializerImpl.java
+++ /dev/null
@@ -1,79 +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.client.core.serialization.v4;
-
-import java.io.InputStream;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.olingo.client.api.data.ServiceDocument;
-import org.apache.olingo.client.api.edm.xml.v4.XMLMetadata;
-import org.apache.olingo.client.api.serialization.v4.ODataDeserializer;
-import org.apache.olingo.client.core.data.JSONServiceDocumentDeserializer;
-import org.apache.olingo.client.core.data.XMLServiceDocumentDeserializer;
-import org.apache.olingo.client.core.edm.xml.v4.EdmxImpl;
-import org.apache.olingo.client.core.edm.xml.v4.XMLMetadataImpl;
-import org.apache.olingo.client.core.serialization.AbstractODataDeserializer;
-import org.apache.olingo.commons.api.data.Delta;
-import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-import org.apache.olingo.commons.core.serialization.AtomDeserializer;
-import org.apache.olingo.commons.core.serialization.JsonDeltaDeserializer;
-
-public class ODataDeserializerImpl extends AbstractODataDeserializer 
implements ODataDeserializer {
-
-  private final ODataFormat format;
-
-  public ODataDeserializerImpl(final ODataServiceVersion version, final 
boolean serverMode, final ODataFormat format) {
-    super(version, serverMode, format);
-    this.format = format;
-  }
-
-  @Override
-  public XMLMetadata toMetadata(final InputStream input) {
-    try {
-      return new XMLMetadataImpl(getXmlMapper().readValue(input, 
EdmxImpl.class));
-    } catch (Exception e) {
-      throw new IllegalArgumentException("Could not parse as Edmx document", 
e);
-    }
-  }
-
-  @Override
-  public ResWrap<ServiceDocument> toServiceDocument(final InputStream input) 
throws ODataDeserializerException {
-    return format == ODataFormat.XML ?
-        new XMLServiceDocumentDeserializer(version, 
false).toServiceDocument(input) :
-        new JSONServiceDocumentDeserializer(version, 
false).toServiceDocument(input);
-  }
-
-  @Override
-  public ResWrap<Delta> toDelta(final InputStream input) throws 
ODataDeserializerException {
-    try {
-      return format == ODataFormat.ATOM ?
-          new AtomDeserializer(version).delta(input) :
-          new JsonDeltaDeserializer(version, false).toDelta(input);
-    } catch (XMLStreamException e) {
-      throw new ODataDeserializerException(e);
-    } catch (final EdmPrimitiveTypeException e) {
-      throw new ODataDeserializerException(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
deleted file mode 100644
index 795108b..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/v4/ODataReaderImpl.java
+++ /dev/null
@@ -1,55 +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.client.core.serialization.v4;
-
-import java.io.InputStream;
-
-import org.apache.olingo.client.api.serialization.v4.ODataReader;
-import org.apache.olingo.client.api.v4.ODataClient;
-import org.apache.olingo.client.core.serialization.AbstractODataReader;
-import org.apache.olingo.commons.api.domain.v4.ODataEntity;
-import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
-import org.apache.olingo.commons.api.domain.v4.ODataProperty;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
-
-public class ODataReaderImpl extends AbstractODataReader implements 
ODataReader {
-
-  public ODataReaderImpl(final ODataClient client) {
-    super(client);
-  }
-
-  @Override
-  public ODataEntitySet readEntitySet(final InputStream input, final 
ODataFormat format)
-      throws ODataDeserializerException {
-    return ((ODataClient) 
client).getBinder().getODataEntitySet(client.getDeserializer(format).toEntitySet(input));
-  }
-
-  @Override
-  public ODataEntity readEntity(final InputStream input, final ODataFormat 
format)
-      throws ODataDeserializerException {
-    return ((ODataClient) 
client).getBinder().getODataEntity(client.getDeserializer(format).toEntity(input));
-  }
-
-  @Override
-  public ODataProperty readProperty(final InputStream input, final ODataFormat 
format)
-      throws ODataDeserializerException {
-    return ((ODataClient) 
client).getBinder().getODataProperty(client.getDeserializer(format).toProperty(input));
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterArgFactoryImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterArgFactoryImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterArgFactoryImpl.java
new file mode 100644
index 0000000..be828b3
--- /dev/null
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterArgFactoryImpl.java
@@ -0,0 +1,112 @@
+/*
+ * 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.client.core.uri;
+
+import org.apache.olingo.client.api.uri.FilterArg;
+import org.apache.olingo.client.api.uri.FilterArgFactory;
+import org.apache.olingo.client.api.uri.URIFilter;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public class FilterArgFactoryImpl extends AbstractFilterArgFactory implements 
FilterArgFactory {
+
+  public FilterArgFactoryImpl(final ODataServiceVersion version) {
+    super(version);
+  }
+
+  @Override
+  public FilterArg contains(final FilterArg first, final FilterArg second) {
+    return new FilterFunction("contains", first, second);
+  }
+
+  @Override
+  public FilterArg fractionalseconds(final FilterArg param) {
+    return new FilterFunction("fractionalseconds", param);
+  }
+
+  @Override
+  public FilterArg date(final FilterArg param) {
+    return new FilterFunction("date", param);
+  }
+
+  @Override
+  public FilterArg time(final FilterArg param) {
+    return new FilterFunction("time", param);
+  }
+
+  @Override
+  public FilterArg totaloffsetminutes(final FilterArg param) {
+    return new FilterFunction("totaloffsetminutes", param);
+  }
+
+  @Override
+  public FilterArg now() {
+    return new FilterFunction("now");
+  }
+
+  @Override
+  public FilterArg mindatetime() {
+    return new FilterFunction("mindatetime");
+  }
+
+  @Override
+  public FilterArg maxdatetime() {
+    return new FilterFunction("maxdatetime");
+  }
+
+  @Override
+  public FilterArg totalseconds(final FilterArg param) {
+    return new FilterFunction("totalseconds", param);
+  }
+
+  @Override
+  public FilterArg cast(final FilterArg type) {
+    return new FilterFunction("cast", type);
+  }
+
+  @Override
+  public FilterArg cast(final FilterArg expression, final FilterArg type) {
+    return new FilterFunction("cast", expression, type);
+  }
+
+  @Override
+  public FilterArg geoDistance(final FilterArg first, final FilterArg second) {
+    return new FilterFunction("geo.distance", first, second);
+  }
+
+  @Override
+  public FilterArg geoIntersects(final FilterArg first, final FilterArg 
second) {
+    return new FilterFunction("geo.intersects", first, second);
+  }
+
+  @Override
+  public FilterArg geoLength(final FilterArg first, final FilterArg second) {
+    return new FilterFunction("geo.length", first, second);
+  }
+
+  @Override
+  public FilterArg any(final FilterArg collection, final URIFilter expression) 
{
+    return new FilterLambda(collection, "any", expression);
+  }
+
+  @Override
+  public FilterArg all(final FilterArg collection, final URIFilter expression) 
{
+    return new FilterLambda(collection, "all", expression);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterFactoryImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterFactoryImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterFactoryImpl.java
new file mode 100644
index 0000000..5e9d24d
--- /dev/null
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterFactoryImpl.java
@@ -0,0 +1,49 @@
+/*
+ * 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.client.core.uri;
+
+import org.apache.olingo.client.api.uri.FilterArg;
+import org.apache.olingo.client.api.uri.FilterArgFactory;
+import org.apache.olingo.client.api.uri.FilterFactory;
+import org.apache.olingo.client.api.uri.URIFilter;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public class FilterFactoryImpl extends AbstractFilterFactory implements 
FilterFactory {
+
+  public FilterFactoryImpl(ODataServiceVersion version) {
+    super(version);
+  }
+
+  @Override
+  public FilterArgFactory getArgFactory() {
+    return new FilterArgFactoryImpl(version);
+  }
+
+  @Override
+  public URIFilter has(final String key, final EdmEnumType enumType, final 
String memberName) {
+    return has(getArgFactory().property(key), enumType, memberName);
+  }
+
+  @Override
+  public URIFilter has(final FilterArg left, final EdmEnumType enumType, final 
String memberName) {
+    return new HasFilter(left, new 
FilterProperty(enumType.toUriLiteral(memberName)));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIBuilderImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIBuilderImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIBuilderImpl.java
new file mode 100644
index 0000000..0955cac
--- /dev/null
+++ 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIBuilderImpl.java
@@ -0,0 +1,144 @@
+/*
+ * 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.client.core.uri;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.olingo.client.api.Configuration;
+import org.apache.olingo.client.api.uri.QueryOption;
+import org.apache.olingo.client.api.uri.SegmentType;
+import org.apache.olingo.client.api.uri.URIBuilder;
+import org.apache.olingo.client.api.uri.URISearch;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public class URIBuilderImpl extends AbstractURIBuilder<URIBuilder> implements 
URIBuilder {
+
+  public URIBuilderImpl(
+      final ODataServiceVersion version, final Configuration configuration, 
final String serviceRoot) {
+    super(version, configuration, serviceRoot);
+  }
+
+  @Override
+  public URIBuilder appendKeySegment(final EdmEnumType enumType, final String 
memberName) {
+    return appendKeySegment(enumType.toUriLiteral(memberName));
+  }
+
+  @Override
+  public URIBuilder appendKeySegment(final Map<String, Pair<EdmEnumType, 
String>> enumValues,
+          final Map<String, Object> segmentValues) {
+
+    final Map<String, Object> values = new LinkedHashMap<String, Object>();
+    for (Map.Entry<String, Pair<EdmEnumType, String>> entry : 
enumValues.entrySet()) {
+      values.put(entry.getKey(), 
entry.getValue().getKey().toUriLiteral(entry.getValue().getValue()));
+    }
+    values.putAll(segmentValues);
+
+    return appendKeySegment(values);
+  }
+
+  @Override
+  protected URIBuilder getThis() {
+    return this;
+  }
+
+  @Override
+  protected String noKeysWrapper() {
+    return "()";
+  }
+
+  @Override
+  protected char getBoundOperationSeparator() {
+    return '.';
+  }
+
+  @Override
+  protected String getOperationInvokeMarker() {
+    return "()";
+  }
+
+  @Override
+  public URIBuilder appendSingletonSegment(final String segmentValue) {
+    segments.add(new Segment(SegmentType.SINGLETON, segmentValue));
+    return getThis();
+  }
+
+  @Override
+  public URIBuilder appendEntityIdSegment(final String segmentValue) {
+    segments.add(new Segment(SegmentType.ENTITY, null));
+    return addQueryOption(QueryOption.ID, segmentValue);
+  }
+
+  @Override
+  public URIBuilder appendRefSegment() {
+    segments.add(new Segment(SegmentType.REF, SegmentType.REF.getValue()));
+    return getThis();
+  }
+
+  @Override
+  public URIBuilder appendCrossjoinSegment(final String... segmentValues) {
+    final StringBuilder segValue = new 
StringBuilder(SegmentType.CROSS_JOIN.getValue()).
+            append('(').append(StringUtils.join(segmentValues, 
",")).append(')');
+    segments.add(new Segment(SegmentType.CROSS_JOIN, segValue.toString()));
+    return getThis();
+  }
+
+  @Override
+  public URIBuilder appendAllSegment() {
+    segments.add(new Segment(SegmentType.ALL, SegmentType.ALL.getValue()));
+    return getThis();
+  }
+
+  @Override
+  public URIBuilder id(final String idValue) {
+    return addQueryOption(QueryOption.ID, idValue);
+  }
+
+  @Override
+  public URIBuilder search(final URISearch search) {
+    return search(search.build());
+  }
+
+  @Override
+  public URIBuilder search(final String expression) {
+    return addQueryOption(QueryOption.SEARCH, expression);
+  }
+
+  @Override
+  public URIBuilder count(final boolean value) {
+    return addQueryOption(QueryOption.COUNT, Boolean.toString(value));
+  }
+
+  @Override
+  public URIBuilder expandWithOptions(final String expandItem, final 
Map<QueryOption, Object> options) {
+    final Map<String, Object> _options = new LinkedHashMap<String, Object>();
+    for (Map.Entry<QueryOption, Object> entry : options.entrySet()) {
+      _options.put("$" + entry.getKey().toString(), entry.getValue());
+    }
+    return expand(expandItem + buildMultiKeySegment(_options, false));
+  }
+
+  @Override
+  public URIBuilder expandWithSelect(final String expandItem, final String... 
selectItems) {
+    return expand(expandItem + "($select=" + StringUtils.join(selectItems, 
",") + ")");
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/109c33ba/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/FilterArgFactoryImpl.java
----------------------------------------------------------------------
diff --git 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/FilterArgFactoryImpl.java
 
b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/FilterArgFactoryImpl.java
deleted file mode 100644
index 15bb9e9..0000000
--- 
a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/v4/FilterArgFactoryImpl.java
+++ /dev/null
@@ -1,115 +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.client.core.uri.v4;
-
-import org.apache.olingo.client.api.uri.FilterArg;
-import org.apache.olingo.client.api.uri.URIFilter;
-import org.apache.olingo.client.api.uri.v4.FilterArgFactory;
-import org.apache.olingo.client.core.uri.AbstractFilterArgFactory;
-import org.apache.olingo.client.core.uri.FilterFunction;
-import org.apache.olingo.client.core.uri.FilterLambda;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-public class FilterArgFactoryImpl extends AbstractFilterArgFactory implements 
FilterArgFactory {
-
-  public FilterArgFactoryImpl(final ODataServiceVersion version) {
-    super(version);
-  }
-
-  @Override
-  public FilterArg contains(final FilterArg first, final FilterArg second) {
-    return new FilterFunction("contains", first, second);
-  }
-
-  @Override
-  public FilterArg fractionalseconds(final FilterArg param) {
-    return new FilterFunction("fractionalseconds", param);
-  }
-
-  @Override
-  public FilterArg date(final FilterArg param) {
-    return new FilterFunction("date", param);
-  }
-
-  @Override
-  public FilterArg time(final FilterArg param) {
-    return new FilterFunction("time", param);
-  }
-
-  @Override
-  public FilterArg totaloffsetminutes(final FilterArg param) {
-    return new FilterFunction("totaloffsetminutes", param);
-  }
-
-  @Override
-  public FilterArg now() {
-    return new FilterFunction("now");
-  }
-
-  @Override
-  public FilterArg mindatetime() {
-    return new FilterFunction("mindatetime");
-  }
-
-  @Override
-  public FilterArg maxdatetime() {
-    return new FilterFunction("maxdatetime");
-  }
-
-  @Override
-  public FilterArg totalseconds(final FilterArg param) {
-    return new FilterFunction("totalseconds", param);
-  }
-
-  @Override
-  public FilterArg cast(final FilterArg type) {
-    return new FilterFunction("cast", type);
-  }
-
-  @Override
-  public FilterArg cast(final FilterArg expression, final FilterArg type) {
-    return new FilterFunction("cast", expression, type);
-  }
-
-  @Override
-  public FilterArg geoDistance(final FilterArg first, final FilterArg second) {
-    return new FilterFunction("geo.distance", first, second);
-  }
-
-  @Override
-  public FilterArg geoIntersects(final FilterArg first, final FilterArg 
second) {
-    return new FilterFunction("geo.intersects", first, second);
-  }
-
-  @Override
-  public FilterArg geoLength(final FilterArg first, final FilterArg second) {
-    return new FilterFunction("geo.length", first, second);
-  }
-
-  @Override
-  public FilterArg any(final FilterArg collection, final URIFilter expression) 
{
-    return new FilterLambda(collection, "any", expression);
-  }
-
-  @Override
-  public FilterArg all(final FilterArg collection, final URIFilter expression) 
{
-    return new FilterLambda(collection, "all", expression);
-  }
-
-}

Reply via email to