You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/03/10 10:02:51 UTC

[35/51] [abbrv] [partial] [OLINGO-192] rename java packages

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java
new file mode 100644
index 0000000..d6ade11
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java
@@ -0,0 +1,582 @@
+/*
+ * 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.op.impl;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.ODataConstants;
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.data.ServiceDocumentItem;
+import org.apache.olingo.client.api.domain.ODataServiceDocument;
+import org.apache.olingo.client.api.op.ODataBinder;
+import org.apache.olingo.client.api.utils.XMLUtils;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public abstract class AbstractODataBinder implements ODataBinder {
+
+  private static final long serialVersionUID = 454285889193689536L;
+
+  /**
+   * Logger.
+   */
+  protected final Logger LOG = LoggerFactory.getLogger(AbstractODataBinder.class);
+
+  protected final ODataClient client;
+
+  protected AbstractODataBinder(final ODataClient client) {
+    this.client = client;
+  }
+
+  protected Element newEntryContent() {
+    Element properties = null;
+    try {
+      final DocumentBuilder builder = XMLUtils.DOC_BUILDER_FACTORY.newDocumentBuilder();
+      final Document doc = builder.newDocument();
+      properties = doc.createElement(ODataConstants.ELEM_PROPERTIES);
+      properties.setAttribute(ODataConstants.XMLNS_METADATA,
+              client.getServiceVersion().getNamespaceMap().get(ODataServiceVersion.NS_METADATA));
+      properties.setAttribute(ODataConstants.XMLNS_DATASERVICES,
+              client.getServiceVersion().getNamespaceMap().get(ODataServiceVersion.NS_DATASERVICES));
+      properties.setAttribute(ODataConstants.XMLNS_GML, ODataConstants.NS_GML);
+      properties.setAttribute(ODataConstants.XMLNS_GEORSS, ODataConstants.NS_GEORSS);
+    } catch (ParserConfigurationException e) {
+      LOG.error("Failure building entry content", e);
+    }
+
+    return properties;
+  }
+
+  @Override
+  public ODataServiceDocument getODataServiceDocument(final ServiceDocument resource) {
+    final ODataServiceDocument serviceDocument = new ODataServiceDocument();
+
+    for (ServiceDocumentItem entitySet : resource.getEntitySets()) {
+      // handles V3 JSON format oddities, where title is not contained
+      serviceDocument.getEntitySets().put(StringUtils.isBlank(entitySet.getTitle())
+              ? entitySet.getName() : entitySet.getTitle(),
+              URIUtils.getURI(resource.getBaseURI(), entitySet.getHref()));
+    }
+
+    return serviceDocument;
+  }
+
+//  @Override
+//  public <T extends Feed> T getFeed(final ODataEntitySet feed, final Class<T> reference) {
+//    final T feedResource = ResourceFactory.newFeed(reference);
+//
+//    final List<Entry> entries = new ArrayList<Entry>();
+//    feedResource.setEntries(entries);
+//
+//    final URI next = feed.getNext();
+//    if (next != null) {
+//      feedResource.setNext(next);
+//    }
+//
+//    for (ODataEntity entity : feed.getEntities()) {
+//      entries.add(getEntry(entity, ResourceFactory.entryClassForFeed(reference)));
+//    }
+//
+//    feedResource.setEntries(entries);
+//
+//    return feedResource;
+//  }
+//
+//  @Override
+//  public <T extends Entry> T getEntry(final ODataEntity entity, final Class<T> reference) {
+//    return getEntry(entity, reference, true);
+//  }
+//
+//  @Override
+//  @SuppressWarnings("unchecked")
+//  public <T extends Entry> T getEntry(final ODataEntity entity, final Class<T> reference,
+//          final boolean setType) {
+//
+//    final T entry = ResourceFactory.newEntry(reference);
+//    entry.setType(entity.getName());
+//
+//        // -------------------------------------------------------------
+//    // Add edit and self link
+//    // -------------------------------------------------------------
+//    final URI editLink = entity.getEditLink();
+//    if (editLink != null) {
+//      final Link entryEditLink = ResourceFactory.newLinkForEntry(reference);
+//      entryEditLink.setTitle(entity.getName());
+//      entryEditLink.setHref(editLink.toASCIIString());
+//      entryEditLink.setRel(ODataConstants.EDIT_LINK_REL);
+//      entry.setEditLink(entryEditLink);
+//    }
+//
+//    if (entity.isReadOnly()) {
+//      final Link entrySelfLink = ResourceFactory.newLinkForEntry(reference);
+//      entrySelfLink.setTitle(entity.getName());
+//      entrySelfLink.setHref(entity.getLink().toASCIIString());
+//      entrySelfLink.setRel(ODataConstants.SELF_LINK_REL);
+//      entry.setSelfLink(entrySelfLink);
+//    }
+//        // -------------------------------------------------------------
+//
+//        // -------------------------------------------------------------
+//    // Append navigation links (handling inline entry / feed as well)
+//    // -------------------------------------------------------------
+//    // handle navigation links
+//    for (ODataLink link : entity.getNavigationLinks()) {
+//      // append link 
+//      LOG.debug("Append navigation link\n{}", link);
+//      entry.addNavigationLink(getLinkResource(link, ResourceFactory.linkClassForEntry(reference)));
+//    }
+//        // -------------------------------------------------------------
+//
+//        // -------------------------------------------------------------
+//    // Append edit-media links
+//    // -------------------------------------------------------------
+//    for (ODataLink link : entity.getEditMediaLinks()) {
+//      LOG.debug("Append edit-media link\n{}", link);
+//      entry.addMediaEditLink(getLinkResource(link, ResourceFactory.linkClassForEntry(reference)));
+//    }
+//        // -------------------------------------------------------------
+//
+//        // -------------------------------------------------------------
+//    // Append association links
+//    // -------------------------------------------------------------
+//    for (ODataLink link : entity.getAssociationLinks()) {
+//      LOG.debug("Append association link\n{}", link);
+//      entry.addAssociationLink(getLinkResource(link, ResourceFactory.linkClassForEntry(reference)));
+//    }
+//    // -------------------------------------------------------------
+//
+//    final Element content = newEntryContent();
+//    if (entity.isMediaEntity()) {
+//      entry.setMediaEntryProperties(content);
+//      entry.setMediaContentSource(entity.getMediaContentSource());
+//      entry.setMediaContentType(entity.getMediaContentType());
+//    } else {
+//      entry.setContent(content);
+//    }
+//
+//    for (ODataProperty prop : entity.getProperties()) {
+//      content.appendChild(toDOMElement(prop, content.getOwnerDocument(), setType));
+//    }
+//
+//    return entry;
+//  }
+//
+//  @Override
+//  public Element toDOMElement(final ODataProperty prop) {
+//    try {
+//      return toDOMElement(prop, XMLUtils.DOC_BUILDER_FACTORY.newDocumentBuilder().newDocument(), true);
+//    } catch (ParserConfigurationException e) {
+//      LOG.error("Error retrieving property DOM", e);
+//      throw new IllegalArgumentException(e);
+//    }
+//  }
+//
+//  @Override
+//  public ODataLinkCollection getLinkCollection(final LinkCollection linkCollection) {
+//    final ODataLinkCollection collection = new ODataLinkCollection(linkCollection.getNext());
+//    collection.setLinks(linkCollection.getLinks());
+//    return collection;
+//  }
+//
+//  @Override
+//  public ODataEntitySet getODataEntitySet(final Feed resource) {
+//    return getODataEntitySet(resource, null);
+//  }
+//
+//  @Override
+//  public ODataEntitySet getODataEntitySet(final Feed resource, final URI defaultBaseURI) {
+//    if (LOG.isDebugEnabled()) {
+//      final StringWriter writer = new StringWriter();
+//      client.getSerializer().feed(resource, writer);
+//      writer.flush();
+//      LOG.debug("FeedResource -> ODataEntitySet:\n{}", writer.toString());
+//    }
+//
+//    final URI base = defaultBaseURI == null ? resource.getBaseURI() : defaultBaseURI;
+//
+//    final URI next = resource.getNext();
+//
+//    final ODataEntitySet entitySet = next == null
+//            ? client.getObjectFactory().newEntitySet()
+//            : client.getObjectFactory().newEntitySet(URIUtils.getURI(base, next.toASCIIString()));
+//
+//    if (resource.getCount() != null) {
+//      entitySet.setCount(resource.getCount());
+//    }
+//
+//    for (Entry entryResource : resource.getEntries()) {
+//      entitySet.addEntity(getODataEntity(entryResource));
+//    }
+//
+//    return entitySet;
+//  }
+//
+//  @Override
+//  public ODataEntity getODataEntity(final Entry resource) {
+//    return getODataEntity(resource, null);
+//  }
+//
+//  @Override
+//  public ODataEntity getODataEntity(final Entry resource, final URI defaultBaseURI) {
+//    if (LOG.isDebugEnabled()) {
+//      final StringWriter writer = new StringWriter();
+//      client.getSerializer().entry(resource, writer);
+//      writer.flush();
+//      LOG.debug("EntryResource -> ODataEntity:\n{}", writer.toString());
+//    }
+//
+//    final URI base = defaultBaseURI == null ? resource.getBaseURI() : defaultBaseURI;
+//
+//    final ODataEntity entity = resource.getSelfLink() == null
+//            ? client.getObjectFactory().newEntity(resource.getType())
+//            : client.getObjectFactory().newEntity(resource.getType(),
+//                    URIUtils.getURI(base, resource.getSelfLink().getHref()));
+//
+//    if (StringUtils.isNotBlank(resource.getETag())) {
+//      entity.setETag(resource.getETag());
+//    }
+//
+//    if (resource.getEditLink() != null) {
+//      entity.setEditLink(URIUtils.getURI(base, resource.getEditLink().getHref()));
+//    }
+//
+//    for (Link link : resource.getAssociationLinks()) {
+//      entity.addLink(client.getObjectFactory().newAssociationLink(link.getTitle(), base, link.getHref()));
+//    }
+//
+//    for (Link link : resource.getNavigationLinks()) {
+//      final Entry inlineEntry = link.getInlineEntry();
+//      final Feed inlineFeed = link.getInlineFeed();
+//
+//      if (inlineEntry == null && inlineFeed == null) {
+//        entity.addLink(
+//                client.getObjectFactory().newEntityNavigationLink(link.getTitle(), base, link.getHref()));
+//      } else if (inlineFeed == null) {
+//        entity.addLink(client.getObjectFactory().newInlineEntity(
+//                link.getTitle(), base, link.getHref(),
+//                getODataEntity(inlineEntry,
+//                        inlineEntry.getBaseURI() == null ? base : inlineEntry.getBaseURI())));
+//      } else {
+//        entity.addLink(client.getObjectFactory().newInlineEntitySet(
+//                link.getTitle(), base, link.getHref(),
+//                getODataEntitySet(inlineFeed,
+//                        inlineFeed.getBaseURI() == null ? base : inlineFeed.getBaseURI())));
+//      }
+//    }
+//
+//    for (Link link : resource.getMediaEditLinks()) {
+//      entity.addLink(client.getObjectFactory().newMediaEditLink(link.getTitle(), base, link.getHref()));
+//    }
+//
+//    for (ODataOperation operation : resource.getOperations()) {
+//      operation.setTarget(URIUtils.getURI(base, operation.getTarget()));
+//      entity.addOperation(operation);
+//    }
+//
+//    final Element content;
+//    if (resource.isMediaEntry()) {
+//      entity.setMediaEntity(true);
+//      entity.setMediaContentSource(resource.getMediaContentSource());
+//      entity.setMediaContentType(resource.getMediaContentType());
+//      content = resource.getMediaEntryProperties();
+//    } else {
+//      content = resource.getContent();
+//    }
+//    if (content != null) {
+//      for (Node property : XMLUtils.getChildNodes(content, Node.ELEMENT_NODE)) {
+//        try {
+//          entity.addProperty(getProperty((Element) property));
+//        } catch (IllegalArgumentException e) {
+//          LOG.warn("Failure retrieving EdmType for {}", property.getTextContent(), e);
+//        }
+//      }
+//    }
+//
+//    return entity;
+//  }
+//
+//  @Override
+//  public <T extends Link> T getLinkResource(final ODataLink link, final Class<T> reference) {
+//    final T linkResource = ResourceFactory.newLink(reference);
+//    linkResource.setRel(link.getRel());
+//    linkResource.setTitle(link.getName());
+//    linkResource.setHref(link.getLink() == null ? null : link.getLink().toASCIIString());
+//    linkResource.setType(link.getType().toString());
+//
+//    if (link instanceof ODataInlineEntity) {
+//      // append inline entity
+//      final ODataEntity inlineEntity = ((ODataInlineEntity) link).getEntity();
+//      LOG.debug("Append in-line entity\n{}", inlineEntity);
+//
+//      linkResource.setInlineEntry(getEntry(inlineEntity, ResourceFactory.entryClassForLink(reference)));
+//    } else if (link instanceof ODataInlineEntitySet) {
+//      // append inline feed
+//      final ODataEntitySet InlineFeed = ((ODataInlineEntitySet) link).getEntitySet();
+//      LOG.debug("Append in-line feed\n{}", InlineFeed);
+//
+//      linkResource.setInlineFeed(getFeed(InlineFeed, ResourceFactory.feedClassForLink(reference)));
+//    }
+//
+//    return linkResource;
+//  }
+//
+//  @Override
+//  public ODataProperty getProperty(final Element property) {
+//    final ODataProperty res;
+//
+//    final Node nullNode = property.getAttributes().getNamedItem(ODataConstants.ATTR_NULL);
+//
+//    if (nullNode == null) {
+//      final EdmType edmType = StringUtils.isBlank(property.getAttribute(ODataConstants.ATTR_M_TYPE))
+//              ? null
+//              : newEdmType(property.getAttribute(ODataConstants.ATTR_M_TYPE));
+//
+//      final PropertyType propType = edmType == null
+//              ? guessPropertyType(property)
+//              : edmType.isCollection()
+//              ? PropertyType.COLLECTION
+//              : edmType.isSimpleType()
+//              ? PropertyType.PRIMITIVE
+//              : PropertyType.COMPLEX;
+//
+//      switch (propType) {
+//        case COLLECTION:
+//          res = fromCollectionPropertyElement(property, edmType);
+//          break;
+//
+//        case COMPLEX:
+//          res = fromComplexPropertyElement(property, edmType);
+//          break;
+//
+//        case PRIMITIVE:
+//          res = fromPrimitivePropertyElement(property, edmType);
+//          break;
+//
+//        case EMPTY:
+//        default:
+//          res = client.getObjectFactory().newPrimitiveProperty(XMLUtils.getSimpleName(property), null);
+//      }
+//    } else {
+//      res = client.getObjectFactory().newPrimitiveProperty(XMLUtils.getSimpleName(property), null);
+//    }
+//
+//    return res;
+//  }
+//
+//  protected PropertyType guessPropertyType(final Element property) {
+//    PropertyType res = null;
+//
+//    if (property.hasChildNodes()) {
+//      final NodeList children = property.getChildNodes();
+//
+//      for (int i = 0; res == null && i < children.getLength(); i++) {
+//        final Node child = children.item(i);
+//
+//        if (child.getNodeType() == Node.ELEMENT_NODE
+//                && !child.getNodeName().startsWith(ODataConstants.PREFIX_GML)) {
+//
+//          res = ODataConstants.ELEM_ELEMENT.equals(XMLUtils.getSimpleName(child))
+//                  ? PropertyType.COLLECTION
+//                  : PropertyType.COMPLEX;
+//        }
+//      }
+//    } else {
+//      res = PropertyType.EMPTY;
+//    }
+//
+//    if (res == null) {
+//      res = PropertyType.PRIMITIVE;
+//    }
+//
+//    return res;
+//  }
+//
+//  protected Element toDOMElement(final ODataProperty prop, final Document doc, final boolean setType) {
+//    final Element element;
+//
+//    if (prop.hasNullValue()) {
+//      // null property handling
+//      element = toNullPropertyElement(prop, doc);
+//    } else if (prop.hasPrimitiveValue()) {
+//      // primitive property handling
+//      element = toPrimitivePropertyElement(prop, doc, setType);
+//    } else if (prop.hasCollectionValue()) {
+//      // collection property handling
+//      element = toCollectionPropertyElement(prop, doc, setType);
+//    } else {
+//      // complex property handling
+//      element = toComplexPropertyElement(prop, doc, setType);
+//    }
+//
+//    element.setAttribute(ODataConstants.XMLNS_METADATA,
+//            client.getWorkingVersion().getNamespaceMap().get(ODataVersion.NS_METADATA));
+//    element.setAttribute(ODataConstants.XMLNS_DATASERVICES,
+//            client.getWorkingVersion().getNamespaceMap().get(ODataVersion.NS_DATASERVICES));
+//    element.setAttribute(ODataConstants.XMLNS_GML, ODataConstants.NS_GML);
+//    element.setAttribute(ODataConstants.XMLNS_GEORSS, ODataConstants.NS_GEORSS);
+//
+//    return element;
+//  }
+//
+//  protected Element toNullPropertyElement(final ODataProperty prop, final Document doc) {
+//    final Element element = doc.createElement(ODataConstants.PREFIX_DATASERVICES + prop.getName());
+//    element.setAttribute(ODataConstants.ATTR_NULL, Boolean.toString(true));
+//    return element;
+//  }
+//
+//  protected Element toPrimitivePropertyElement(
+//          final ODataProperty prop, final Document doc, final boolean setType) {
+//
+//    return toPrimitivePropertyElement(prop.getName(), prop.getPrimitiveValue(), doc, setType);
+//  }
+//
+//  protected Element toPrimitivePropertyElement(
+//          final String name, final ODataPrimitiveValue value, final Document doc, final boolean setType) {
+//
+//    final Element element = doc.createElement(ODataConstants.PREFIX_DATASERVICES + name);
+//    if (setType) {
+//      element.setAttribute(ODataConstants.ATTR_M_TYPE, value.getTypeName());
+//    }
+//
+//    if (value instanceof ODataGeospatialValue) {
+//      element.appendChild(doc.importNode(((ODataGeospatialValue) value).toTree(), true));
+//    } else {
+//      element.setTextContent(value.toString());
+//    }
+//
+//    return element;
+//  }
+//
+//  protected Element toCollectionPropertyElement(
+//          final ODataProperty prop, final Document doc, final boolean setType) {
+//
+//    if (!prop.hasCollectionValue()) {
+//      throw new IllegalArgumentException("Invalid property value type "
+//              + prop.getValue().getClass().getSimpleName());
+//    }
+//
+//    final ODataCollectionValue value = prop.getCollectionValue();
+//
+//    final Element element = doc.createElement(ODataConstants.PREFIX_DATASERVICES + prop.getName());
+//    if (value.getTypeName() != null && setType) {
+//      element.setAttribute(ODataConstants.ATTR_M_TYPE, value.getTypeName());
+//    }
+//
+//    for (ODataValue el : value) {
+//      if (el.isPrimitive()) {
+//        element.appendChild(
+//                toPrimitivePropertyElement(ODataConstants.ELEM_ELEMENT, el.asPrimitive(), doc, setType));
+//      } else {
+//        element.appendChild(
+//                toComplexPropertyElement(ODataConstants.ELEM_ELEMENT, el.asComplex(), doc, setType));
+//      }
+//    }
+//
+//    return element;
+//  }
+//
+//  protected Element toComplexPropertyElement(
+//          final ODataProperty prop, final Document doc, final boolean setType) {
+//
+//    return toComplexPropertyElement(prop.getName(), prop.getComplexValue(), doc, setType);
+//  }
+//
+//  protected Element toComplexPropertyElement(
+//          final String name, final ODataComplexValue value, final Document doc, final boolean setType) {
+//
+//    final Element element = doc.createElement(ODataConstants.PREFIX_DATASERVICES + name);
+//    if (value.getTypeName() != null && setType) {
+//      element.setAttribute(ODataConstants.ATTR_M_TYPE, value.getTypeName());
+//    }
+//
+//    for (ODataProperty field : value) {
+//      element.appendChild(toDOMElement(field, doc, true));
+//    }
+//    return element;
+//  }
+//
+//  protected ODataPrimitiveValue fromPrimitiveValueElement(final Element prop, final EdmType edmType) {
+//    final ODataPrimitiveValue value;
+//    if (edmType != null && edmType.getSimpleType().isGeospatial()) {
+//      final Element geoProp = ODataConstants.PREFIX_GML.equals(prop.getPrefix())
+//              ? prop : (Element) XMLUtils.getChildNodes(prop, Node.ELEMENT_NODE).get(0);
+//      value = client.getGeospatialValueBuilder().
+//              setType(edmType.getSimpleType()).setTree(geoProp).build();
+//    } else {
+//      value = client.getPrimitiveValueBuilder().
+//              setType(edmType == null ? null : edmType.getSimpleType()).setText(prop.getTextContent()).build();
+//    }
+//    return value;
+//  }
+//
+//  protected ODataProperty fromPrimitivePropertyElement(final Element prop, final EdmType edmType) {
+//    return client.getObjectFactory().newPrimitiveProperty(
+//            XMLUtils.getSimpleName(prop), fromPrimitiveValueElement(prop, edmType));
+//  }
+//
+//  protected ODataComplexValue fromComplexValueElement(final Element prop, final EdmType edmType) {
+//    final ODataComplexValue value = new ODataComplexValue(edmType == null ? null : edmType.getTypeExpression());
+//
+//    for (Node child : XMLUtils.getChildNodes(prop, Node.ELEMENT_NODE)) {
+//      value.add(getProperty((Element) child));
+//    }
+//
+//    return value;
+//  }
+//
+//  protected ODataProperty fromComplexPropertyElement(final Element prop, final EdmType edmType) {
+//    return client.getObjectFactory().newComplexProperty(XMLUtils.getSimpleName(prop),
+//            fromComplexValueElement(prop, edmType));
+//  }
+//
+//  protected ODataProperty fromCollectionPropertyElement(final Element prop, final EdmType edmType) {
+//    final ODataCollectionValue value
+//            = new ODataCollectionValue(edmType == null ? null : edmType.getTypeExpression());
+//
+//    final EdmType type = edmType == null ? null : newEdmType(edmType.getBaseType());
+//    final NodeList elements = prop.getChildNodes();
+//
+//    for (int i = 0; i < elements.getLength(); i++) {
+//      if (elements.item(i).getNodeType() != Node.TEXT_NODE) {
+//        final Element child = (Element) elements.item(i);
+//
+//        switch (guessPropertyType(child)) {
+//          case COMPLEX:
+//            value.add(fromComplexValueElement(child, type));
+//            break;
+//          case PRIMITIVE:
+//            value.add(fromPrimitiveValueElement(child, type));
+//            break;
+//          default:
+//          // do not add null or empty values
+//        }
+//      }
+//    }
+//
+//    return client.getObjectFactory().newCollectionProperty(XMLUtils.getSimpleName(prop), value);
+//  }
+//  protected abstract EdmType newEdmType(String expression);
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataDeserializer.java
new file mode 100644
index 0000000..2c7ff22
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataDeserializer.java
@@ -0,0 +1,178 @@
+/*
+ * 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.op.impl;
+
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.op.ODataDeserializer;
+import org.apache.olingo.client.core.xml.XMLParser;
+import org.w3c.dom.Element;
+
+public abstract class AbstractODataDeserializer extends AbstractJacksonTool implements ODataDeserializer {
+
+  private static final long serialVersionUID = -4244158979195609909L;
+
+//    private final AtomDeserializer atomDeserializer;
+  public AbstractODataDeserializer(final ODataClient client) {
+    super(client);
+//        this.atomDeserializer = new AtomDeserializer(client);
+  }
+
+//    @Override
+//    @SuppressWarnings("unchecked")
+//    public <T extends Feed> T toFeed(final InputStream input, final Class<T> reference) {
+//        T entry;
+//
+//        if (AtomFeed.class.equals(reference)) {
+//            entry = (T) toAtomFeed(input);
+//        } else {
+//            entry = (T) toJSONFeed(input);
+//        }
+//
+//        return entry;
+//    }
+//
+//    @Override
+//    @SuppressWarnings("unchecked")
+//    public <T extends Entry> T toEntry(final InputStream input, final Class<T> reference) {
+//        T entry;
+//
+//        if (AtomEntry.class.equals(reference)) {
+//            entry = (T) toAtomEntry(input);
+//
+//        } else {
+//            entry = (T) toJSONEntry(input);
+//        }
+//
+//        return entry;
+//    }
+//
+//    @Override
+//    public Element toPropertyDOM(final InputStream input, final ODataFormat format) {
+//        return format == ODataFormat.XML
+//                ? toPropertyDOMFromXML(input)
+//                : toPropertyDOMFromJSON(input);
+//    }
+//
+//    @Override
+//    public LinkCollection toLinkCollection(final InputStream input, final ODataFormat format) {
+//        return format == ODataFormat.XML
+//                ? toLinkCollectionFromXML(input)
+//                : toLinkCollectionFromJSON(input);
+//    }
+//
+//    @Override
+//    public ODataError toODataError(final InputStream input, final boolean isXML) {
+//        return isXML
+//                ? toODataErrorFromXML(input)
+//                : toODataErrorFromJSON(input);
+//    }
+//
+  @Override
+  public Element toDOM(final InputStream input) {
+    return XMLParser.PARSER.deserialize(input);
+  }
+//
+//    /*
+//     * ------------------ Protected methods ------------------
+//     */
+//    protected AtomFeed toAtomFeed(final InputStream input) {
+//        try {
+//            return atomDeserializer.feed(toDOM(input));
+//        } catch (Exception e) {
+//            throw new IllegalArgumentException("While deserializing Atom feed", e);
+//        }
+//    }
+//
+//    protected AtomEntry toAtomEntry(final InputStream input) {
+//        try {
+//            return atomDeserializer.entry(toDOM(input));
+//        } catch (Exception e) {
+//            throw new IllegalArgumentException("While deserializing Atom entry", e);
+//        }
+//    }
+//
+//    protected JSONFeed toJSONFeed(final InputStream input) {
+//        try {
+//            return getObjectMapper().readValue(input, JSONFeed.class);
+//        } catch (IOException e) {
+//            throw new IllegalArgumentException("While deserializing JSON feed", e);
+//        }
+//    }
+//
+//    protected abstract AbstractJSONEntry toJSONEntry(final InputStream input);
+//
+//    protected Element toPropertyDOMFromXML(final InputStream input) {
+//        return toDOM(input);
+//    }
+//
+//    protected Element toPropertyDOMFromJSON(final InputStream input) {
+//        try {
+//            return getObjectMapper().readValue(input, JSONProperty.class).getContent();
+//        } catch (IOException e) {
+//            throw new IllegalArgumentException("While deserializing JSON property", e);
+//        }
+//    }
+//
+//    protected XMLLinkCollection toLinkCollectionFromXML(final InputStream input) {
+//        final Element root = toDOM(input);
+//
+//        final NodeList uris = root.getOwnerDocument().getElementsByTagName(ODataConstants.ELEM_URI);
+//
+//        final List<URI> links = new ArrayList<URI>();
+//        for (int i = 0; i < uris.getLength(); i++) {
+//            links.add(URI.create(uris.item(i).getTextContent()));
+//        }
+//
+//        final NodeList next = root.getElementsByTagName(ODataConstants.NEXT_LINK_REL);
+//        final XMLLinkCollection linkCollection = next.getLength() > 0
+//                ? new XMLLinkCollection(URI.create(next.item(0).getTextContent()))
+//                : new XMLLinkCollection();
+//        linkCollection.setLinks(links);
+//
+//        return linkCollection;
+//    }
+//
+//    protected JSONLinkCollection toLinkCollectionFromJSON(final InputStream input) {
+//        try {
+//            return getObjectMapper().readValue(input, JSONLinkCollection.class);
+//        } catch (IOException e) {
+//            throw new IllegalArgumentException("While deserializing JSON $links", e);
+//        }
+//    }
+//
+//    protected XMLODataError toODataErrorFromXML(final InputStream input) {
+//        try {
+//            final XmlMapper xmlMapper = new XmlMapper(
+//                    new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
+//            return xmlMapper.readValue(input, XMLODataError.class);
+//        } catch (Exception e) {
+//            throw new IllegalArgumentException("While deserializing XML error", e);
+//        }
+//    }
+//
+//    protected JSONODataError toODataErrorFromJSON(final InputStream input) {
+//        try {
+//            return getObjectMapper().readValue(input, JSONODataErrorBundle.class).getError();
+//        } catch (IOException e) {
+//            throw new IllegalArgumentException("While deserializing JSON error", e);
+//        }
+//    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataReader.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataReader.java
new file mode 100644
index 0000000..6cf19a3
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataReader.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.op.impl;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.op.ODataReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractODataReader implements ODataReader {
+
+  private static final long serialVersionUID = -1988865870981207079L;
+
+  /**
+   * Logger.
+   */
+  protected static final Logger LOG = LoggerFactory.getLogger(AbstractODataReader.class);
+
+  protected final ODataClient client;
+
+  protected AbstractODataReader(final ODataClient client) {
+    this.client = client;
+  }
+
+//    @Override
+//    public ODataEntitySet readEntitySet(final InputStream input, final ODataPubFormat format) {
+//        return client.getBinder().getODataEntitySet(
+//                client.getDeserializer().toFeed(input, ResourceFactory.feedClassForFormat(format)));
+//    }
+//
+//    @Override
+//    public ODataEntity readEntity(final InputStream input, final ODataPubFormat format) {
+//        return client.getBinder().getODataEntity(
+//                client.getDeserializer().toEntry(input, ResourceFactory.entryClassForFormat(format)));
+//    }
+//
+//    @Override
+//    public ODataProperty readProperty(final InputStream input, final ODataFormat format) {
+//        final Element property = client.getDeserializer().toPropertyDOM(input, format);
+//
+//        // The ODataProperty object is used either for actual entity properties and for invoke result 
+//         // (when return type is neither an entity nor a collection of entities).
+//        // Such formats are mostly the same except for collections: an entity property looks like
+//        //     <aproperty m:type="Collection(AType)">
+//        //       <element>....</element>
+//        //     </aproperty>
+//        //
+//        // while an invoke result with returnType="Collection(AnotherType)" looks like
+//        //     <functionImportName>
+//        //       <element m:type="AnotherType">...</element>
+//        //     <functionImportName>
+//        //
+//        // The code below is meant for "normalizing" the latter into
+//        //     <functionImportName m:type="Collection(AnotherType)">
+//        //       <element m:type="AnotherType">...</element>
+//        //     <functionImportName>
+//        final String type = property.getAttribute(ODataConstants.ATTR_M_TYPE);
+//        final NodeList elements = property.getElementsByTagName(ODataConstants.ELEM_ELEMENT);
+//        if (StringUtils.isBlank(type) && elements != null && elements.getLength() > 0) {
+//            final Node elementType = elements.item(0).getAttributes().getNamedItem(ODataConstants.ATTR_M_TYPE);
+//            if (elementType != null) {
+//                property.setAttribute(ODataConstants.ATTR_M_TYPE, "Collection(" + elementType.getTextContent() + ")");
+//            }
+//        }
+//
+//        return client.getBinder().getProperty(property);
+//    }
+//
+//    @Override
+//    public ODataLinkCollection readLinks(final InputStream input, final ODataFormat format) {
+//        return client.getBinder().getLinkCollection(
+//                client.getDeserializer().toLinkCollection(input, format));
+//    }
+//
+//  @Override
+//  public ODataError readError(final InputStream inputStream, final boolean isXML) {
+//    return client.getDeserializer().toODataError(inputStream, isXML);
+//  }
+//
+//    @Override
+//    @SuppressWarnings("unchecked")
+//    public <T> T read(final InputStream src, final String format, final Class<T> reference) {
+//        Object res;
+//
+//        try {
+//            if (ODataEntitySetIterator.class.isAssignableFrom(reference)) {
+//                res = new ODataEntitySetIterator(client, src, ODataPubFormat.fromString(format));
+//            } else if (ODataEntitySet.class.isAssignableFrom(reference)) {
+//                res = readEntitySet(src, ODataPubFormat.fromString(format));
+//            } else if (ODataEntity.class.isAssignableFrom(reference)) {
+//                res = readEntity(src, ODataPubFormat.fromString(format));
+//            } else if (ODataProperty.class.isAssignableFrom(reference)) {
+//                res = readProperty(src, ODataFormat.fromString(format));
+//            } else if (ODataLinkCollection.class.isAssignableFrom(reference)) {
+//                res = readLinks(src, ODataFormat.fromString(format));
+//            } else if (ODataValue.class.isAssignableFrom(reference)) {
+//                res = client.getPrimitiveValueBuilder().
+//                        setType(ODataValueFormat.fromString(format) == ODataValueFormat.TEXT
+//                                ? EdmSimpleType.String : EdmSimpleType.Stream).
+//                        setText(IOUtils.toString(src)).
+//                        build();
+//            } else if (AbstractEdmMetadata.class.isAssignableFrom(reference)) {
+//                res = readMetadata(src);
+//            } else if (ODataServiceDocument.class.isAssignableFrom(reference)) {
+//                res = readServiceDocument(src, ODataFormat.fromString(format));
+//            } else if (ODataError.class.isAssignableFrom(reference)) {
+//                res = readError(src, !format.toString().contains("json"));
+//            } else {
+//                throw new IllegalArgumentException("Invalid reference type " + reference);
+//            }
+//        } catch (Exception e) {
+//            LOG.warn("Cast error", e);
+//            res = null;
+//        } finally {
+//            if (!ODataEntitySetIterator.class.isAssignableFrom(reference)) {
+//                IOUtils.closeQuietly(src);
+//            }
+//        }
+//
+//        return (T) res;
+//    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataSerializer.java
new file mode 100644
index 0000000..d60ff19
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataSerializer.java
@@ -0,0 +1,161 @@
+/*
+ * 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.op.impl;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.op.ODataSerializer;
+import org.apache.olingo.client.core.xml.XMLParser;
+import org.w3c.dom.Node;
+
+public abstract class AbstractODataSerializer extends AbstractJacksonTool implements ODataSerializer {
+
+  private static final long serialVersionUID = -357777648541325363L;
+
+//    private final AtomSerializer atomSerializer;
+  public AbstractODataSerializer(final ODataClient client) {
+    super(client);
+//        this.atomSerializer = new AtomSerializer(client);
+  }
+
+//    @Override
+//    public <T extends Feed> void feed(final T obj, final OutputStream out) {
+//        feed(obj, new OutputStreamWriter(out));
+//    }
+//
+//    @Override
+//    public <T extends Feed> void feed(final T obj, final Writer writer) {
+//        if (obj instanceof AtomFeed) {
+//            atom((AtomFeed) obj, writer);
+//        } else {
+//            json((JSONFeed) obj, writer);
+//        }
+//    }
+//
+//    @Override
+//    public <T extends Entry> void entry(final T obj, final OutputStream out) {
+//        entry(obj, new OutputStreamWriter(out));
+//    }
+//
+//    @Override
+//    public <T extends Entry> void entry(final T obj, final Writer writer) {
+//        if (obj instanceof AtomEntry) {
+//            atom((AtomEntry) obj, writer);
+//        } else {
+//            json((JSONEntry) obj, writer);
+//        }
+//    }
+//
+//    @Override
+//    public void property(final Element element, final ODataFormat format, final OutputStream out) {
+//        property(element, format, new OutputStreamWriter(out));
+//    }
+//
+//    @Override
+//    public void property(final Element element, final ODataFormat format, final Writer writer) {
+//        if (format == ODataFormat.XML) {
+//            dom(element, writer);
+//        } else {
+//            json(element, writer);
+//        }
+//    }
+//
+//    @Override
+//    public void link(final ODataLink link, final ODataFormat format, final OutputStream out) {
+//        link(link, format, new OutputStreamWriter(out));
+//    }
+//
+//    @Override
+//    public void link(final ODataLink link, final ODataFormat format, final Writer writer) {
+//        if (format == ODataFormat.XML) {
+//            xmlLink(link, writer);
+//        } else {
+//            jsonLink(link, writer);
+//        }
+//    }
+//
+  @Override
+  public void dom(final Node content, final OutputStream out) {
+    dom(content, new OutputStreamWriter(out));
+  }
+
+  @Override
+  public void dom(final Node content, final Writer writer) {
+    XMLParser.PARSER.serialize(content, writer);
+  }
+//
+//    /*
+//     * ------------------ Protected methods ------------------
+//     */
+//    protected <T extends AbstractPayloadObject> void atom(final T obj, final Writer writer) {
+//        try {
+//            dom(atomSerializer.serialize(obj), writer);
+//        } catch (Exception e) {
+//            throw new IllegalArgumentException("While serializing Atom object", e);
+//        }
+//    }
+//
+//    protected <T extends AbstractPayloadObject> void json(final T obj, final Writer writer) {
+//        try {
+//            getObjectMapper().writeValue(writer, obj);
+//        } catch (IOException e) {
+//            throw new IllegalArgumentException("While serializing JSON object", e);
+//        }
+//    }
+//
+//    protected void json(final Element element, final Writer writer) {
+//        try {
+//            final JSONProperty property = new JSONProperty();
+//            property.setContent(element);
+//            getObjectMapper().writeValue(writer, property);
+//        } catch (IOException e) {
+//            throw new IllegalArgumentException("While serializing JSON property", e);
+//        }
+//    }
+//
+//    protected void xmlLink(final ODataLink link, final Writer writer) {
+//        try {
+//            final DocumentBuilder builder = XMLUtils.DOC_BUILDER_FACTORY.newDocumentBuilder();
+//            final Document doc = builder.newDocument();
+//            final Element uri = doc.createElementNS(
+//                    client.getWorkingVersion().getNamespaceMap().get(ODataVersion.NS_DATASERVICES),
+//                    ODataConstants.ELEM_URI);
+//            uri.appendChild(doc.createTextNode(link.getLink().toASCIIString()));
+//
+//            dom(uri, writer);
+//        } catch (Exception e) {
+//            throw new IllegalArgumentException("While serializing XML link", e);
+//        }
+//    }
+//
+//    protected void jsonLink(final ODataLink link, final Writer writer) {
+//        final ObjectMapper mapper = getObjectMapper();
+//        final ObjectNode uri = mapper.createObjectNode();
+//        uri.put(ODataConstants.JSON_URL, link.getLink().toASCIIString());
+//
+//        try {
+//            mapper.writeValue(writer, uri);
+//        } catch (Exception e) {
+//            throw new IllegalArgumentException("While serializing JSON link", e);
+//        }
+//    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ComplexTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ComplexTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ComplexTypeDeserializer.java
new file mode 100644
index 0000000..e07d907
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ComplexTypeDeserializer.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.client.core.edm.xml.AbstractComplexType;
+import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public class ComplexTypeDeserializer extends AbstractEdmDeserializer<AbstractComplexType> {
+
+  @Override
+  protected AbstractComplexType doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+          throws IOException, JsonProcessingException {
+
+    final AbstractComplexType complexType = ODataServiceVersion.V30 == client.getServiceVersion()
+            ? new org.apache.olingo.client.core.edm.xml.v3.ComplexTypeImpl()
+            : new org.apache.olingo.client.core.edm.xml.v4.ComplexTypeImpl();
+
+    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+      final JsonToken token = jp.getCurrentToken();
+      if (token == JsonToken.FIELD_NAME) {
+        if ("Name".equals(jp.getCurrentName())) {
+          complexType.setName(jp.nextTextValue());
+        } else if ("Abstract".equals(jp.getCurrentName())) {
+          ((org.apache.olingo.client.core.edm.xml.v4.ComplexTypeImpl) complexType).
+                  setAbstractEntityType(BooleanUtils.toBoolean(jp.nextTextValue()));
+        } else if ("BaseType".equals(jp.getCurrentName())) {
+          ((org.apache.olingo.client.core.edm.xml.v4.ComplexTypeImpl) complexType).
+                  setBaseType(jp.nextTextValue());
+        } else if ("OpenType".equals(jp.getCurrentName())) {
+          ((org.apache.olingo.client.core.edm.xml.v4.ComplexTypeImpl) complexType).
+                  setOpenType(BooleanUtils.toBoolean(jp.nextTextValue()));
+        } else if ("Property".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          if (complexType instanceof org.apache.olingo.client.core.edm.xml.v3.ComplexTypeImpl) {
+            ((org.apache.olingo.client.core.edm.xml.v3.ComplexTypeImpl) complexType).
+                    getProperties().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v3.PropertyImpl.class));
+          } else {
+            ((org.apache.olingo.client.core.edm.xml.v4.ComplexTypeImpl) complexType).
+                    getProperties().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v4.PropertyImpl.class));
+          }
+        } else if ("NavigationProperty".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          ((org.apache.olingo.client.core.edm.xml.v4.ComplexTypeImpl) complexType).
+                  getNavigationProperties().add(jp.readValueAs(
+                                  org.apache.olingo.client.core.edm.xml.v4.NavigationPropertyImpl.class));
+        } else if ("Annotation".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          ((org.apache.olingo.client.core.edm.xml.v4.ComplexTypeImpl) complexType).
+                  setAnnotation(jp.readValueAs(AnnotationImpl.class));
+        }
+      }
+    }
+
+    return complexType;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityContainerDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityContainerDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityContainerDeserializer.java
new file mode 100644
index 0000000..5269128
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityContainerDeserializer.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.client.core.edm.xml.AbstractEntityContainer;
+import org.apache.olingo.client.core.edm.xml.v3.AssociationSetImpl;
+import org.apache.olingo.client.core.edm.xml.v4.ActionImportImpl;
+import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl;
+import org.apache.olingo.client.core.edm.xml.v4.SingletonImpl;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+@SuppressWarnings("rawtypes")
+public class EntityContainerDeserializer extends AbstractEdmDeserializer<AbstractEntityContainer> {
+
+  @Override
+  protected AbstractEntityContainer doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+          throws IOException, JsonProcessingException {
+
+    final AbstractEntityContainer entityContainer = ODataServiceVersion.V30 == client.getServiceVersion()
+            ? new org.apache.olingo.client.core.edm.xml.v3.EntityContainerImpl()
+            : new org.apache.olingo.client.core.edm.xml.v4.EntityContainerImpl();
+
+    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+      final JsonToken token = jp.getCurrentToken();
+      if (token == JsonToken.FIELD_NAME) {
+        if ("Name".equals(jp.getCurrentName())) {
+          entityContainer.setName(jp.nextTextValue());
+        } else if ("Extends".equals(jp.getCurrentName())) {
+          entityContainer.setExtends(jp.nextTextValue());
+        } else if ("LazyLoadingEnabled".equals(jp.getCurrentName())) {
+          entityContainer.setLazyLoadingEnabled(BooleanUtils.toBoolean(jp.nextTextValue()));
+        } else if ("IsDefaultEntityContainer".equals(jp.getCurrentName())) {
+          entityContainer.setDefaultEntityContainer(BooleanUtils.toBoolean(jp.nextTextValue()));
+        } else if ("EntitySet".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          if (entityContainer instanceof org.apache.olingo.client.core.edm.xml.v3.EntityContainerImpl) {
+            ((org.apache.olingo.client.core.edm.xml.v3.EntityContainerImpl) entityContainer).
+                    getEntitySets().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v3.EntitySetImpl.class));
+          } else {
+            ((org.apache.olingo.client.core.edm.xml.v4.EntityContainerImpl) entityContainer).
+                    getEntitySets().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v4.EntitySetImpl.class));
+          }
+        } else if ("AssociationSet".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          ((org.apache.olingo.client.core.edm.xml.v3.EntityContainerImpl) entityContainer).
+                  getAssociationSets().add(jp.readValueAs(AssociationSetImpl.class));
+        } else if ("Singleton".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          ((org.apache.olingo.client.core.edm.xml.v4.EntityContainerImpl) entityContainer).
+                  getSingletons().add(jp.readValueAs(SingletonImpl.class));
+        } else if ("ActionImport".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          ((org.apache.olingo.client.core.edm.xml.v4.EntityContainerImpl) entityContainer).
+                  getActionImports().add(jp.readValueAs(ActionImportImpl.class));
+        } else if ("FunctionImport".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          if (entityContainer instanceof org.apache.olingo.client.core.edm.xml.v3.EntityContainerImpl) {
+            ((org.apache.olingo.client.core.edm.xml.v3.EntityContainerImpl) entityContainer).
+                    getFunctionImports().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v3.FunctionImportImpl.class));
+          } else {
+            ((org.apache.olingo.client.core.edm.xml.v4.EntityContainerImpl) entityContainer).
+                    getFunctionImports().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v4.FunctionImportImpl.class));
+          }
+        } else if ("Annotation".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          ((org.apache.olingo.client.core.edm.xml.v4.EntityContainerImpl) entityContainer).
+                  setAnnotation(jp.readValueAs(AnnotationImpl.class));
+        }
+      }
+    }
+
+    return entityContainer;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityKeyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityKeyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityKeyDeserializer.java
new file mode 100644
index 0000000..1f6b415
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityKeyDeserializer.java
@@ -0,0 +1,50 @@
+/*
+ * 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.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+
+import java.io.IOException;
+
+import org.apache.olingo.client.core.edm.xml.EntityKeyImpl;
+import org.apache.olingo.client.core.edm.xml.PropertyRefImpl;
+
+public class EntityKeyDeserializer extends AbstractEdmDeserializer<EntityKeyImpl> {
+
+  @Override
+  protected EntityKeyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+          throws IOException, JsonProcessingException {
+
+    final EntityKeyImpl entityKey = new EntityKeyImpl();
+
+    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+      final JsonToken token = jp.getCurrentToken();
+
+      if (token == JsonToken.FIELD_NAME && "PropertyRef".equals(jp.getCurrentName())) {
+        jp.nextToken();
+        entityKey.getPropertyRefs().add(jp.readValueAs( PropertyRefImpl.class));
+      }
+    }
+
+    return entityKey;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntitySetDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntitySetDeserializer.java
new file mode 100644
index 0000000..7dba1f6
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntitySetDeserializer.java
@@ -0,0 +1,70 @@
+/*
+ * 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.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.client.core.edm.xml.AbstractEntitySet;
+import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl;
+import org.apache.olingo.client.core.edm.xml.v4.NavigationPropertyBindingImpl;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public class EntitySetDeserializer extends AbstractEdmDeserializer<AbstractEntitySet> {
+
+  @Override
+  protected AbstractEntitySet doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+          throws IOException, JsonProcessingException {
+
+    final AbstractEntitySet entitySet = ODataServiceVersion.V30 == client.getServiceVersion()
+            ? new org.apache.olingo.client.core.edm.xml.v3.EntitySetImpl()
+            : new org.apache.olingo.client.core.edm.xml.v4.EntitySetImpl();
+
+    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+      final JsonToken token = jp.getCurrentToken();
+      if (token == JsonToken.FIELD_NAME) {
+        if ("Name".equals(jp.getCurrentName())) {
+          entitySet.setName(jp.nextTextValue());
+        } else if ("EntityType".equals(jp.getCurrentName())) {
+          entitySet.setEntityType(jp.nextTextValue());
+        } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) {
+          ((org.apache.olingo.client.core.edm.xml.v4.EntitySetImpl) entitySet).
+                  setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue()));
+        } else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          ((org.apache.olingo.client.core.edm.xml.v4.EntitySetImpl) entitySet).
+                  getNavigationPropertyBindings().add(
+                          jp.readValueAs(NavigationPropertyBindingImpl.class));
+        } else if ("Annotation".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          ((org.apache.olingo.client.core.edm.xml.v4.EntitySetImpl) entitySet).
+                  setAnnotation(jp.readValueAs(AnnotationImpl.class));
+        }
+      }
+    }
+
+    return entitySet;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityTypeDeserializer.java
new file mode 100644
index 0000000..a772b14
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EntityTypeDeserializer.java
@@ -0,0 +1,92 @@
+/*
+ * 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.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.client.core.edm.xml.AbstractEntityType;
+import org.apache.olingo.client.core.edm.xml.EntityKeyImpl;
+import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public class EntityTypeDeserializer extends AbstractEdmDeserializer<AbstractEntityType> {
+
+  @Override
+  protected AbstractEntityType doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+          throws IOException, JsonProcessingException {
+
+    final AbstractEntityType entityType = ODataServiceVersion.V30 == client.getServiceVersion()
+            ? new org.apache.olingo.client.core.edm.xml.v3.EntityTypeImpl()
+            : new org.apache.olingo.client.core.edm.xml.v4.EntityTypeImpl();
+
+    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+      final JsonToken token = jp.getCurrentToken();
+      if (token == JsonToken.FIELD_NAME) {
+        if ("Name".equals(jp.getCurrentName())) {
+          entityType.setName(jp.nextTextValue());
+        } else if ("Abstract".equals(jp.getCurrentName())) {
+          entityType.setAbstractEntityType(BooleanUtils.toBoolean(jp.nextTextValue()));
+        } else if ("BaseType".equals(jp.getCurrentName())) {
+          entityType.setBaseType(jp.nextTextValue());
+        } else if ("OpenType".equals(jp.getCurrentName())) {
+          entityType.setOpenType(BooleanUtils.toBoolean(jp.nextTextValue()));
+        } else if ("HasStream".equals(jp.getCurrentName())) {
+          entityType.setHasStream(BooleanUtils.toBoolean(jp.nextTextValue()));
+        } else if ("Key".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          entityType.setKey(jp.readValueAs(EntityKeyImpl.class));
+        } else if ("Property".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          if (entityType instanceof org.apache.olingo.client.core.edm.xml.v3.EntityTypeImpl) {
+            ((org.apache.olingo.client.core.edm.xml.v3.EntityTypeImpl) entityType).
+                    getProperties().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v3.PropertyImpl.class));
+          } else {
+            ((org.apache.olingo.client.core.edm.xml.v4.EntityTypeImpl) entityType).
+                    getProperties().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v4.PropertyImpl.class));
+          }
+        } else if ("NavigationProperty".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          if (entityType instanceof org.apache.olingo.client.core.edm.xml.v3.EntityTypeImpl) {
+            ((org.apache.olingo.client.core.edm.xml.v3.EntityTypeImpl) entityType).
+                    getNavigationProperties().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v3.NavigationPropertyImpl.class));
+          } else {
+            ((org.apache.olingo.client.core.edm.xml.v4.EntityTypeImpl) entityType).
+                    getNavigationProperties().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v4.NavigationPropertyImpl.class));
+          }
+        } else if ("Annotation".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          ((org.apache.olingo.client.core.edm.xml.v4.EntityTypeImpl) entityType).
+                  setAnnotation(jp.readValueAs(AnnotationImpl.class));
+        }
+      }
+    }
+
+    return entityType;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EnumTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EnumTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EnumTypeDeserializer.java
new file mode 100644
index 0000000..42d68ba
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/EnumTypeDeserializer.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.client.core.op.impl;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.olingo.client.core.edm.xml.AbstractEnumType;
+import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public class EnumTypeDeserializer extends AbstractEdmDeserializer<AbstractEnumType> {
+
+  @Override
+  protected AbstractEnumType doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
+          throws IOException, JsonProcessingException {
+
+    final AbstractEnumType enumType = ODataServiceVersion.V30 == client.getServiceVersion()
+            ? new org.apache.olingo.client.core.edm.xml.v3.EnumTypeImpl()
+            : new org.apache.olingo.client.core.edm.xml.v4.EnumTypeImpl();
+
+    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
+      final JsonToken token = jp.getCurrentToken();
+      if (token == JsonToken.FIELD_NAME) {
+        if ("Name".equals(jp.getCurrentName())) {
+          enumType.setName(jp.nextTextValue());
+        } else if ("UnderlyingType".equals(jp.getCurrentName())) {
+          enumType.setUnderlyingType(jp.nextTextValue());
+        } else if ("IsFlags".equals(jp.getCurrentName())) {
+          enumType.setFlags(BooleanUtils.toBoolean(jp.nextTextValue()));
+        } else if ("Member".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          if (enumType instanceof org.apache.olingo.client.core.edm.xml.v3.EnumTypeImpl) {
+            ((org.apache.olingo.client.core.edm.xml.v3.EnumTypeImpl) enumType).
+                    getMembers().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v3.MemberImpl.class));
+          } else {
+            ((org.apache.olingo.client.core.edm.xml.v4.EnumTypeImpl) enumType).
+                    getMembers().add(jp.readValueAs(
+                                    org.apache.olingo.client.core.edm.xml.v4.MemberImpl.class));
+          }
+        } else if ("Annotation".equals(jp.getCurrentName())) {
+          jp.nextToken();
+          ((org.apache.olingo.client.core.edm.xml.v4.EnumTypeImpl) enumType).
+                  setAnnotation(jp.readValueAs(AnnotationImpl.class));
+        }
+      }
+    }
+
+    return enumType;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/InjectableSerializerProvider.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/InjectableSerializerProvider.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/InjectableSerializerProvider.java
new file mode 100644
index 0000000..ec9fd29
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/InjectableSerializerProvider.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.op.impl;
+
+import com.fasterxml.jackson.databind.SerializationConfig;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
+import com.fasterxml.jackson.databind.ser.SerializerFactory;
+
+class InjectableSerializerProvider extends DefaultSerializerProvider {
+
+  private static final long serialVersionUID = 3432260063063739646L;
+
+  public InjectableSerializerProvider(
+          final SerializerProvider src, final SerializationConfig config, final SerializerFactory factory) {
+
+    super(src, config, factory);
+  }
+
+  @Override
+  public InjectableSerializerProvider createInstance(
+          final SerializationConfig config, final SerializerFactory factory) {
+
+    return this;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3BinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3BinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3BinderImpl.java
new file mode 100644
index 0000000..9196c9c
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3BinderImpl.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.op.impl;
+
+import org.apache.olingo.client.core.ODataV3ClientImpl;
+import org.apache.olingo.client.core.op.impl.AbstractODataBinder;
+
+public class ODataV3BinderImpl extends AbstractODataBinder {
+
+    private static final long serialVersionUID = 8970843539708952308L;
+
+    public ODataV3BinderImpl(final ODataV3ClientImpl client) {
+        super(client);
+    }
+
+//    @Override
+//    protected EdmType newEdmType(final String expression) {
+//        return new EdmV3Type(expression);
+//    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3DeserializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3DeserializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3DeserializerImpl.java
new file mode 100644
index 0000000..a5c6e95
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3DeserializerImpl.java
@@ -0,0 +1,70 @@
+/*
+ * 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.op.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.format.ODataFormat;
+import org.apache.olingo.client.api.op.ODataV3Deserializer;
+import org.apache.olingo.client.core.data.v3.JSONServiceDocumentImpl;
+import org.apache.olingo.client.core.data.v4.XMLServiceDocumentImpl;
+import org.apache.olingo.client.core.edm.xml.v3.EdmxImpl;
+import org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl;
+import org.apache.olingo.client.core.op.impl.AbstractODataDeserializer;
+
+public class ODataV3DeserializerImpl extends AbstractODataDeserializer implements ODataV3Deserializer {
+
+  private static final long serialVersionUID = -8221085862548914611L;
+
+  public ODataV3DeserializerImpl(final ODataClient client) {
+    super(client);
+  }
+
+  @Override
+  public XMLMetadataImpl 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 ServiceDocument toServiceDocument(final InputStream input, final ODataFormat format) {
+    try {
+      return format == ODataFormat.XML
+              ? getXmlMapper().readValue(input, XMLServiceDocumentImpl.class)
+              : getObjectMapper().readValue(input, JSONServiceDocumentImpl.class);
+    } catch (IOException e) {
+      throw new IllegalArgumentException("Could not parse Service Document", e);
+    }
+  }
+
+//    @Override
+//    protected JSONEntry toJSONEntry(final InputStream input) {
+//        try {
+//            return getObjectMapper().readValue(input, JSONEntry.class);
+//        } catch (IOException e) {
+//            throw new IllegalArgumentException("While deserializing JSON entry", e);
+//        }
+//    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3ReaderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3ReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3ReaderImpl.java
new file mode 100644
index 0000000..187bc41
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3ReaderImpl.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.op.impl;
+
+import java.io.InputStream;
+
+import org.apache.olingo.client.api.domain.ODataServiceDocument;
+import org.apache.olingo.client.api.format.ODataFormat;
+import org.apache.olingo.client.core.ODataV3ClientImpl;
+import org.apache.olingo.client.core.edm.EdmClientImpl;
+import org.apache.olingo.client.core.op.impl.AbstractODataReader;
+import org.apache.olingo.commons.api.edm.Edm;
+
+public class ODataV3ReaderImpl extends AbstractODataReader {
+
+  private static final long serialVersionUID = -2481293269536406956L;
+
+  public ODataV3ReaderImpl(final ODataV3ClientImpl client) {
+    super(client);
+  }
+
+  @Override
+  public Edm readMetadata(final InputStream input) {
+    return new EdmClientImpl(client.getDeserializer().toMetadata(input));
+  }
+
+  @Override
+  public ODataServiceDocument readServiceDocument(final InputStream input, final ODataFormat format) {
+    return ((ODataV3ClientImpl) client).getBinder().getODataServiceDocument(
+            ((ODataV3ClientImpl) client).getDeserializer().toServiceDocument(input, format));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3SerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3SerializerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3SerializerImpl.java
new file mode 100644
index 0000000..41f8567
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV3SerializerImpl.java
@@ -0,0 +1,32 @@
+/*
+ * 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.op.impl;
+
+import org.apache.olingo.client.api.ODataClient;
+import org.apache.olingo.client.core.op.impl.AbstractODataSerializer;
+
+public class ODataV3SerializerImpl extends AbstractODataSerializer {
+
+  private static final long serialVersionUID = -8861908250297989806L;
+
+  public ODataV3SerializerImpl(final ODataClient client) {
+    super(client);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/897db8ef/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV4BinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV4BinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV4BinderImpl.java
new file mode 100644
index 0000000..22a42ab
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/ODataV4BinderImpl.java
@@ -0,0 +1,62 @@
+/*
+ * 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.op.impl;
+
+import org.apache.olingo.client.api.data.ServiceDocument;
+import org.apache.olingo.client.api.data.ServiceDocumentItem;
+import org.apache.olingo.client.api.domain.ODataServiceDocument;
+import org.apache.olingo.client.core.ODataV4ClientImpl;
+import org.apache.olingo.client.core.op.impl.AbstractODataBinder;
+import org.apache.olingo.client.core.uri.URIUtils;
+
+public class ODataV4BinderImpl extends AbstractODataBinder {
+
+  private static final long serialVersionUID = -6371110655960799393L;
+
+  public ODataV4BinderImpl(final ODataV4ClientImpl client) {
+    super(client);
+  }
+
+//    @Override
+//    protected EdmType newEdmType(final String expression) {
+//        return new EdmV4Type(expression);
+//    }
+  @Override
+  public ODataServiceDocument getODataServiceDocument(final ServiceDocument resource) {
+    final ODataServiceDocument serviceDocument = super.getODataServiceDocument(resource);
+
+    serviceDocument.setMetadataContext(URIUtils.getURI(resource.getBaseURI(), resource.getMetadataContext()));
+    serviceDocument.setMetadataETag(resource.getMetadataETag());
+
+    for (ServiceDocumentItem functionImport : resource.getFunctionImports()) {
+      serviceDocument.getFunctionImports().put(functionImport.getTitle(),
+              URIUtils.getURI(resource.getBaseURI(), functionImport.getHref()));
+    }
+    for (ServiceDocumentItem singleton : resource.getSingletons()) {
+      serviceDocument.getSingletons().put(singleton.getTitle(),
+              URIUtils.getURI(resource.getBaseURI(), singleton.getHref()));
+    }
+    for (ServiceDocumentItem sdoc : resource.getRelatedServiceDocuments()) {
+      serviceDocument.getRelatedServiceDocuments().put(sdoc.getTitle(),
+              URIUtils.getURI(resource.getBaseURI(), sdoc.getHref()));
+    }
+
+    return serviceDocument;
+  }
+}