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:23 UTC

[34/50] [abbrv] [OLINGO-200] Moving Atom and JSON (de)serializer to commons

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java
new file mode 100644
index 0000000..027eac3
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertyImpl.java
@@ -0,0 +1,53 @@
+/*
+ * 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.core.data;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import java.net.URI;
+
+/**
+ * A single property (primitive, complex or collection) represented via JSON.
+ */
+@JsonSerialize(using = JSONPropertySerializer.class)
+@JsonDeserialize(using = JSONPropertyDeserializer.class)
+public class JSONPropertyImpl extends AbstractPropertyImpl {
+
+  private static final long serialVersionUID = 553414431536637434L;
+
+  private URI metadata;
+
+  /**
+   * Gets metadata URI.
+   *
+   * @return metadata URI.
+   */
+  public URI getMetadata() {
+    return metadata;
+  }
+
+  /**
+   * Sets metadata URI.
+   *
+   * @param metadata metadata URI.
+   */
+  public void setMetadata(final URI metadata) {
+    this.metadata = metadata;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
new file mode 100644
index 0000000..104083b
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONPropertySerializer.java
@@ -0,0 +1,59 @@
+/*
+ * 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.core.data;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import java.io.IOException;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Property;
+
+/**
+ * Writes out JSON string from <tt>JSONPropertyImpl</tt>.
+ *
+ * @see JSONPropertyImpl
+ */
+public class JSONPropertySerializer extends AbstractJsonSerializer<JSONPropertyImpl> {
+
+  @Override
+  protected void doSerialize(final JSONPropertyImpl property, final JsonGenerator jgen,
+          final SerializerProvider provider) throws IOException, JsonProcessingException {
+
+    jgen.writeStartObject();
+
+    if (property.getMetadata() != null) {
+      jgen.writeStringField(Constants.JSON_METADATA, property.getMetadata().toASCIIString());
+    }
+
+    if (property.getValue().isNull()) {
+      jgen.writeBooleanField(Constants.JSON_NULL, true);
+    } else if (property.getValue().isSimple()) {
+      jgen.writeStringField(Constants.JSON_VALUE, property.getValue().asSimple().get());
+    } else if (property.getValue().isGeospatial() || property.getValue().isCollection()) {
+      property(jgen, property, Constants.JSON_VALUE);
+    } else if (property.getValue().isComplex()) {
+      for (Property cproperty : property.getValue().asComplex().get()) {
+        property(jgen, cproperty, cproperty.getName());
+      }
+    }
+
+    jgen.writeEndObject();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
new file mode 100644
index 0000000..85fabdc
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/LinkImpl.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.data;
+
+import org.apache.olingo.commons.api.data.Entry;
+import org.apache.olingo.commons.api.data.Feed;
+import org.apache.olingo.commons.api.data.Link;
+
+public class LinkImpl extends AbstractPayloadObject implements Link {
+
+  private static final long serialVersionUID = -3449344217160035501L;
+
+  private String title;
+
+  private String rel;
+
+  private String href;
+
+  private String type;
+
+  private String mediaETag;
+
+  private Entry entry;
+
+  private Feed feed;
+
+  @Override
+  public String getTitle() {
+    return title;
+  }
+
+  @Override
+  public void setTitle(final String title) {
+    this.title = title;
+  }
+
+  @Override
+  public String getRel() {
+    return rel;
+  }
+
+  @Override
+  public void setRel(final String rel) {
+    this.rel = rel;
+  }
+
+  @Override
+  public String getHref() {
+    return href;
+  }
+
+  @Override
+  public void setHref(final String href) {
+    this.href = href;
+  }
+
+  @Override
+  public String getType() {
+    return type;
+  }
+
+  @Override
+  public void setType(final String type) {
+    this.type = type;
+  }
+
+  @Override
+  public String getMediaETag() {
+    return mediaETag;
+  }
+
+  @Override
+  public void setMediaETag(final String mediaETag) {
+    this.mediaETag = mediaETag;
+  }
+
+  @Override
+  public Entry getInlineEntry() {
+    return entry;
+  }
+
+  @Override
+  public void setInlineEntry(final Entry entry) {
+    this.entry = entry;
+  }
+
+  @Override
+  public Feed getInlineFeed() {
+    return feed;
+  }
+
+  @Override
+  public void setInlineFeed(final Feed feed) {
+    this.feed = feed;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/NullValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/NullValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/NullValueImpl.java
new file mode 100644
index 0000000..1fca329
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/NullValueImpl.java
@@ -0,0 +1,35 @@
+/*
+ * 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.core.data;
+
+import org.apache.olingo.commons.api.data.NullValue;
+
+public class NullValueImpl extends AbstractValue implements NullValue {
+
+  @Override
+  public boolean isNull() {
+    return true;
+  }
+
+  @Override
+  public Void get() {
+    return null;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
new file mode 100644
index 0000000..e882be2
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonDeserializer.java
@@ -0,0 +1,44 @@
+/*
+ * 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.core.data;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+
+import java.io.IOException;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public abstract class ODataJacksonDeserializer<T> extends JsonDeserializer<T> {
+
+  protected ODataServiceVersion version;
+
+  protected abstract T doDeserialize(JsonParser jp, DeserializationContext ctxt)
+          throws IOException, JsonProcessingException;
+
+  @Override
+  public T deserialize(final JsonParser jp, final DeserializationContext ctxt)
+          throws IOException, JsonProcessingException {
+
+    version = (ODataServiceVersion) ctxt.findInjectableValue(ODataServiceVersion.class.getName(), null, null);
+    return doDeserialize(jp, ctxt);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java
new file mode 100644
index 0000000..31ed332
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/ODataJacksonSerializer.java
@@ -0,0 +1,45 @@
+/*
+ * 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.core.data;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+import java.io.IOException;
+
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public abstract class ODataJacksonSerializer<T> extends JsonSerializer<T> {
+
+  protected ODataServiceVersion version;
+
+  protected abstract void doSerialize(T value, JsonGenerator jgen, SerializerProvider provider)
+          throws IOException, JsonProcessingException;
+
+  @Override
+  public void serialize(final T value, final JsonGenerator jgen, final SerializerProvider provider)
+          throws IOException, JsonProcessingException {
+
+    version = (ODataServiceVersion) provider.getAttribute(ODataServiceVersion.class);
+    doSerialize(value, jgen, provider);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java
new file mode 100644
index 0000000..2d0a6bc
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/PrimitiveValueImpl.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.data;
+
+import org.apache.olingo.commons.api.data.PrimitiveValue;
+
+public class PrimitiveValueImpl extends AbstractValue implements PrimitiveValue {
+
+  private final String value;
+
+  public PrimitiveValueImpl(final String value) {
+    this.value = value;
+  }
+
+  @Override
+  public boolean isSimple() {
+    return true;
+  }
+
+  @Override
+  public String get() {
+    return value;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLErrorImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLErrorImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLErrorImpl.java
new file mode 100644
index 0000000..a8c3d84
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/XMLErrorImpl.java
@@ -0,0 +1,213 @@
+/*
+ * 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.core.data;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
+import java.util.Map;
+import org.apache.olingo.commons.api.domain.ODataError;
+
+/**
+ * This class represents an OData error returned as JSON.
+ */
+public class XMLErrorImpl extends AbstractPayloadObject implements ODataError {
+
+  private static final long serialVersionUID = -3476499168507242932L;
+
+  @JacksonXmlText(false)
+  private String code;
+
+  @JsonProperty
+  private Message message;
+
+  @JsonProperty(required = false)
+  private InnerError innererror;
+
+  @Override
+  public String getCode() {
+    return code;
+  }
+
+  /**
+   * Sets error code.
+   *
+   * @param code error code.
+   */
+  public void setCode(final String code) {
+    this.code = code;
+  }
+
+  @JsonIgnore
+  @Override
+  public String getMessageLang() {
+    return this.message == null ? null : this.message.getLang();
+  }
+
+  @JsonIgnore
+  @Override
+  public String getMessageValue() {
+    return this.message == null ? null : this.message.getValue();
+  }
+
+  /**
+   * Sets the value of the message property.
+   *
+   * @param value allowed object is {@link Error.Message }
+   *
+   */
+  public void setMessage(final Message value) {
+    this.message = value;
+  }
+
+  @JsonIgnore
+  @Override
+  public String getInnerErrorMessage() {
+    return this.innererror == null ? null : this.innererror.getMessage().getValue();
+  }
+
+  @JsonIgnore
+  @Override
+  public String getInnerErrorType() {
+    return this.innererror == null ? null : this.innererror.getType().getValue();
+  }
+
+  @JsonIgnore
+  @Override
+  public String getInnerErrorStacktrace() {
+    return this.innererror == null ? null : this.innererror.getStacktrace().getValue();
+  }
+
+  static class TextChildContainer extends AbstractPayloadObject {
+
+    private static final long serialVersionUID = -8908394095210115904L;
+
+    public TextChildContainer() {
+      super();
+    }
+
+    public TextChildContainer(final String value) {
+      super();
+      this.value = value;
+    }
+
+    @JsonCreator
+    public TextChildContainer(final Map<String, Object> props) {
+      super();
+      this.value = (String) props.get("");
+    }
+
+    private String value;
+
+    public String getValue() {
+      return value;
+    }
+
+    public void setValue(final String value) {
+      this.value = value;
+    }
+  }
+
+  /**
+   * Error message.
+   */
+  public static class Message extends TextChildContainer {
+
+    private static final long serialVersionUID = 2577818040815637859L;
+
+    private String lang;
+
+    public Message() {
+      super();
+    }
+
+    @JsonCreator
+    public Message(final Map<String, Object> props) {
+      super(props);
+      this.lang = (String) props.get("lang");
+    }
+
+    /**
+     * Gets language.
+     *
+     * @return language.
+     */
+    public String getLang() {
+      return lang;
+    }
+
+    /**
+     * Sets language.
+     *
+     * @param lang language.
+     */
+    public void setLang(final String lang) {
+      this.lang = lang;
+    }
+  }
+
+  /**
+   * Inner error.
+   */
+  static class InnerError extends AbstractPayloadObject {
+
+    private static final long serialVersionUID = -3920947476143537640L;
+
+    private TextChildContainer message;
+
+    private TextChildContainer type;
+
+    private TextChildContainer stacktrace;
+
+    private InnerError internalexception;
+
+    public TextChildContainer getMessage() {
+      return message;
+    }
+
+    public void setMessage(final TextChildContainer message) {
+      this.message = message;
+    }
+
+    public TextChildContainer getType() {
+      return type;
+    }
+
+    public void setType(final TextChildContainer type) {
+      this.type = type;
+    }
+
+    public TextChildContainer getStacktrace() {
+      return stacktrace;
+    }
+
+    public void setStacktrace(final TextChildContainer stacktrace) {
+      this.stacktrace = stacktrace;
+    }
+
+    public InnerError getInternalexception() {
+      return internalexception;
+    }
+
+    public void setInternalexception(final InnerError internalexception) {
+      this.internalexception = internalexception;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
new file mode 100644
index 0000000..b0bd6e0
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/JSONLinkCollectionImpl.java
@@ -0,0 +1,118 @@
+/*
+ * 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.core.data.v3;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+import org.apache.olingo.commons.core.data.AbstractPayloadObject;
+
+/**
+ * Link from an entry, represented via JSON.
+ */
+public class JSONLinkCollectionImpl extends AbstractPayloadObject implements LinkCollection {
+
+  private static final long serialVersionUID = -5006368367235783907L;
+
+  /**
+   * JSON link URL representation.
+   */
+  static class JSONLinkURL extends AbstractPayloadObject {
+
+    private static final long serialVersionUID = 5365055617973271468L;
+
+    private URI url;
+
+    public URI getUrl() {
+      return url;
+    }
+
+    public void setUrl(final URI url) {
+      this.url = url;
+    }
+  }
+
+  @JsonProperty(value = "odata.metadata", required = false)
+  private URI metadata;
+
+  @JsonProperty(required = false)
+  private URI url;
+
+  @JsonProperty(value = "value", required = false)
+  private final List<JSONLinkURL> links = new ArrayList<JSONLinkURL>();
+
+  @JsonProperty(value = "odata.nextLink", required = false)
+  private String next;
+
+  /**
+   * Gets the metadata URI.
+   */
+  public URI getMetadata() {
+    return metadata;
+  }
+
+  /**
+   * Sets the metadata URI.
+   *
+   * @param metadata metadata URI.
+   */
+  public void setMetadata(final URI metadata) {
+    this.metadata = metadata;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @JsonIgnore
+  @Override
+  public List<URI> getLinks() {
+    final List<URI> result = new ArrayList<URI>();
+
+    if (this.url == null) {
+      for (JSONLinkURL link : links) {
+        result.add(link.getUrl());
+      }
+    } else {
+      result.add(this.url);
+    }
+
+    return result;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @JsonIgnore
+  @Override
+  public void setNext(final URI next) {
+    this.next = next == null ? null : next.toASCIIString();
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @JsonIgnore
+  @Override
+  public URI getNext() {
+    return next == null ? null : URI.create(next);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.java
new file mode 100644
index 0000000..8d9001c
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/v3/XMLLinkCollectionImpl.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.commons.core.data.v3;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.olingo.commons.api.data.v3.LinkCollection;
+
+public class XMLLinkCollectionImpl implements LinkCollection {
+
+  private final List<URI> links = new ArrayList<URI>();
+
+  private URI next;
+
+  /**
+   * Constructor.
+   */
+  public XMLLinkCollectionImpl() {
+  }
+
+  /**
+   * Constructor.
+   *
+   * @param next next page link.
+   */
+  public XMLLinkCollectionImpl(final URI next) {
+    this.next = next;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public List<URI> getLinks() {
+    return links;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public void setNext(final URI next) {
+    this.next = next;
+  }
+
+  /**
+   * {@inheritDoc }
+   */
+  @Override
+  public URI getNext() {
+    return next;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/fac84b3e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java
new file mode 100644
index 0000000..567950d
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java
@@ -0,0 +1,172 @@
+/*
+ * 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.core.edm;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmComplexType;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmEnumType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EdmTypeInfo {
+
+  private static final Logger LOG = LoggerFactory.getLogger(EdmTypeInfo.class);
+
+  public static class Builder {
+
+    private String typeExpression;
+
+    private String defaultNamespace;
+
+    private Edm edm;
+
+    public Builder setTypeExpression(final String typeExpression) {
+      this.typeExpression = typeExpression;
+      return this;
+    }
+
+    public Builder setDefaultNamespace(final String defaultNamespace) {
+      this.defaultNamespace = defaultNamespace;
+      return this;
+    }
+
+    public Builder setEdm(final Edm edm) {
+      this.edm = edm;
+      return this;
+    }
+
+    public EdmTypeInfo build() {
+      return new EdmTypeInfo(edm, typeExpression.indexOf('.') == -1
+              ? defaultNamespace + "." + typeExpression
+              : typeExpression);
+    }
+  }
+
+  private final Edm edm;
+
+  private final String typeExpression;
+
+  private final boolean collection;
+
+  private final FullQualifiedName fullQualifiedName;
+
+  private EdmPrimitiveTypeKind primitiveType;
+
+  private EdmEnumType enumType;
+
+  private EdmComplexType complexType;
+
+  private EdmEntityType entityType;
+
+  private EdmTypeInfo(final Edm edm, final String typeExpression) {
+    this.edm = edm;
+    this.typeExpression = typeExpression;
+
+    String baseType;
+    final int collStartIdx = typeExpression.indexOf("Collection(");
+    final int collEndIdx = typeExpression.lastIndexOf(')');
+    if (collStartIdx == -1) {
+      baseType = typeExpression;
+      this.collection = false;
+    } else {
+      if (collEndIdx == -1) {
+        throw new IllegalArgumentException("Malformed type: " + typeExpression);
+      }
+
+      this.collection = true;
+      baseType = typeExpression.substring(collStartIdx + 11, collEndIdx);
+    }
+
+    final int lastDotIdx = baseType.lastIndexOf('.');
+    if (lastDotIdx == -1) {
+      throw new IllegalArgumentException("Cannot find namespace or alias in " + typeExpression);
+    }
+    final String namespace = baseType.substring(0, lastDotIdx);
+    final String typeName = baseType.substring(lastDotIdx + 1);
+    if (StringUtils.isBlank(typeName)) {
+      throw new IllegalArgumentException("Null or empty type name in " + typeExpression);
+    }
+
+    this.fullQualifiedName = new FullQualifiedName(namespace, typeName);
+
+    try {
+      this.primitiveType = EdmPrimitiveTypeKind.valueOf(this.fullQualifiedName.getName());
+    } catch (IllegalArgumentException e) {
+      LOG.debug("{} does not appear to refer to an Edm primitive type", this.fullQualifiedName);
+    }
+    if (this.primitiveType == null && this.edm != null) {
+      this.enumType = this.edm.getEnumType(this.fullQualifiedName);
+      if (this.enumType == null) {
+        this.complexType = this.edm.getComplexType(this.fullQualifiedName);
+        if (this.complexType == null) {
+          this.entityType = this.edm.getEntityType(this.fullQualifiedName);
+        }
+      }
+    }
+  }
+
+  public String getTypeExpression() {
+    return typeExpression;
+  }
+
+  public boolean isCollection() {
+    return collection;
+  }
+
+  public FullQualifiedName getFullQualifiedName() {
+    return fullQualifiedName;
+  }
+
+  public boolean isPrimitiveType() {
+    return this.primitiveType != null;
+  }
+
+  public EdmPrimitiveTypeKind getPrimitiveTypeKind() {
+    return primitiveType;
+  }
+
+  public boolean isEnumType() {
+    return this.enumType != null;
+  }
+
+  public EdmEnumType getEnumType() {
+    return enumType;
+  }
+
+  public boolean isComplexType() {
+    return this.complexType != null;
+  }
+
+  public EdmComplexType getComplexType() {
+    return complexType;
+  }
+
+  public boolean isEntityType() {
+    return this.entityType != null;
+  }
+
+  public EdmEntityType getEntityType() {
+    return entityType;
+  }
+
+}