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

[29/50] [abbrv] [OLINGO-200] Moving domain objects to commons-api

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
new file mode 100644
index 0000000..ab77d7f
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/AbstractODataValue.java
@@ -0,0 +1,127 @@
+/*
+ * 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.commons.api.domain;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * Abstract representation of an OData entity property value.
+ */
+public abstract class AbstractODataValue implements ODataValue {
+
+  private static final long serialVersionUID = 7445422004232581877L;
+
+  /**
+   * Check is is a primitive value.
+   *
+   * @return 'TRUE' if primitive; 'FALSE' otherwise.
+   */
+  @Override
+  public boolean isPrimitive() {
+    return (this instanceof ODataPrimitiveValue);
+  }
+
+  /**
+   * Casts to primitive value.
+   *
+   * @return primitive value.
+   */
+  @Override
+  public ODataPrimitiveValue asPrimitive() {
+    return isPrimitive() ? (ODataPrimitiveValue) this : null;
+  }
+
+  /**
+   * Check is is a geospatail value.
+   *
+   * @return 'TRUE' if geospatail; 'FALSE' otherwise.
+   */
+  @Override
+  public boolean isGeospatial() {
+    return (this instanceof ODataGeospatialValue);
+  }
+
+  /**
+   * Casts to geospatail value.
+   *
+   * @return geospatail value.
+   */
+  @Override
+  public ODataGeospatialValue asGeospatial() {
+    return isGeospatial() ? (ODataGeospatialValue) this : null;
+  }
+
+  /**
+   * Check is is a complex value.
+   *
+   * @return 'TRUE' if complex; 'FALSE' otherwise.
+   */
+  @Override
+  public boolean isComplex() {
+    return (this instanceof ODataComplexValue);
+  }
+
+  /**
+   * Casts to complex value.
+   *
+   * @return complex value.
+   */
+  @Override
+  public ODataComplexValue asComplex() {
+    return isComplex() ? (ODataComplexValue) this : null;
+  }
+
+  /**
+   * Check is is a collection value.
+   *
+   * @return 'TRUE' if collection; 'FALSE' otherwise.
+   */
+  @Override
+  public boolean isCollection() {
+    return (this instanceof ODataCollectionValue);
+  }
+
+  /**
+   * Casts to collection value.
+   *
+   * @return collection value.
+   */
+  @Override
+  public ODataCollectionValue asCollection() {
+    return isCollection() ? (ODataCollectionValue) this : null;
+  }
+
+  @Override
+  public boolean equals(final Object obj) {
+    return EqualsBuilder.reflectionEquals(this, obj);
+  }
+
+  @Override
+  public int hashCode() {
+    return HashCodeBuilder.reflectionHashCode(this);
+  }
+
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
new file mode 100644
index 0000000..f583187
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
@@ -0,0 +1,98 @@
+/*
+ * 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.commons.api.domain;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * OData collection property value.
+ */
+public class ODataCollectionValue extends AbstractODataValue implements Iterable<ODataValue> {
+
+  private static final long serialVersionUID = -3665659846001987187L;
+
+  /**
+   * Type name;
+   */
+  private final String typeName;
+
+  /**
+   * Values.
+   */
+  private final List<ODataValue> values = new ArrayList<ODataValue>();
+
+  /**
+   * Constructor.
+   *
+   * @param typeName type name.
+   */
+  public ODataCollectionValue(final String typeName) {
+    this.typeName = typeName;
+  }
+
+  /**
+   * Adds a value to the collection.
+   *
+   * @param value value to be added.
+   */
+  public void add(final ODataValue value) {
+    if (value.isPrimitive() || value.isComplex()) {
+      values.add(value);
+    }
+  }
+
+  /**
+   * Value iterator.
+   *
+   * @return value iterator.
+   */
+  @Override
+  public Iterator<ODataValue> iterator() {
+    return values.iterator();
+  }
+
+  /**
+   * Gets value type name.
+   *
+   * @return value type name.
+   */
+  public String getType() {
+    return typeName;
+  }
+
+  /**
+   * Gets collection size.
+   *
+   * @return collection size.
+   */
+  public int size() {
+    return values.size();
+  }
+
+  /**
+   * Checks if collection is empty.
+   *
+   * @return 'TRUE' if empty; 'FALSE' otherwise.
+   */
+  public boolean isEmpty() {
+    return values.isEmpty();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
new file mode 100644
index 0000000..b973718
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
@@ -0,0 +1,97 @@
+/*
+ * 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.commons.api.domain;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * OData complex property value.
+ */
+public class ODataComplexValue extends AbstractODataValue implements Iterable<ODataProperty> {
+
+  private static final long serialVersionUID = -1878555027714020431L;
+
+  /**
+   * Type name.
+   */
+  private final String typeName;
+
+  /**
+   * Complex type fields.
+   */
+  private final Map<String, ODataProperty> fields = new LinkedHashMap<String, ODataProperty>();
+
+  /**
+   * Constructor.
+   *
+   * @param type type name.
+   */
+  public ODataComplexValue(final String typeName) {
+    this.typeName = typeName;
+  }
+
+  /**
+   * Adds field to the complex type.
+   *
+   * @param field field to be added.
+   */
+  public void add(final ODataProperty field) {
+    fields.put(field.getName(), field);
+  }
+
+  /**
+   * Gets field.
+   *
+   * @param name name of the field to be retrieved.
+   * @return requested field.
+   */
+  public ODataProperty get(final String name) {
+    return fields.get(name);
+  }
+
+  /**
+   * Complex property fields iterator.
+   *
+   * @return fields iterator.
+   */
+  @Override
+  public Iterator<ODataProperty> iterator() {
+    return fields.values().iterator();
+  }
+
+  /**
+   * Gest value type name.
+   *
+   * @return value type name.
+   */
+  public String getType() {
+    return typeName;
+  }
+
+  /**
+   * Gets number of fields.
+   *
+   * @return number of fields.
+   */
+  public int size() {
+    return fields.size();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java
new file mode 100644
index 0000000..6f84e4b
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntity.java
@@ -0,0 +1,316 @@
+/*
+ * 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.commons.api.domain;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * OData entity.
+ */
+public class ODataEntity extends ODataItem implements ODataInvokeResult {
+
+  private static final long serialVersionUID = 8360640095932811034L;
+
+  /**
+   * ETag.
+   */
+  private String eTag;
+
+  /**
+   * Media entity flag.
+   */
+  private boolean mediaEntity = false;
+
+  /**
+   * In case of media entity, media content type.
+   */
+  private String mediaContentType;
+
+  /**
+   * In case of media entity, media content source.
+   */
+  private String mediaContentSource;
+
+  /**
+   * Edit link.
+   */
+  protected URI editLink;
+
+  /**
+   * Navigation links (might contain in-line entities or feeds).
+   */
+  protected final List<ODataLink> navigationLinks = new ArrayList<ODataLink>();
+
+  /**
+   * Association links.
+   */
+  protected final List<ODataLink> associationLinks = new ArrayList<ODataLink>();
+
+  /**
+   * Media edit links.
+   */
+  protected final List<ODataLink> editMediaLinks = new ArrayList<ODataLink>();
+
+  /**
+   * Operations (legacy, functions, actions).
+   */
+  protected final List<ODataOperation> operations = new ArrayList<ODataOperation>();
+
+  /**
+   * Entity properties.
+   */
+  protected final List<ODataProperty> properties = new ArrayList<ODataProperty>();
+
+  /**
+   * Constructor.
+   *
+   * @param name OData entity name.
+   */
+  public ODataEntity(final String name) {
+    super(name);
+  }
+
+  /**
+   * Gets ETag.
+   *
+   * @return ETag.
+   */
+  public String getETag() {
+    return eTag;
+  }
+
+  /**
+   * Sets ETag.
+   *
+   * @param eTag ETag.
+   */
+  public void setETag(final String eTag) {
+    this.eTag = eTag;
+  }
+
+  /**
+   * Searches for operation with given title.
+   *
+   * @param title operation to look for
+   * @return operation if found with given title, <tt>null</tt> otherwise
+   */
+  public ODataOperation getOperation(final String title) {
+    ODataOperation result = null;
+    for (ODataOperation operation : operations) {
+      if (title.equals(operation.getTitle())) {
+        result = operation;
+      }
+    }
+
+    return result;
+  }
+
+  /**
+   * Gets operations.
+   *
+   * @return operations.
+   */
+  public List<ODataOperation> getOperations() {
+    return this.operations;
+  }
+
+  /**
+   * Searches for property with given name.
+   *
+   * @param name property to look for
+   * @return property if found with given name, <tt>null</tt> otherwise
+   */
+  public ODataProperty getProperty(final String name) {
+    ODataProperty result = null;
+
+    if (StringUtils.isNotBlank(name)) {
+      for (ODataProperty property : properties) {
+        if (name.equals(property.getName())) {
+          result = property;
+        }
+      }
+    }
+
+    return result;
+  }
+
+  /**
+   * Returns OData entity properties.
+   *
+   * @return OData entity properties.
+   */
+  public List<ODataProperty> getProperties() {
+    return properties;
+  }
+
+  /**
+   * Puts the given link into one of available lists, based on its type.
+   *
+   * @param link to be added
+   * @return <tt>true</tt> if the given link was added in one of available lists
+   */
+  public boolean addLink(final ODataLink link) {
+    boolean result = false;
+
+    switch (link.getType()) {
+      case ASSOCIATION:
+        result = associationLinks.contains(link) ? false : associationLinks.add(link);
+        break;
+
+      case ENTITY_NAVIGATION:
+      case ENTITY_SET_NAVIGATION:
+        result = navigationLinks.contains(link) ? false : navigationLinks.add(link);
+        break;
+
+      case MEDIA_EDIT:
+        result = editMediaLinks.contains(link) ? false : editMediaLinks.add(link);
+        break;
+
+      default:
+    }
+
+    return result;
+  }
+
+  /**
+   * Removes the given link from any list (association, navigation, edit-media).
+   *
+   * @param link to be removed
+   * @return <tt>true</tt> if the given link was contained in one of available lists
+   */
+  public boolean removeLink(final ODataLink link) {
+    return associationLinks.remove(link) || navigationLinks.remove(link) || editMediaLinks.remove(link);
+  }
+
+  /**
+   * Returns all entity navigation links (including inline entities / feeds).
+   *
+   * @return OData entity links.
+   */
+  public List<ODataLink> getNavigationLinks() {
+    return navigationLinks;
+  }
+
+  /**
+   * Returns all entity association links.
+   *
+   * @return OData entity links.
+   */
+  public List<ODataLink> getAssociationLinks() {
+    return associationLinks;
+  }
+
+  /**
+   * Returns all entity media edit links.
+   *
+   * @return OData entity links.
+   */
+  public List<ODataLink> getEditMediaLinks() {
+    return editMediaLinks;
+  }
+
+  /**
+   * Returns OData entity edit link.
+   *
+   * @return entity edit link.
+   */
+  public URI getEditLink() {
+    return editLink;
+  }
+
+  /**
+   * Sets OData entity edit link.
+   *
+   * @param editLink edit link.
+   */
+  public void setEditLink(final URI editLink) {
+    this.editLink = editLink;
+  }
+
+  @Override
+  public URI getLink() {
+    return super.getLink() == null ? getEditLink() : super.getLink();
+  }
+
+  /**
+   * TRUE if read-only entity.
+   *
+   * @return TRUE if read-only; FALSE otherwise.
+   */
+  public boolean isReadOnly() {
+    return super.getLink() != null;
+  }
+
+  /**
+   * Checks if the current entity is a media entity.
+   *
+   * @return 'TRUE' if media entity; 'FALSE' otherwise.
+   */
+  public boolean isMediaEntity() {
+    return mediaEntity;
+  }
+
+  /**
+   * Sets media entity flag.
+   *
+   * @param isMediaEntity media entity flag value.
+   */
+  public void setMediaEntity(final boolean isMediaEntity) {
+    this.mediaEntity = isMediaEntity;
+  }
+
+  /**
+   * Gets media content type.
+   *
+   * @return media content type.
+   */
+  public String getMediaContentType() {
+    return mediaContentType;
+  }
+
+  /**
+   * Sets media content type.
+   *
+   * @param mediaContentType media content type.
+   */
+  public void setMediaContentType(final String mediaContentType) {
+    this.mediaContentType = mediaContentType;
+  }
+
+  /**
+   * Gets media content source.
+   *
+   * @return media content source.
+   */
+  public String getMediaContentSource() {
+    return mediaContentSource;
+  }
+
+  /**
+   * Sets media content source.
+   *
+   * @param mediaContentSource media content source.
+   */
+  public void setMediaContentSource(final String mediaContentSource) {
+    this.mediaContentSource = mediaContentSource;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java
new file mode 100644
index 0000000..d3b146d
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataEntitySet.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.api.domain;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * OData entity collection. If pagination was used to get this instance, forward page navigation URI will be available.
+ */
+public class ODataEntitySet extends ODataItem implements ODataInvokeResult {
+
+  private static final long serialVersionUID = 9039605899821494024L;
+
+  /**
+   * Link to the next page.
+   */
+  protected URI next;
+
+  /**
+   * Number of ODataEntities contained in this feed. If <tt>$inlinecount</tt> was requested, this value comes from
+   * there.
+   */
+  protected Integer count;
+
+  /**
+   * OData entities contained in this feed.
+   */
+  protected List<ODataEntity> entities = new ArrayList<ODataEntity>();
+
+  /**
+   * Constructor.
+   */
+  public ODataEntitySet() {
+    super(null);
+  }
+
+  /**
+   * Constructor.
+   *
+   * @param next next link.
+   */
+  public ODataEntitySet(final URI next) {
+    super(null);
+    this.next = next;
+  }
+
+  /**
+   * Gets next page link.
+   *
+   * @return next page link; null value if single page or last page reached.
+   */
+  public URI getNext() {
+    return next;
+  }
+
+  /**
+   * Sets in-line count.
+   *
+   * @param count in-line count value.
+   */
+  public void setCount(final int count) {
+    this.count = count;
+  }
+
+  /**
+   * Gets in-line count.
+   *
+   * @return in-line count value.
+   */
+  public int getCount() {
+    return count == null ? entities.size() : count;
+  }
+
+  /**
+   * Adds entity to the current feed.
+   *
+   * @param entity entity to be added.
+   * @return 'FALSE' if already exists; 'TRUE' otherwise.
+   */
+  public boolean addEntity(final ODataEntity entity) {
+    return entities.contains(entity) ? false : entities.add(entity);
+  }
+
+  /**
+   * Removes an entity.
+   *
+   * @param entity entity to be removed.
+   * @return 'TRUE' in case of success; 'FALSE' otherwise.
+   */
+  public boolean removeEntity(final ODataEntity entity) {
+    return entities.remove(entity);
+  }
+
+  /**
+   * Gets contained entities.
+   *
+   * @return feed entries.
+   */
+  public List<ODataEntity> getEntities() {
+    return entities;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataGeospatialValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataGeospatialValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataGeospatialValue.java
new file mode 100644
index 0000000..7563907
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataGeospatialValue.java
@@ -0,0 +1,57 @@
+/*
+ * 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.commons.api.domain;
+
+import org.apache.olingo.commons.api.edm.EdmGeospatialType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+
+public interface ODataGeospatialValue extends ODataValue {
+
+  interface Builder {
+
+    Builder setType(EdmPrimitiveTypeKind type);
+
+    Builder setValue(Geospatial value);
+
+    ODataGeospatialValue build();
+
+  }
+
+  EdmPrimitiveTypeKind getTypeKind();
+
+  EdmGeospatialType getType();
+
+  /**
+   * Returns the current geospatial value.
+   *
+   * @return the current geospatial value.
+   */
+  Geospatial toValue();
+
+  /**
+   * Returns the current value casted to the given type.
+   *
+   * @param <T> cast type
+   * @param reference class reference
+   * @return the current value as typed java instance
+   */
+  <T extends Geospatial> T toCastValue(Class<T> reference);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java
new file mode 100644
index 0000000..46e29dd
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java
@@ -0,0 +1,74 @@
+/*
+ * 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.commons.api.domain;
+
+import java.net.URI;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+/**
+ * OData in-line entity.
+ */
+public class ODataInlineEntity extends ODataLink {
+
+  private static final long serialVersionUID = -4763341581843700743L;
+
+  private final ODataEntity entity;
+
+  /**
+   * Constructor.
+   *
+   * @param version OData service version.
+   * @param uri edit link.
+   * @param type type.
+   * @param title title.
+   * @param entity entity.
+   */
+  public ODataInlineEntity(final ODataServiceVersion version,
+          final URI uri, final ODataLinkType type, final String title, final ODataEntity entity) {
+
+    super(version, uri, type, title);
+    this.entity = entity;
+  }
+
+  /**
+   * Constructor.
+   *
+   * @param version OData service version.
+   * @param baseURI base URI.
+   * @param href href.
+   * @param type type.
+   * @param title title.
+   * @param entity entity.
+   */
+  public ODataInlineEntity(final ODataServiceVersion version, final URI baseURI, final String href,
+          final ODataLinkType type, final String title, final ODataEntity entity) {
+
+    super(version, baseURI, href, type, title);
+    this.entity = entity;
+  }
+
+  /**
+   * Gets wrapped entity.
+   *
+   * @return wrapped entity.
+   */
+  public ODataEntity getEntity() {
+    return entity;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java
new file mode 100644
index 0000000..1ace20b
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntitySet.java
@@ -0,0 +1,74 @@
+/*
+ * 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.commons.api.domain;
+
+import java.net.URI;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+/**
+ * OData in-line entity set.
+ */
+public class ODataInlineEntitySet extends ODataLink {
+
+  private static final long serialVersionUID = -77628001615355449L;
+
+  private ODataEntitySet entitySet;
+
+  /**
+   * Constructor.
+   *
+   * @param version OData service version.
+   * @param uri edit link.
+   * @param type type.
+   * @param title title.
+   * @param entitySet entity set.
+   */
+  public ODataInlineEntitySet(final ODataServiceVersion version, final URI uri, final ODataLinkType type,
+          final String title, final ODataEntitySet entitySet) {
+
+    super(version, uri, type, title);
+    this.entitySet = entitySet;
+  }
+
+  /**
+   * Constructor.
+   *
+   * @param version OData service version.
+   * @param baseURI base URI.
+   * @param href href.
+   * @param type type.
+   * @param title title.
+   * @param entitySet entity set.
+   */
+  public ODataInlineEntitySet(final ODataServiceVersion version, final URI baseURI, final String href,
+          final ODataLinkType type, final String title, final ODataEntitySet entitySet) {
+
+    super(version, baseURI, href, type, title);
+    this.entitySet = entitySet;
+  }
+
+  /**
+   * Gets wrapped entity set.
+   *
+   * @return wrapped entity set.
+   */
+  public ODataEntitySet getEntitySet() {
+    return entitySet;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInvokeResult.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInvokeResult.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInvokeResult.java
new file mode 100644
index 0000000..d4b8c44
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInvokeResult.java
@@ -0,0 +1,30 @@
+/*
+ * 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.commons.api.domain;
+
+/**
+ * Marker interface for any OData domain object that can be returned by an operation invocation.
+ *
+ * @see ODataEntitySet
+ * @see ODataEntity
+ * @see ODataProperty
+ * @see ODataNoContent
+ */
+public interface ODataInvokeResult {
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataItem.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataItem.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataItem.java
new file mode 100644
index 0000000..b40eeb7
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataItem.java
@@ -0,0 +1,111 @@
+/*
+ * 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.commons.api.domain;
+
+import java.io.Serializable;
+import java.net.URI;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Abstract representation of OData entities and links.
+ */
+public abstract class ODataItem implements Serializable {
+
+  private static final long serialVersionUID = -2600707722689304686L;
+
+  /**
+   * Logger.
+   */
+  protected static final Logger LOG = LoggerFactory.getLogger(ODataItem.class);
+
+  /**
+   * OData item self link.
+   */
+  protected URI link;
+
+  /**
+   * OData entity name/type.
+   */
+  private final String name;
+
+  /**
+   * Constructor.
+   *
+   * @param name OData entity name.
+   */
+  public ODataItem(final String name) {
+    this.name = name;
+  }
+
+  /**
+   * Returns self link.
+   *
+   * @return entity edit link.
+   */
+  public URI getLink() {
+    return link;
+  }
+
+  /**
+   * Sets self link.
+   *
+   * @param link link.
+   */
+  public void setLink(final URI link) {
+    this.link = link;
+  }
+
+  /**
+   * Returns OData entity name.
+   *
+   * @return entity name.
+   */
+  public String getName() {
+    return name;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public boolean equals(final Object obj) {
+    return EqualsBuilder.reflectionEquals(this, obj);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public int hashCode() {
+    return HashCodeBuilder.reflectionHashCode(this);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java
new file mode 100644
index 0000000..9e68454
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java
@@ -0,0 +1,190 @@
+/*
+ * 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.commons.api.domain;
+
+import java.net.URI;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+/**
+ * OData link.
+ */
+public class ODataLink extends ODataItem {
+
+  private static final long serialVersionUID = 7274966414277952124L;
+
+  public static class Builder {
+
+    private ODataServiceVersion version;
+
+    private URI uri;
+
+    private ODataLinkType type;
+
+    private String title;
+
+    private String mediaETag;
+
+    public Builder setVersion(final ODataServiceVersion version) {
+      this.version = version;
+      return this;
+    }
+
+    public Builder setURI(final URI uri) {
+      this.uri = uri;
+      return this;
+    }
+
+    public Builder setURI(final URI baseURI, final String href) {
+      this.uri = getURI(baseURI, href);
+      return this;
+    }
+
+    public Builder setType(final ODataLinkType type) {
+      this.type = type;
+      return this;
+    }
+
+    public Builder setTitle(final String title) {
+      this.title = title;
+      return this;
+    }
+
+    public void setMediaETag(final String mediaETag) {
+      this.mediaETag = mediaETag;
+    }
+
+    public ODataLink build() {
+      ODataLink instance = new ODataLink(version, uri, type, title);
+      instance.mediaETag = this.mediaETag;
+      return instance;
+    }
+  }
+
+  /**
+   * Build URI starting from the given base and href.
+   * <br/>
+   * If href is absolute or base is null then base will be ignored.
+   *
+   * @param base URI prefix.
+   * @param href URI suffix.
+   * @return built URI.
+   */
+  private static URI getURI(final URI base, final String href) {
+    if (href == null) {
+      throw new IllegalArgumentException("Null link provided");
+    }
+
+    URI uri = URI.create(href);
+
+    if (!uri.isAbsolute() && base != null) {
+      uri = URI.create(base.toASCIIString() + "/" + href);
+    }
+
+    return uri.normalize();
+  }
+
+  /**
+   * Link type.
+   */
+  protected final ODataLinkType type;
+
+  /**
+   * Link rel.
+   */
+  protected final String rel;
+
+  /**
+   * ETag for media edit links.
+   */
+  private String mediaETag;
+
+  /**
+   * Constructor.
+   *
+   * @param version OData service version.
+   * @param uri URI.
+   * @param type type.
+   * @param title title.
+   */
+  protected ODataLink(final ODataServiceVersion version, final URI uri, final ODataLinkType type, final String title) {
+    super(title);
+
+    this.link = uri;
+    this.type = type;
+
+    switch (this.type) {
+      case ASSOCIATION:
+        this.rel = version.getNamespaceMap().get(ODataServiceVersion.ASSOCIATION_LINK_REL) + title;
+        break;
+
+      case ENTITY_NAVIGATION:
+      case ENTITY_SET_NAVIGATION:
+        this.rel = version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL) + title;
+        break;
+
+      case MEDIA_EDIT:
+      default:
+        this.rel = version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL) + title;
+        break;
+    }
+  }
+
+  /**
+   * Constructor.
+   *
+   * @param version OData service version.
+   * @param baseURI base URI.
+   * @param href href.
+   * @param type type.
+   * @param title title.
+   */
+  protected ODataLink(final ODataServiceVersion version,
+          final URI baseURI, final String href, final ODataLinkType type, final String title) {
+
+    this(version, getURI(baseURI, href), type, title);
+  }
+
+  /**
+   * Gets link type.
+   *
+   * @return link type;
+   */
+  public ODataLinkType getType() {
+    return type;
+  }
+
+  /**
+   * Gets link rel.
+   *
+   * @return link rel
+   */
+  public String getRel() {
+    return rel;
+  }
+
+  /**
+   * Gets Media ETag.
+   *
+   * @return media ETag
+   */
+  public String getMediaETag() {
+    return mediaETag;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java
new file mode 100644
index 0000000..59dc834
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java
@@ -0,0 +1,93 @@
+/*
+ * 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.commons.api.domain;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+
+/**
+ * OData link types.
+ */
+public enum ODataLinkType {
+
+  /**
+   * Entity navigation link.
+   */
+  ENTITY_NAVIGATION(ODataPubFormat.ATOM + ";type=entry"),
+  /**
+   * Entity set navigation link.
+   */
+  ENTITY_SET_NAVIGATION(ODataPubFormat.ATOM + ";type=feed"),
+  /**
+   * Association link.
+   */
+  ASSOCIATION(ContentType.APPLICATION_XML),
+  /**
+   * Media-edit link.
+   */
+  MEDIA_EDIT("*/*");
+
+  private String type;
+
+  private ODataLinkType(final String type) {
+    this.type = type;
+  }
+
+  private ODataLinkType setType(final String type) {
+    this.type = type;
+    return this;
+  }
+
+  /**
+   * Gets <code>LinkType</code> instance from the given rel and type.
+   *
+   * @param version OData protocol version.
+   * @param rel rel.
+   * @param type type.
+   * @return <code>ODataLinkType</code> object.
+   */
+  public static ODataLinkType fromString(final ODataServiceVersion version, final String rel, final String type) {
+    if (StringUtils.isNotBlank(rel)
+            && rel.startsWith(version.getNamespaceMap().get(ODataServiceVersion.MEDIA_EDIT_LINK_REL))) {
+
+      return MEDIA_EDIT.setType(StringUtils.isBlank(type) ? "*/*" : type);
+    }
+
+    if (ODataLinkType.ENTITY_NAVIGATION.type.equals(type)) {
+      return ENTITY_NAVIGATION;
+    }
+
+    if (ODataLinkType.ENTITY_SET_NAVIGATION.type.equals(type)) {
+      return ENTITY_SET_NAVIGATION;
+    }
+
+    if (ODataLinkType.ASSOCIATION.type.equals(type)) {
+      return ASSOCIATION;
+    }
+
+    throw new IllegalArgumentException("Invalid link type: " + type);
+  }
+
+  @Override
+  public String toString() {
+    return type;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java
new file mode 100644
index 0000000..b38a5e8
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataObjectFactory.java
@@ -0,0 +1,218 @@
+/*
+ * 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.commons.api.domain;
+
+import java.net.URI;
+
+/**
+ * Entry point for generating OData domain objects.
+ *
+ * @see ODataEntitySet
+ * @see ODataEntity
+ * @see ODataProperty
+ * @see ODataLink
+ */
+public interface ODataObjectFactory {
+
+  /**
+   * Instantiates a new entity set.
+   *
+   * @return entity set.
+   */
+  ODataEntitySet newEntitySet();
+
+  /**
+   * Instantiates a new entity set.
+   *
+   * @param next next link.
+   * @return entity set.
+   */
+  ODataEntitySet newEntitySet(URI next);
+
+  /**
+   * Instantiates a new entity.
+   *
+   * @param name OData entity name.
+   * @return entity.
+   */
+  ODataEntity newEntity(String name);
+
+  /**
+   * Instantiates a new entity.
+   *
+   * @param name OData entity name.
+   * @param link self link.
+   * @return entity.
+   */
+  ODataEntity newEntity(String name, URI link);
+
+  /**
+   * Instantiates a new in-line entity set.
+   *
+   * @param name name.
+   * @param link edit link.
+   * @param entitySet entity set.
+   * @return in-line entity set.
+   */
+  ODataInlineEntitySet newInlineEntitySet(String name, URI link, ODataEntitySet entitySet);
+
+  /**
+   * Instantiates a new in-line entity set.
+   *
+   * @param name name.
+   * @param baseURI base URI.
+   * @param href href.
+   * @param entitySet entity set.
+   * @return in-line entity set.
+   */
+  ODataInlineEntitySet newInlineEntitySet(String name, URI baseURI, String href, ODataEntitySet entitySet);
+
+  /**
+   * Instantiates a new in-line entity.
+   *
+   * @param name name.
+   * @param link edit link.
+   * @param entity entity.
+   * @return in-line entity.
+   */
+  ODataInlineEntity newInlineEntity(String name, URI link, ODataEntity entity);
+
+  /**
+   * Instantiates a new in-line entity.
+   *
+   * @param name name.
+   * @param baseURI base URI.
+   * @param href href.
+   * @param entity entity.
+   * @return in-line entity.
+   */
+  ODataInlineEntity newInlineEntity(String name, URI baseURI, String href, ODataEntity entity);
+
+  /**
+   * Instantiates a new entity navigation link.
+   *
+   * @param name name.
+   * @param link link.
+   * @return entity navigation link.
+   */
+  ODataLink newEntityNavigationLink(String name, URI link);
+
+  /**
+   * Instantiates a new entity navigation link.
+   *
+   * @param name name.
+   * @param baseURI base URI.
+   * @param href href.
+   * @return entity navigation link.
+   */
+  ODataLink newEntityNavigationLink(String name, URI baseURI, String href);
+
+  /**
+   * Instantiates a new entity set navigation link.
+   *
+   * @param name name.
+   * @param link link.
+   * @return entity set navigation link.
+   */
+  ODataLink newFeedNavigationLink(String name, URI link);
+
+  /**
+   * Instantiates a new entity set navigation link.
+   *
+   * @param name name.
+   * @param baseURI base URI.
+   * @param href href.
+   * @return entity set navigation link.
+   */
+  ODataLink newFeedNavigationLink(String name, URI baseURI, String href);
+
+  /**
+   * Instantiates a new association link.
+   *
+   * @param name name.
+   * @param link link.
+   * @return association link.
+   */
+  ODataLink newAssociationLink(String name, URI link);
+
+  /**
+   * Instantiates a new association link.
+   *
+   * @param name name.
+   * @param baseURI base URI.
+   * @param href href.
+   * @return association link.
+   */
+  ODataLink newAssociationLink(String name, URI baseURI, String href);
+
+  /**
+   * Instantiates a new media-edit link.
+   *
+   * @param name name.
+   * @param link link.
+   * @return media-edit link.
+   */
+  ODataLink newMediaEditLink(String name, URI link);
+
+  /**
+   * Instantiates a new media-edit link.
+   *
+   * @param name name.
+   * @param baseURI base URI.
+   * @param href href.
+   * @return media-edit link.
+   */
+  ODataLink newMediaEditLink(String name, URI baseURI, String href);
+
+  /**
+   * Instantiates a new primitive property.
+   *
+   * @param name name.
+   * @param value primitive value.
+   * @return primitive property.
+   */
+  ODataProperty newPrimitiveProperty(String name, ODataPrimitiveValue value);
+
+  /**
+   * Instantiates a new primitive property.
+   *
+   * @param name name.
+   * @param value geospatial value.
+   * @return primitive property.
+   */
+  ODataProperty newPrimitiveProperty(String name, ODataGeospatialValue value);
+
+  /**
+   * Instantiates a new complex property.
+   *
+   * @param name name.
+   * @param value value.
+   * @return complex property.
+   */
+  ODataProperty newComplexProperty(String name, ODataComplexValue value);
+
+  /**
+   * Instantiates a new collection property.
+   *
+   * @param name name.
+   * @param value value.
+   * @return collection property.
+   */
+  ODataProperty newCollectionProperty(String name, ODataCollectionValue value);
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataOperation.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataOperation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataOperation.java
new file mode 100644
index 0000000..47daba4
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataOperation.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.api.domain;
+
+import java.io.Serializable;
+import java.net.URI;
+
+public class ODataOperation implements Serializable {
+
+  private static final long serialVersionUID = 4155165768886762490L;
+
+  private String metadataAnchor;
+
+  private String title;
+
+  private URI target;
+
+  /**
+   * Gets metadata anchor.
+   *
+   * @return metadata anchor.
+   */
+  public String getMetadataAnchor() {
+    return metadataAnchor;
+  }
+
+  /**
+   * Sets metadata anchor.
+   *
+   * @param metadataAnchor metadata anchor.
+   */
+  public void setMetadataAnchor(final String metadataAnchor) {
+    this.metadataAnchor = metadataAnchor;
+  }
+
+  /**
+   * Gets title.
+   *
+   * @return title.
+   */
+  public String getTitle() {
+    return title;
+  }
+
+  /**
+   * Sets title.
+   *
+   * @param title title.
+   */
+  public void setTitle(final String title) {
+    this.title = title;
+  }
+
+  /**
+   * Gets target.
+   *
+   * @return target.
+   */
+  public URI getTarget() {
+    return target;
+  }
+
+  /**
+   * Sets target.
+   *
+   * @param target target.
+   */
+  public void setTarget(final URI target) {
+    this.target = target;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java
new file mode 100644
index 0000000..77e83ae
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPrimitiveValue.java
@@ -0,0 +1,67 @@
+/*
+ * 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.commons.api.domain;
+
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+
+public interface ODataPrimitiveValue extends ODataValue {
+
+  interface Builder {
+
+    Builder setType(EdmPrimitiveTypeKind type);
+
+    Builder setText(String text);
+
+    Builder setValue(Object value);
+
+    ODataPrimitiveValue build();
+  }
+
+  EdmPrimitiveTypeKind getTypeKind();
+
+  EdmPrimitiveType getType();
+
+  /**
+   * Returns the current value as generic Object.
+   *
+   * @return an uncasted instance of this value
+   */
+  Object toValue();
+
+  /**
+   * Returns the current value casted to the given type.
+   *
+   * @param <T> cast type
+   * @param reference class reference
+   * @return the current value as typed java instance
+   * @throws EdmPrimitiveTypeException if the object is not assignable to the type T.
+   */
+  <T> T toCastValue(Class<T> reference) throws EdmPrimitiveTypeException;
+
+  /**
+   * Serialize the current value as String.
+   *
+   * @return a String representation of this value
+   */
+  @Override
+  String toString();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java
new file mode 100644
index 0000000..7217282
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataProperty.java
@@ -0,0 +1,186 @@
+/*
+ * 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.commons.api.domain;
+
+import java.io.Serializable;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * OData entity property.
+ */
+public class ODataProperty implements Serializable, ODataInvokeResult {
+
+  private static final long serialVersionUID = 926939448778950450L;
+
+  /**
+   * Property name.
+   */
+  private final String name;
+
+  /**
+   * Property value.
+   */
+  private ODataValue value;
+
+  /**
+   * Constructor.
+   *
+   * @param name property name.
+   * @param value property value.
+   */
+  public ODataProperty(final String name, final ODataValue value) {
+    this.name = name;
+    this.value = value;
+  }
+
+  /**
+   * Returns property name.
+   *
+   * @return property name.
+   */
+  public String getName() {
+    return name;
+  }
+
+  /**
+   * Returns property value.
+   *
+   * @return property value.
+   */
+  public ODataValue getValue() {
+    return value;
+  }
+
+  /**
+   * Updates property value.
+   *
+   * @param value property value that replaces current.
+   */
+  public void setValue(final ODataValue value) {
+    this.value = value;
+  }
+
+  /**
+   * Checks if has null value.
+   *
+   * @return 'TRUE' if has null value; 'FALSE' otherwise.
+   */
+  public boolean hasNullValue() {
+    return this.value == null;
+  }
+
+  /**
+   * Checks if has primitive value.
+   *
+   * @return 'TRUE' if has primitive value; 'FALSE' otherwise.
+   */
+  public boolean hasPrimitiveValue() {
+    return !hasNullValue() && this.value.isPrimitive();
+  }
+
+  /**
+   * Gets primitive value.
+   *
+   * @return primitive value if exists; null otherwise.
+   */
+  public ODataPrimitiveValue getPrimitiveValue() {
+    return hasPrimitiveValue() ? this.value.asPrimitive() : null;
+  }
+
+  /**
+   * Checks if has geospatial value.
+   *
+   * @return 'TRUE' if has geospatial value; 'FALSE' otherwise.
+   */
+  public boolean hasGeospatialValue() {
+    return !hasNullValue() && this.value.isGeospatial();
+  }
+
+  /**
+   * Gets geospatial value.
+   *
+   * @return geospatial value if exists; null otherwise.
+   */
+  public ODataGeospatialValue getGeospatialValue() {
+    return hasGeospatialValue() ? this.value.asGeospatial() : null;
+  }
+
+  /**
+   * Checks if has complex value.
+   *
+   * @return 'TRUE' if has complex value; 'FALSE' otherwise.
+   */
+  public boolean hasComplexValue() {
+    return !hasNullValue() && this.value.isComplex();
+  }
+
+  /**
+   * Gets complex value.
+   *
+   * @return complex value if exists; null otherwise.
+   */
+  public ODataComplexValue getComplexValue() {
+    return hasComplexValue() ? this.value.asComplex() : null;
+  }
+
+  /**
+   * Checks if has collection value.
+   *
+   * @return 'TRUE' if has collection value; 'FALSE' otherwise.
+   */
+  public boolean hasCollectionValue() {
+    return !hasNullValue() && this.value.isCollection();
+  }
+
+  /**
+   * Gets collection value.
+   *
+   * @return collection value if exists; null otherwise.
+   */
+  public ODataCollectionValue getCollectionValue() {
+    return hasCollectionValue() ? this.value.asCollection() : null;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public boolean equals(final Object obj) {
+    return EqualsBuilder.reflectionEquals(this, obj);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public int hashCode() {
+    return HashCodeBuilder.reflectionHashCode(this);
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java
new file mode 100644
index 0000000..d173e50
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java
@@ -0,0 +1,40 @@
+/*
+ * 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.commons.api.domain;
+
+public enum ODataPropertyType {
+
+  /**
+   * Primitive (including geospatial and enum).
+   */
+  PRIMITIVE,
+  /**
+   * Collection
+   */
+  COLLECTION,
+  /**
+   * Complex.
+   */
+  COMPLEX,
+  /**
+   * Empty type (possibly, no type information could be retrieved).
+   */
+  EMPTY
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataServiceDocument.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataServiceDocument.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataServiceDocument.java
new file mode 100644
index 0000000..13f807b
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataServiceDocument.java
@@ -0,0 +1,183 @@
+/*
+ * 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.commons.api.domain;
+
+import java.net.URI;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ODataServiceDocument {
+
+  private URI metadataContext;
+
+  private String metadataETag;
+
+  private final Map<String, URI> entitySets = new HashMap<String, URI>();
+
+  private final Map<String, URI> functionImports = new HashMap<String, URI>();
+
+  private final Map<String, URI> singletons = new HashMap<String, URI>();
+
+  private final Map<String, URI> relatedServiceDocuments = new HashMap<String, URI>();
+
+  public URI getMetadataContext() {
+    return metadataContext;
+  }
+
+  public void setMetadataContext(final URI metadataContext) {
+    this.metadataContext = metadataContext;
+  }
+
+  public String getMetadataETag() {
+    return metadataETag;
+  }
+
+  public void setMetadataETag(final String metadataETag) {
+    this.metadataETag = metadataETag;
+  }
+
+  public Map<String, URI> getEntitySets() {
+    return entitySets;
+  }
+
+  /**
+   * Gets entity set titles.
+   *
+   * @return entity set titles.
+   */
+  public Collection<String> getEntitySetTitles() {
+    return entitySets.keySet();
+  }
+
+  /**
+   * Gets entity set URIs.
+   *
+   * @return entity set URIs.
+   */
+  public Collection<URI> getEntitySetURIs() {
+    return entitySets.values();
+  }
+
+  /**
+   * Gets URI about the given entity set.
+   *
+   * @param title title.
+   * @return URI.
+   */
+  public URI getEntitySetURI(final String title) {
+    return entitySets.get(title);
+  }
+
+  public Map<String, URI> getFunctionImports() {
+    return functionImports;
+  }
+
+  /**
+   * Gets function import titles.
+   *
+   * @return function import titles.
+   */
+  public Collection<String> getFunctionImportTitles() {
+    return functionImports.keySet();
+  }
+
+  /**
+   * Gets function import URIs.
+   *
+   * @return function import URIs.
+   */
+  public Collection<URI> getFunctionImportURIs() {
+    return functionImports.values();
+  }
+
+  /**
+   * Gets URI of the given function import.
+   *
+   * @param title title.
+   * @return URI.
+   */
+  public URI getFunctionImportURI(final String title) {
+    return functionImports.get(title);
+  }
+
+  public Map<String, URI> getSingletons() {
+    return singletons;
+  }
+
+  /**
+   * Gets singleton titles.
+   *
+   * @return singleton titles.
+   */
+  public Collection<String> getSingletonTitles() {
+    return singletons.keySet();
+  }
+
+  /**
+   * Gets singleton URIs.
+   *
+   * @return singleton URIs.
+   */
+  public Collection<URI> getSingletonURIs() {
+    return singletons.values();
+  }
+
+  /**
+   * Gets URI of the given singleton.
+   *
+   * @param title title.
+   * @return URI.
+   */
+  public URI getSingletonURI(final String title) {
+    return singletons.get(title);
+  }
+
+  public Map<String, URI> getRelatedServiceDocuments() {
+    return relatedServiceDocuments;
+  }
+
+  /**
+   * Gets related service documents titles.
+   *
+   * @return related service documents titles.
+   */
+  public Collection<String> getRelatedServiceDocumentsTitles() {
+    return relatedServiceDocuments.keySet();
+  }
+
+  /**
+   * Gets related service documents URIs.
+   *
+   * @return related service documents URIs.
+   */
+  public Collection<URI> getRelatedServiceDocumentsURIs() {
+    return relatedServiceDocuments.values();
+  }
+
+  /**
+   * Gets URI of the given related service documents.
+   *
+   * @param title title.
+   * @return URI.
+   */
+  public URI getRelatedServiceDocumentURI(final String title) {
+    return relatedServiceDocuments.get(title);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
new file mode 100644
index 0000000..e1c9be9
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataValue.java
@@ -0,0 +1,84 @@
+/*
+ * 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.commons.api.domain;
+
+import java.io.Serializable;
+
+/**
+ * Abstract representation of an OData entity property value.
+ */
+public interface ODataValue extends Serializable {
+
+  /**
+   * Check is is a primitive value.
+   *
+   * @return 'TRUE' if primitive; 'FALSE' otherwise.
+   */
+  boolean isPrimitive();
+
+  /**
+   * Casts to primitive value.
+   *
+   * @return primitive value.
+   */
+  ODataPrimitiveValue asPrimitive();
+
+  /**
+   * Check is is a geospatail value.
+   *
+   * @return 'TRUE' if geospatail; 'FALSE' otherwise.
+   */
+  boolean isGeospatial();
+
+  /**
+   * Casts to geospatail value.
+   *
+   * @return geospatail value.
+   */
+  ODataGeospatialValue asGeospatial();
+
+  /**
+   * Check is is a collection value.
+   *
+   * @return 'TRUE' if collection; 'FALSE' otherwise.
+   */
+  boolean isCollection();
+
+  /**
+   * Casts to collection value.
+   *
+   * @return collection value.
+   */
+  ODataCollectionValue asCollection();
+
+  /**
+   * Check is is a complex value.
+   *
+   * @return 'TRUE' if complex; 'FALSE' otherwise.
+   */
+  boolean isComplex();
+
+  /**
+   * Casts to complex value.
+   *
+   * @return complex value.
+   */
+  ODataComplexValue asComplex();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
new file mode 100644
index 0000000..21ed548
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ContentType.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.api.format;
+
+public interface ContentType {
+
+  public static final String APPLICATION_ATOM_XML = "application/atom+xml";
+
+  public static final String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";
+
+  public static final String APPLICATION_JSON = "application/json";
+
+  public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
+
+  public static final String APPLICATION_SVG_XML = "application/svg+xml";
+
+  public static final String APPLICATION_XHTML_XML = "application/xhtml+xml";
+
+  public static final String APPLICATION_XML = "application/xml";
+
+  public static final String MULTIPART_FORM_DATA = "multipart/form-data";
+
+  public static final String TEXT_HTML = "text/html";
+
+  public static final String TEXT_PLAIN = "text/plain";
+
+  public static final String TEXT_XML = "text/xml";
+
+  public static final String WILDCARD = "*/*";
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
new file mode 100644
index 0000000..30d9e09
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java
@@ -0,0 +1,95 @@
+/*
+ * 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.commons.api.format;
+
+/**
+ * Available formats to be used in various contexts.
+ */
+public enum ODataFormat {
+
+  /**
+   * JSON format with no metadata.
+   */
+  JSON_NO_METADATA(ContentType.APPLICATION_JSON + ";odata=nometadata"),
+  /**
+   * JSON format with minimal metadata (default).
+   */
+  JSON(ContentType.APPLICATION_JSON + ";odata=minimalmetadata"),
+  /**
+   * JSON format with no metadata.
+   */
+  JSON_FULL_METADATA(ContentType.APPLICATION_JSON + ";odata=fullmetadata"),
+  /**
+   * XML format.
+   */
+  XML(ContentType.APPLICATION_XML);
+
+  private final String format;
+
+  ODataFormat(final String format) {
+    this.format = format;
+  }
+
+  /**
+   * Gets format as a string.
+   *
+   * @return format as a string.
+   */
+  @Override
+  public String toString() {
+    return format;
+  }
+
+  /**
+   * Gets OData format from its string representation.
+   *
+   * @param format string representation of the format.
+   * @return OData format.
+   */
+  public static ODataFormat fromString(final String format) {
+    ODataFormat result = null;
+
+    final StringBuffer _format = new StringBuffer();
+
+    final String[] parts = format.split(";");
+    _format.append(parts[0].trim());
+    if (ContentType.APPLICATION_JSON.equals(parts[0].trim())) {
+      if (parts.length > 1) {
+        _format.append(';').append(parts[1].trim());
+      } else {
+        result = ODataFormat.JSON;
+      }
+    }
+
+    if (result == null) {
+      final String candidate = _format.toString();
+      for (ODataFormat value : values()) {
+        if (candidate.equals(value.toString())) {
+          result = value;
+        }
+      }
+    }
+
+    if (result == null) {
+      throw new IllegalArgumentException("Unsupported format: " + format);
+    }
+
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataMediaFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataMediaFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataMediaFormat.java
new file mode 100644
index 0000000..c479de4
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataMediaFormat.java
@@ -0,0 +1,69 @@
+/*
+ * 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.commons.api.format;
+
+/**
+ * Available formats for media.
+ */
+public enum ODataMediaFormat {
+
+  CHARSET_PARAMETER("charset"),
+  MEDIA_TYPE_WILDCARD("*"),
+  WILDCARD(ContentType.WILDCARD),
+  APPLICATION_XML(ContentType.APPLICATION_XML),
+  APPLICATION_ATOM_XML(ContentType.APPLICATION_ATOM_XML),
+  APPLICATION_XHTML_XML(ContentType.APPLICATION_XHTML_XML),
+  APPLICATION_SVG_XML(ContentType.APPLICATION_SVG_XML),
+  APPLICATION_JSON(ContentType.APPLICATION_JSON),
+  APPLICATION_FORM_URLENCODED(ContentType.APPLICATION_FORM_URLENCODED),
+  MULTIPART_FORM_DATA(ContentType.MULTIPART_FORM_DATA),
+  APPLICATION_OCTET_STREAM(ContentType.APPLICATION_OCTET_STREAM),
+  TEXT_PLAIN(ContentType.TEXT_PLAIN),
+  TEXT_XML(ContentType.TEXT_XML),
+  TEXT_HTML(ContentType.TEXT_HTML);
+
+  private final String format;
+
+  private ODataMediaFormat(final String format) {
+    this.format = format;
+  }
+
+  @Override
+  public String toString() {
+    return format;
+  }
+
+  public static ODataMediaFormat fromFormat(final String format) {
+    final String _format = format.split(";")[0];
+
+    ODataMediaFormat result = null;
+
+    for (ODataMediaFormat value : values()) {
+      if (_format.equals(value.toString())) {
+        result = value;
+      }
+    }
+
+    if (result == null) {
+      throw new IllegalArgumentException("Unsupported format: " + format);
+    }
+
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataPubFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataPubFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataPubFormat.java
new file mode 100644
index 0000000..6cd6a05
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataPubFormat.java
@@ -0,0 +1,95 @@
+/*
+ * 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.commons.api.format;
+
+/**
+ * Available formats for AtomPub exchange.
+ */
+public enum ODataPubFormat {
+
+  /**
+   * JSON format with no metadata.
+   */
+  JSON_NO_METADATA(ContentType.APPLICATION_JSON + ";odata=nometadata"),
+  /**
+   * JSON format with minimal metadata (default).
+   */
+  JSON(ContentType.APPLICATION_JSON + ";odata=minimalmetadata"),
+  /**
+   * JSON format with no metadata.
+   */
+  JSON_FULL_METADATA(ContentType.APPLICATION_JSON + ";odata=fullmetadata"),
+  /**
+   * Atom format.
+   */
+  ATOM(ContentType.APPLICATION_ATOM_XML);
+
+  private final String format;
+
+  ODataPubFormat(final String format) {
+    this.format = format;
+  }
+
+  /**
+   * Gets format as a string.
+   *
+   * @return format as a string.
+   */
+  @Override
+  public String toString() {
+    return format;
+  }
+
+  /**
+   * Gets OData format from its string representation.
+   *
+   * @param format string representation of the format.
+   * @return OData format.
+   */
+  public static ODataPubFormat fromString(final String format) {
+    ODataPubFormat result = null;
+
+    final StringBuffer _format = new StringBuffer();
+
+    final String[] parts = format.split(";");
+    _format.append(parts[0].trim());
+    if (ContentType.APPLICATION_JSON.equals(parts[0].trim())) {
+      if (parts.length > 1 && parts[1].startsWith("odata=")) {
+        _format.append(';').append(parts[1].trim());
+      } else {
+        result = ODataPubFormat.JSON;
+      }
+    }
+
+    if (result == null) {
+      final String candidate = _format.toString();
+      for (ODataPubFormat value : values()) {
+        if (candidate.equals(value.toString())) {
+          result = value;
+        }
+      }
+    }
+
+    if (result == null) {
+      throw new IllegalArgumentException("Unsupported format: " + format);
+    }
+
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/0b4b86c0/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataValueFormat.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataValueFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataValueFormat.java
new file mode 100644
index 0000000..1b290bf
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataValueFormat.java
@@ -0,0 +1,74 @@
+/*
+ * 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.commons.api.format;
+
+/**
+ * Available formats for property values.
+ */
+public enum ODataValueFormat {
+
+  /**
+   * Application octet stream.
+   */
+  STREAM(ContentType.APPLICATION_OCTET_STREAM),
+  /**
+   * Plain text format.
+   */
+  TEXT(ContentType.TEXT_PLAIN);
+
+  private final String format;
+
+  ODataValueFormat(final String format) {
+    this.format = format;
+  }
+
+  /**
+   * Gets format as a string.
+   *
+   * @return format as a string.
+   */
+  @Override
+  public String toString() {
+    return format;
+  }
+
+  /**
+   * Gets format from its string representation.
+   *
+   * @param format string representation of the format.
+   * @return OData format.
+   */
+  public static ODataValueFormat fromString(final String format) {
+    final String _format = format.split(";")[0];
+
+    ODataValueFormat result = null;
+
+    for (ODataValueFormat value : values()) {
+      if (_format.equals(value.toString())) {
+        result = value;
+      }
+    }
+
+    if (result == null) {
+      throw new IllegalArgumentException("Unsupported format: " + format);
+    }
+
+    return result;
+  }
+}