You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/12/06 15:51:51 UTC
[15/21] [OLINGO-77] Refactored java package names
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmEnum.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmEnum.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmEnum.java
deleted file mode 100644
index abfae20..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmEnum.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmMember;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-
-/**
- * Implementation of the EDM enum type.
- * @see EdmEnumType
- */
-final class EdmEnum extends AbstractPrimitiveType implements EdmEnumType {
-
- private final String namespace;
- private final String name;
- private final String fullName;
- private final EdmPrimitiveType underlyingType;
- private final List<EdmMember> members;
- private final Boolean isFlags;
-
- public EdmEnum(final String namespace, final String name,
- final EdmPrimitiveType underlyingType, final List<EdmMember> members, final Boolean isFlags) {
- this.namespace = namespace;
- this.name = name;
- fullName = namespace + '.' + name;
- uriPrefix = fullName + '\'';
- uriSuffix = "'";
- this.underlyingType = underlyingType;
- this.members = members;
- this.isFlags = isFlags;
- }
-
- @Override
- public String getNamespace() {
- return namespace;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public EdmTypeKind getKind() {
- return EdmTypeKind.ENUM;
- }
-
- @Override
- public Class<?> getDefaultType() {
- return underlyingType.getDefaultType();
- }
-
- @Override
- public EdmMember getMember(final String name) {
- for (EdmMember member : members) {
- if (member.getName().equals(name)) {
- return member;
- }
- }
- return null;
- }
-
- @Override
- public List<String> getMemberNames() {
- List<String> names = new ArrayList<String>();
- for (final EdmMember member : members) {
- names.add(member.getName());
- }
- return names;
- }
-
- @Override
- public EdmPrimitiveType getUnderlyingType() {
- return underlyingType;
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- try {
- return EdmInt64.convertNumber(parseEnumValue(value), returnType);
- } catch (final IllegalArgumentException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value, returnType), e");
- } catch (final ClassCastException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType), e");
- }
- }
-
- protected Long parseEnumValue(final String value) throws EdmPrimitiveTypeException {
- Long result = null;
- for (final String memberValue : value.split(",", isFlags ? -1 : 1)) {
- Long memberValueLong = null;
- for (final EdmMember member : members) {
- if (member.getName().equals(memberValue) || member.getValue().equals(memberValue)) {
- memberValueLong = Long.decode(member.getValue());
- }
- }
- if (memberValueLong == null) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)");
- }
- result = result == null ? memberValueLong : result | memberValueLong;
- }
- return result;
- }
-
- @Override
- protected String internalValueToString(final Object value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long) {
- return constructEnumValue(((Number) value).longValue());
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
- }
- }
-
- protected String constructEnumValue(final long value) throws EdmPrimitiveTypeException {
- long remaining = value;
- StringBuilder result = new StringBuilder();
-
- for (final EdmMember member : members) {
- final long memberValue = Long.parseLong(member.getValue());
- if ((memberValue & remaining) == memberValue) {
- if (result.length() > 0) {
- result.append(',');
- }
- result.append(member.getName());
- remaining ^= memberValue;
- }
- }
-
- if (remaining != 0) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- return result.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGuid.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGuid.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGuid.java
deleted file mode 100644
index beb4757..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGuid.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import java.util.UUID;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-/**
- * Implementation of the EDM primitive type Guid.
- */
-final class EdmGuid extends SingletonPrimitiveType {
-
- private static final String PATTERN = "\\p{XDigit}{8}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{12}";
- private static final EdmGuid instance = new EdmGuid();
-
- public static EdmGuid getInstance() {
- return instance;
- }
-
- @Override
- public Class<?> getDefaultType() {
- return UUID.class;
- }
-
- @Override
- public boolean validate(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) {
- return value == null ? isNullable == null || isNullable : validateLiteral(value);
- }
-
- private boolean validateLiteral(final String value) {
- return value.matches(PATTERN);
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode,
- final Class<T> returnType) throws EdmPrimitiveTypeException {
- UUID result;
- if (validateLiteral(value)) {
- result = UUID.fromString(value);
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)");
- }
-
- if (returnType.isAssignableFrom(UUID.class)) {
- return returnType.cast(result);
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
- }
- }
-
- @Override
- protected <T> String internalValueToString(final T value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- if (value instanceof UUID) {
- return ((UUID) value).toString();
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt16.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt16.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt16.java
deleted file mode 100644
index 53804e5..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt16.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import java.math.BigInteger;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-/**
- * Implementation of the EDM primitive type Int16.
- */
-final class EdmInt16 extends SingletonPrimitiveType {
-
- private static final EdmInt16 instance = new EdmInt16();
-
- public static EdmInt16 getInstance() {
- return instance;
- }
-
- @Override
- public boolean isCompatible(final EdmPrimitiveType primitiveType) {
- return primitiveType instanceof Uint7
- || primitiveType instanceof EdmByte
- || primitiveType instanceof EdmSByte
- || primitiveType instanceof EdmInt16;
- }
-
- @Override
- public Class<?> getDefaultType() {
- return Short.class;
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- Short valueShort;
- try {
- valueShort = Short.parseShort(value);
- } catch (final NumberFormatException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);
- }
-
- try {
- return EdmInt64.convertNumber(valueShort, returnType);
- } catch (final IllegalArgumentException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value, returnType), e");
- } catch (final ClassCastException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType), e");
- }
- }
-
- @Override
- protected <T> String internalValueToString(final T value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- if (value instanceof Byte || value instanceof Short) {
- return value.toString();
- } else if (value instanceof Integer || value instanceof Long) {
- if (((Number) value).longValue() >= Short.MIN_VALUE
- && ((Number) value).longValue() <= Short.MAX_VALUE) {
- return value.toString();
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- } else if (value instanceof BigInteger) {
- if (((BigInteger) value).bitLength() < Short.SIZE) {
- return value.toString();
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt32.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt32.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt32.java
deleted file mode 100644
index bd041c7..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt32.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import java.math.BigInteger;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-/**
- * Implementation of the EDM primitive type Int32.
- */
-final class EdmInt32 extends SingletonPrimitiveType {
-
- private static final EdmInt32 instance = new EdmInt32();
-
- public static EdmInt32 getInstance() {
- return instance;
- }
-
- @Override
- public boolean isCompatible(final EdmPrimitiveType primitiveType) {
- return primitiveType instanceof Uint7
- || primitiveType instanceof EdmByte
- || primitiveType instanceof EdmSByte
- || primitiveType instanceof EdmInt16
- || primitiveType instanceof EdmInt32;
- }
-
- @Override
- public Class<?> getDefaultType() {
- return Integer.class;
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- Integer valueInteger;
- try {
- valueInteger = Integer.parseInt(value);
- } catch (final NumberFormatException e) {
- throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);
- }
-
- try {
- return EdmInt64.convertNumber(valueInteger, returnType);
- } catch (final IllegalArgumentException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value, returnType), e");
- } catch (final ClassCastException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType), e");
- }
- }
-
- @Override
- protected <T> String internalValueToString(final T value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- if (value instanceof Byte || value instanceof Short || value instanceof Integer) {
- return value.toString();
- } else if (value instanceof Long) {
- if ((Long) value >= Integer.MIN_VALUE && (Long) value <= Integer.MAX_VALUE) {
- return value.toString();
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- } else if (value instanceof BigInteger) {
- if (((BigInteger) value).bitLength() < Integer.SIZE) {
- return value.toString();
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt64.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt64.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt64.java
deleted file mode 100644
index ac979ba..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt64.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import java.math.BigInteger;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-/**
- * Implementation of the EDM primitive type Int64.
- */
-final class EdmInt64 extends SingletonPrimitiveType {
-
- private static final EdmInt64 instance = new EdmInt64();
-
- public static EdmInt64 getInstance() {
- return instance;
- }
-
- @Override
- public boolean isCompatible(final EdmPrimitiveType primitiveType) {
- return primitiveType instanceof Uint7
- || primitiveType instanceof EdmByte
- || primitiveType instanceof EdmSByte
- || primitiveType instanceof EdmInt16
- || primitiveType instanceof EdmInt32
- || primitiveType instanceof EdmInt64;
- }
-
- @Override
- public Class<?> getDefaultType() {
- return Long.class;
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- Long valueLong;
- try {
- valueLong = Long.parseLong(value);
- } catch (final NumberFormatException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);
- }
-
- try {
- return convertNumber(valueLong, returnType);
- } catch (final IllegalArgumentException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value, returnType), e");
- } catch (final ClassCastException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType), e");
- }
- }
-
- /**
- * Converts a whole {@link Number} value into the requested return type if possible.
- * @param value the value
- * @param returnType the class of the returned value; it must be one of {@link BigInteger}, {@link Long},
- * {@link Integer}, {@link Short}, or {@link Byte}
- * @return the converted value
- * @throws IllegalArgumentException if the conversion is not possible
- * @throws ClassCastException if the return type is not allowed
- */
- protected static <T> T convertNumber(final Number value, final Class<T> returnType) throws IllegalArgumentException,
- ClassCastException {
- if (returnType.isAssignableFrom(Long.class)) {
- return returnType.cast(value.longValue());
- } else if (returnType.isAssignableFrom(BigInteger.class)) {
- return returnType.cast(BigInteger.valueOf(value.longValue()));
- } else if (returnType.isAssignableFrom(Byte.class)) {
- if (value.longValue() >= Byte.MIN_VALUE && value.longValue() <= Byte.MAX_VALUE) {
- return returnType.cast(value.byteValue());
- } else {
- throw new IllegalArgumentException();
- }
- } else if (returnType.isAssignableFrom(Short.class)) {
- if (value.longValue() >= Short.MIN_VALUE && value.longValue() <= Short.MAX_VALUE) {
- return returnType.cast(value.shortValue());
- } else {
- throw new IllegalArgumentException();
- }
- } else if (returnType.isAssignableFrom(Integer.class)) {
- if (value.longValue() >= Integer.MIN_VALUE && value.longValue() <= Integer.MAX_VALUE) {
- return returnType.cast(value.intValue());
- } else {
- throw new IllegalArgumentException();
- }
- } else {
- throw new ClassCastException("unsupported return type " + returnType.getSimpleName());
- }
- }
-
- @Override
- protected <T> String internalValueToString(final T value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long) {
- return value.toString();
- } else if (value instanceof BigInteger) {
- if (((BigInteger) value).bitLength() < Long.SIZE) {
- return value.toString();
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNull.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNull.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNull.java
deleted file mode 100644
index 758a7f0..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNull.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-//TODO: Is this class still necessary?
-/**
- * Implementation of the simple type Null.
- */
-final class EdmNull extends SingletonPrimitiveType {
-
- private static final EdmNull instance = new EdmNull();
-
- public static EdmNull getInstance() {
- return instance;
- }
-
- @Override
- public boolean equals(final Object obj) {
- return this == obj || obj == null;
- }
-
- @Override
- public int hashCode() {
- return 0;
- }
-
- @Override
- public Class<?> getDefaultType() {
- return null;
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- return null;
- }
-
- @Override
- protected <T> String internalValueToString(final T value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- return null;
- }
-
- @Override
- public String toUriLiteral(final String literal) {
- return "null";
- }
-
- @Override
- public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmPrimitiveTypeKind.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmPrimitiveTypeKind.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmPrimitiveTypeKind.java
deleted file mode 100644
index 5bd7954..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmPrimitiveTypeKind.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-
-//TODO: Should we delete this typekind and use a facade?
-public enum EdmPrimitiveTypeKind {
- Binary, Boolean, Byte, Date, DateTimeOffset, Decimal, Double, Duration, Guid,
- Int16, Int32, Int64, SByte, Single, String, TimeOfDay;
-
- /**
- * Returns the {@link FullQualifiedName} for this type kind.
- * @return {@link FullQualifiedName}
- */
- public FullQualifiedName getFullQualifiedName() {
- return new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, toString());
- }
-
- /**
- * Returns an instance for this {@link EdmPrimitiveTypeKind} in the form of {@link EdmPrimitiveType}.
- * @return {@link EdmPrimitiveType} instance
- */
- public EdmPrimitiveType getEdmPrimitiveTypeInstance() {
- switch (this) {
- case Binary:
- return EdmBinary.getInstance();
- case Boolean:
- return EdmBoolean.getInstance();
- case Byte:
- return EdmByte.getInstance();
- case Date:
- return EdmDate.getInstance();
- case DateTimeOffset:
- return EdmDateTimeOffset.getInstance();
- case Decimal:
- return EdmDecimal.getInstance();
- case Double:
- return EdmDouble.getInstance();
- case Duration:
- return EdmDuration.getInstance();
- case Guid:
- return EdmGuid.getInstance();
- case Int16:
- return EdmInt16.getInstance();
- case Int32:
- return EdmInt32.getInstance();
- case Int64:
- return EdmInt64.getInstance();
- case SByte:
- return EdmSByte.getInstance();
- case Single:
- return EdmSingle.getInstance();
- case String:
- return EdmString.getInstance();
- case TimeOfDay:
- return EdmTimeOfDay.getInstance();
- default:
- throw new RuntimeException("Wrong type:" + this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSByte.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSByte.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSByte.java
deleted file mode 100644
index 4fadc04..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSByte.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import java.math.BigInteger;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-/**
- * Implementation of the EDM primitive type SByte.
- */
-final class EdmSByte extends SingletonPrimitiveType {
-
- private static final EdmSByte instance = new EdmSByte();
-
- public static EdmSByte getInstance() {
- return instance;
- }
-
- @Override
- public boolean isCompatible(final EdmPrimitiveType primitiveType) {
- return primitiveType instanceof Uint7
- || primitiveType instanceof EdmSByte;
- }
-
- @Override
- public Class<?> getDefaultType() {
- return Byte.class;
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- Byte valueByte;
- try {
- valueByte = Byte.parseByte(value);
- } catch (final NumberFormatException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);
- }
-
- try {
- return EdmInt64.convertNumber(valueByte, returnType);
- } catch (final ClassCastException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType), e");
- }
- }
-
- @Override
- protected <T> String internalValueToString(final T value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- if (value instanceof Byte) {
- return value.toString();
- } else if (value instanceof Short || value instanceof Integer || value instanceof Long) {
- if (((Number) value).longValue() >= Byte.MIN_VALUE && ((Number) value).longValue() <= Byte.MAX_VALUE) {
- return value.toString();
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- } else if (value instanceof BigInteger) {
- if (((BigInteger) value).bitLength() < Byte.SIZE) {
- return value.toString();
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingle.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingle.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingle.java
deleted file mode 100644
index d9c60ce..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingle.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import java.math.BigDecimal;
-import java.util.regex.Pattern;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-/**
- * Implementation of the EDM primitive type Single.
- */
-final class EdmSingle extends SingletonPrimitiveType {
-
- private static final Pattern PATTERN = Pattern.compile(
- "(?:\\+|-)?\\p{Digit}{1,9}(?:\\.\\p{Digit}{1,9})?(?:(?:E|e)(?:\\+|-)?\\p{Digit}{1,2})?");
- private static final EdmSingle instance = new EdmSingle();
-
- public static EdmSingle getInstance() {
- return instance;
- }
-
- @Override
- public boolean isCompatible(final EdmPrimitiveType primitiveType) {
- return primitiveType instanceof Uint7
- || primitiveType instanceof EdmByte
- || primitiveType instanceof EdmSByte
- || primitiveType instanceof EdmInt16
- || primitiveType instanceof EdmInt32
- || primitiveType instanceof EdmInt64
- || primitiveType instanceof EdmSingle;
- }
-
- @Override
- public Class<?> getDefaultType() {
- return Float.class;
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- Float result = null;
- BigDecimal bigDecimalValue = null;
- // Handle special values first.
- if (value.equals(EdmDouble.NEGATIVE_INFINITY)) {
- result = Float.NEGATIVE_INFINITY;
- } else if (value.equals(EdmDouble.POSITIVE_INFINITY)) {
- result = Float.POSITIVE_INFINITY;
- } else if (value.equals(EdmDouble.NaN)) {
- result = Float.NaN;
- } else {
- // Now only "normal" numbers remain.
- if (!PATTERN.matcher(value).matches()) {
- throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)");
- }
-
- // The number format is checked above, so we don't have to catch NumberFormatException.
- bigDecimalValue = new BigDecimal(value);
- result = bigDecimalValue.floatValue();
- // "Real" infinite values have been treated already above, so we can throw an exception
- // if the conversion to a float results in an infinite value.
- if (result.isInfinite() || bigDecimalValue.compareTo(new BigDecimal(result.toString())) != 0) {
- throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)");
- }
- }
-
- if (returnType.isAssignableFrom(Float.class)) {
- return returnType.cast(result);
- } else if (result.isInfinite() || result.isNaN()) {
- if (returnType.isAssignableFrom(Double.class)) {
- return returnType.cast(result.doubleValue());
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value, returnType)");
- }
- } else {
- try {
- return EdmDecimal.convertDecimal(bigDecimalValue, returnType);
- } catch (final IllegalArgumentException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value, returnType), e");
- } catch (final ClassCastException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType), e");
- }
- }
- }
-
- @Override
- protected <T> String internalValueToString(final T value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- if (value instanceof Long || value instanceof Integer) {
- if (Math.abs(((Number) value).longValue()) < 1L << 22) {
- return value.toString();
- } else {
- throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- } else if (value instanceof Short || value instanceof Byte) {
- return value.toString();
- } else if (value instanceof Double) {
- if (((Double) value).isInfinite()) {
- return (Double) value == Double.NEGATIVE_INFINITY ? EdmDouble.NEGATIVE_INFINITY : EdmDouble.POSITIVE_INFINITY;
- } else {
- final String floatString = Float.toString(((Double) value).floatValue());
- if (floatString.equals(((Double) value).toString())) {
- return floatString;
- } else {
- throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- }
- } else if (value instanceof Float) {
- return (Float) value == Float.NEGATIVE_INFINITY ? EdmDouble.NEGATIVE_INFINITY :
- (Float) value == Float.POSITIVE_INFINITY ? EdmDouble.POSITIVE_INFINITY : value.toString();
- } else if (value instanceof BigDecimal) {
- final float floatValue = ((BigDecimal) value).floatValue();
- if (!Float.isInfinite(floatValue) && BigDecimal.valueOf(floatValue).compareTo((BigDecimal) value) == 0) {
- return ((BigDecimal) value).toString();
- } else {
- throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
- }
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
deleted file mode 100644
index 375bbae..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmString.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import java.util.regex.Pattern;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-/**
- * Implementation of the EDM primitive type String.
- */
-final class EdmString extends SingletonPrimitiveType {
-
- private static final Pattern PATTERN_ASCII = Pattern.compile("\\p{ASCII}*");
- private static final EdmString instance = new EdmString();
- {
- uriPrefix = "'";
- uriSuffix = "'";
- }
-
- public static EdmString getInstance() {
- return instance;
- }
-
- @Override
- public Class<?> getDefaultType() {
- return String.class;
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- if (isUnicode != null && !isUnicode && !PATTERN_ASCII.matcher(value).matches()
- || maxLength != null && maxLength < value.length()) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_FACETS_NOT_MATCHED.addContent(value, facets)");
- }
-
- if (returnType.isAssignableFrom(String.class)) {
- return returnType.cast(value);
- } else {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
- }
- }
-
- @Override
- protected <T> String internalValueToString(final T value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- final String result = value instanceof String ? (String) value : String.valueOf(value);
-
- if (isUnicode != null && !isUnicode && !PATTERN_ASCII.matcher(result).matches()
- || maxLength != null && maxLength < result.length()) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_FACETS_NOT_MATCHED.addContent(value, facets)");
- }
-
- return result;
- }
-
- @Override
- public String toUriLiteral(final String literal) {
- if (literal == null) {
- return null;
- }
-
- final int length = literal.length();
-
- StringBuilder uriLiteral = new StringBuilder(length + 2);
- uriLiteral.append(uriPrefix);
- for (int i = 0; i < length; i++) {
- final char c = literal.charAt(i);
- if (c == '\'') {
- uriLiteral.append(c);
- }
- uriLiteral.append(c);
- }
- uriLiteral.append(uriSuffix);
- return uriLiteral.toString();
- }
-
- @Override
- public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException {
- return literal == null ? null : super.fromUriLiteral(literal).replace("''", "'");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDay.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDay.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDay.java
deleted file mode 100644
index 6e93e15..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDay.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-final class EdmTimeOfDay extends SingletonPrimitiveType {
-
- private static final Pattern PATTERN = Pattern.compile(
- "(\\p{Digit}{2}):(\\p{Digit}{2})(?::(\\p{Digit}{2})(\\.(\\p{Digit}{0,3}?)0*)?)?");
- private static final EdmTimeOfDay instance = new EdmTimeOfDay();
-
- public static EdmTimeOfDay getInstance() {
- return instance;
- }
-
- @Override
- public Class<?> getDefaultType() {
- return Calendar.class;
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- final Matcher matcher = PATTERN.matcher(value);
- if (!matcher.matches()) {
- throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)");
- }
-
- Calendar dateTimeValue = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- dateTimeValue.clear();
- dateTimeValue.set(Calendar.HOUR_OF_DAY, Byte.parseByte(matcher.group(1)));
- dateTimeValue.set(Calendar.MINUTE, Byte.parseByte(matcher.group(2)));
- dateTimeValue.set(Calendar.SECOND, matcher.group(3) == null ? 0 : Byte.parseByte(matcher.group(3)));
-
- if (matcher.group(4) != null) {
- if (matcher.group(4).length() == 1 || matcher.group(4).length() > 13) {
- throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)");
- }
- final String decimals = matcher.group(5);
- if (decimals.length() > (precision == null ? 0 : precision)) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_FACETS_NOT_MATCHED.addContent(value, facets)");
- }
- final String milliSeconds = decimals + "000".substring(decimals.length());
- dateTimeValue.set(Calendar.MILLISECOND, Short.parseShort(milliSeconds));
- }
-
- try {
- return EdmDateTimeOffset.convertDateTime(dateTimeValue, returnType);
- } catch (final IllegalArgumentException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value), e");
- } catch (final ClassCastException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType), e");
- }
- }
-
- @Override
- protected <T> String internalValueToString(final T value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- final Calendar dateTimeValue = EdmDateTimeOffset.createDateTime(value);
-
- StringBuilder result = new StringBuilder(8); // Eight characters are enough for "normal" times.
- EdmDateTimeOffset.appendTwoDigits(result, dateTimeValue.get(Calendar.HOUR_OF_DAY));
- result.append(':');
- EdmDateTimeOffset.appendTwoDigits(result, dateTimeValue.get(Calendar.MINUTE));
- result.append(':');
- EdmDateTimeOffset.appendTwoDigits(result, dateTimeValue.get(Calendar.SECOND));
-
- try {
- EdmDateTimeOffset.appendMilliseconds(result, dateTimeValue.get(Calendar.MILLISECOND), precision);
- } catch (final IllegalArgumentException e) {
- throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_FACETS_NOT_MATCHED.addContent(value, facets), e");
- }
-
- return result.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/SingletonPrimitiveType.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/SingletonPrimitiveType.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/SingletonPrimitiveType.java
deleted file mode 100644
index 9f9d703..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/SingletonPrimitiveType.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-
-/**
- * Abstract singleton implementation of the EDM primitive-type interface.
- */
-abstract class SingletonPrimitiveType extends AbstractPrimitiveType {
-
- @Override
- public boolean equals(final Object obj) {
- return this == obj || obj != null && getClass() == obj.getClass();
- }
-
- @Override
- public int hashCode() {
- return getClass().hashCode();
- }
-
- @Override
- public String getNamespace() {
- return EDM_NAMESPACE;
- }
-
- @Override
- public String getName() {
- return getClass().getSimpleName().substring(3);
- }
-
- @Override
- public EdmTypeKind getKind() {
- return EdmTypeKind.PRIMITIVE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/Uint7.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/Uint7.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/Uint7.java
deleted file mode 100644
index 6805fc0..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/Uint7.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-
-/**
- * Implementation of the internal primitive type "unsigned 7-bit integer".
- */
-final class Uint7 extends SingletonPrimitiveType {
-
- private static final Uint7 instance = new Uint7();
-
- public static Uint7 getInstance() {
- return instance;
- }
-
- @Override
- public String getNamespace() {
- return SYSTEM_NAMESPACE;
- }
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public Class<?> getDefaultType() {
- return Byte.class;
- }
-
- @Override
- protected <T> T internalValueOfString(final String value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
- return EdmSByte.getInstance().internalValueOfString(value, isNullable, maxLength, precision, scale, isUnicode,
- returnType);
- }
-
- @Override
- protected <T> String internalValueToString(final T value,
- final Boolean isNullable, final Integer maxLength, final Integer precision,
- final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
- return EdmSByte.getInstance().internalValueToString(value, isNullable, maxLength, precision, scale, isUnicode);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImpl.java
deleted file mode 100644
index cfdf46d..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.provider;
-
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.Action;
-
-public class EdmActionImpl extends EdmOperationImpl implements EdmAction {
-
- public EdmActionImpl(final EdmProviderImpl edm, final FullQualifiedName name, final Action action) {
- super(edm, name, action, EdmTypeKind.ACTION);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImportImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImportImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImportImpl.java
deleted file mode 100644
index 19d299a..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmActionImportImpl.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.provider;
-
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.EdmActionImport;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.provider.ActionImport;
-
-public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmActionImport {
-
- private final ActionImport actionImport;
-
- public EdmActionImportImpl(final EdmProviderImpl edm, final String name, final EdmEntityContainer container,
- final ActionImport actionImport) {
- super(edm, name, container, actionImport);
- this.actionImport = actionImport;
- }
-
- @Override
- public EdmAction getAction() {
- return edm.getAction(actionImport.getAction(), null, null);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java
deleted file mode 100644
index d9136e0..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmBindingTargetImpl.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.provider;
-
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.EdmBindingTarget;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.provider.BindingTarget;
-import org.apache.olingo.commons.api.edm.provider.NavigationPropertyBinding;
-import org.apache.olingo.commons.api.edm.provider.Target;
-
-public abstract class EdmBindingTargetImpl extends EdmNamedImpl implements EdmBindingTarget {
-
- private BindingTarget target;
- private EdmEntityContainer container;
-
- public EdmBindingTargetImpl(final EdmProviderImpl edm, final EdmEntityContainer container,
- final BindingTarget target) {
- super(edm, target.getName());
- this.container = container;
- this.target = target;
- }
-
- @Override
- public EdmBindingTarget getRelatedBindingTarget(final String path) {
- EdmBindingTarget bindingTarget = null;
- List<NavigationPropertyBinding> navigationPropertyBindings = target.getNavigationPropertyBindings();
- if (navigationPropertyBindings != null) {
- for (NavigationPropertyBinding binding : navigationPropertyBindings) {
- if (binding.getPath().equals(path)) {
- Target providerTarget = binding.getTarget();
- EdmEntityContainer entityContainer = edm.getEntityContainer(providerTarget.getEntityContainer());
- if (entityContainer == null) {
- throw new EdmException("Cant find entity container with name: " + providerTarget.getEntityContainer());
- }
- String targetName = providerTarget.getTargetName();
- bindingTarget = entityContainer.getEntitySet(targetName);
- if (bindingTarget == null) {
- bindingTarget = entityContainer.getSingleton(targetName);
- if (bindingTarget != null) {
- break;
- }else{
- throw new EdmException("Cant find target with name: " + targetName);
- }
- } else {
- break;
- }
- }
- }
- }
-
- return bindingTarget;
- }
-
- @Override
- public EdmEntityContainer getEntityContainer() {
- return container;
- }
-
- @Override
- public EdmEntityType getEntityType() {
- EdmEntityType type = edm.getEntityType(target.getType());
- if (type == null) {
- throw new EdmException("CanĀ“t find entity type : " + target.getType() + "for entity set: " + target.getName());
- }
- return type;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java
deleted file mode 100644
index a6ad4ce..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmComplexTypeImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.provider;
-
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmStructuralType;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.ComplexType;
-
-public class EdmComplexTypeImpl extends EdmStructuralTypeImpl implements EdmComplexType {
-
- public EdmComplexTypeImpl(final EdmProviderImpl edm, final FullQualifiedName name, final ComplexType complexType) {
- super(edm, name, complexType, EdmTypeKind.COMPLEX);
- }
-
- @Override
- public EdmComplexType getBaseType() {
- return (EdmComplexType) baseType;
- }
-
- @Override
- protected EdmStructuralType buildBaseType(final FullQualifiedName baseTypeName) {
- EdmComplexType baseType = null;
- if (baseTypeName != null) {
- baseType = edm.getComplexType(baseTypeName);
- if (baseType == null) {
- throw new EdmException("Cant find base type with name: " + baseTypeName + " for complex type: " + getName());
- }
- }
- return baseType;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java
deleted file mode 100644
index a229ef1..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmElementImpl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.provider;
-
-import org.apache.olingo.commons.api.edm.EdmElement;
-
-public abstract class EdmElementImpl extends EdmNamedImpl implements EdmElement {
-
- public EdmElementImpl(final EdmProviderImpl edm, final String name) {
- super(edm, name);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java
deleted file mode 100644
index e9759c9..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityContainerImpl.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.provider;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.olingo.commons.api.edm.EdmActionImport;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmFunctionImport;
-import org.apache.olingo.commons.api.edm.EdmSingleton;
-import org.apache.olingo.commons.api.edm.helper.EntityContainerInfo;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.ActionImport;
-import org.apache.olingo.commons.api.edm.provider.EdmProvider;
-import org.apache.olingo.commons.api.edm.provider.EntitySet;
-import org.apache.olingo.commons.api.edm.provider.FunctionImport;
-import org.apache.olingo.commons.api.edm.provider.Singleton;
-import org.apache.olingo.commons.api.exception.ODataException;
-
-public class EdmEntityContainerImpl extends EdmNamedImpl implements EdmEntityContainer {
-
- private final FullQualifiedName entityContainerName;
- private final EdmProvider provider;
- private final Map<String, EdmSingleton> singletons = new HashMap<String, EdmSingleton>();
- private final Map<String, EdmEntitySet> entitySets = new HashMap<String, EdmEntitySet>();
- private final Map<String, EdmActionImport> actionImports = new HashMap<String, EdmActionImport>();
- private final Map<String, EdmFunctionImport> functionImports = new HashMap<String, EdmFunctionImport>();
-
- public EdmEntityContainerImpl(final EdmProviderImpl edm, final EdmProvider provider,
- final EntityContainerInfo entityContainerInfo) {
- super(edm, entityContainerInfo.getContainerName().getName());
- this.provider = provider;
- entityContainerName = entityContainerInfo.getContainerName();
- }
-
- @Override
- public String getNamespace() {
- return entityContainerName.getNamespace();
- }
-
- @Override
- public EdmSingleton getSingleton(final String singletonName) {
- EdmSingleton singleton = singletons.get(singletonName);
- if (singleton == null) {
- try {
- Singleton providerSingleton = provider.getSingleton(entityContainerName, singletonName);
- if (providerSingleton != null) {
- singleton = new EdmSingletonImpl(edm, this, providerSingleton);
- singletons.put(singletonName, singleton);
- }
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
- return singleton;
- }
-
- @Override
- public EdmEntitySet getEntitySet(final String entitySetName) {
- EdmEntitySet entitySet = entitySets.get(entitySetName);
- if (entitySet == null) {
- try {
- EntitySet providerEntitySet = provider.getEntitySet(entityContainerName, entitySetName);
- if (providerEntitySet != null) {
- entitySet = new EdmEntitySetImpl(edm, this, providerEntitySet);
- entitySets.put(entitySetName, entitySet);
- }
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
- return entitySet;
- }
-
- @Override
- public EdmActionImport getActionImport(final String actionImportName) {
- EdmActionImport actionImport = actionImports.get(actionImportName);
- if (actionImport == null) {
- try {
- ActionImport providerImport = provider.getActionImport(entityContainerName, actionImportName);
- if (providerImport != null) {
- actionImport = new EdmActionImportImpl(edm, actionImportName, this, providerImport);
- actionImports.put(actionImportName, actionImport);
- }
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
- return actionImport;
- }
-
- @Override
- public EdmFunctionImport getFunctionImport(final String functionImportName) {
- EdmFunctionImport functionImport = functionImports.get(functionImportName);
- if (functionImport == null) {
- try {
- FunctionImport providerImport = provider.getFunctionImport(entityContainerName, functionImportName);
- if (providerImport != null) {
- functionImport = new EdmFunctionImportImpl(edm, functionImportName, this, providerImport);
- functionImports.put(functionImportName, functionImport);
- }
- } catch (ODataException e) {
- throw new EdmException(e);
- }
- }
- return functionImport;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntitySetImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntitySetImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntitySetImpl.java
deleted file mode 100644
index 86fc331..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntitySetImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.provider;
-
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.provider.EntitySet;
-
-public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntitySet {
-
- public EdmEntitySetImpl(final EdmProviderImpl edm, final EdmEntityContainer container, final EntitySet entitySet) {
- super(edm, container, entitySet);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/82ae6060/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java b/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java
deleted file mode 100644
index bed0be9..0000000
--- a/odata4-lib/odata4-commons-core/src/main/java/org/apache/olingo/commons/core/edm/provider/EdmEntityTypeImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.commons.core.edm.provider;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
-import org.apache.olingo.commons.api.edm.EdmStructuralType;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.api.edm.helper.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.provider.EntityType;
-import org.apache.olingo.commons.api.edm.provider.PropertyRef;
-
-public class EdmEntityTypeImpl extends EdmStructuralTypeImpl implements EdmEntityType {
-
- private EntityType entityType;
- private final List<String> keyPredicateNames = new ArrayList<String>();
- private final HashMap<String, EdmKeyPropertyRef> keyPropertyRefs = new HashMap<String, EdmKeyPropertyRef>();
- private final EdmEntityType entityBaseType;
-
- public EdmEntityTypeImpl(final EdmProviderImpl edm, final FullQualifiedName name, final EntityType entityType) {
- super(edm, name, entityType, EdmTypeKind.ENTITY);
- this.entityType = entityType;
- if (baseType == null) {
- entityBaseType = null;
- if (entityType.getKey() == null && !entityType.isAbstract()) {
- throw new EdmException("Non-Abstract entity types must define a key.");
- }
- for (PropertyRef ref : entityType.getKey()) {
- EdmKeyPropertyRef edmKeyRef = new EdmKeyPropertyRefImpl(this, ref);
- if (ref.getAlias() != null) {
- keyPredicateNames.add(ref.getAlias());
- keyPropertyRefs.put(ref.getAlias(), edmKeyRef);
- } else {
- keyPredicateNames.add(ref.getPropertyName());
- keyPropertyRefs.put(ref.getPropertyName(), edmKeyRef);
- }
- }
- } else {
- entityBaseType = (EdmEntityType) baseType;
- }
-
- }
-
- @Override
- public boolean hasStream() {
- return entityType.hasStream();
- }
-
- @Override
- public EdmEntityType getBaseType() {
- return entityBaseType;
- }
-
- @Override
- public List<String> getKeyPredicateNames() {
- if (baseType != null) {
- return entityBaseType.getKeyPredicateNames();
- } else {
- return keyPredicateNames;
- }
- }
-
- @Override
- public List<EdmKeyPropertyRef> getKeyPropertyRefs() {
- if (baseType != null) {
- return entityBaseType.getKeyPropertyRefs();
- } else {
- //TODO: Cache
- return new ArrayList<EdmKeyPropertyRef>(keyPropertyRefs.values());
- }
- }
-
- @Override
- public EdmKeyPropertyRef getKeyPropertyRef(final String keyPredicateName) {
- if (baseType != null) {
- return entityBaseType.getKeyPropertyRef(keyPredicateName);
- } else {
- return keyPropertyRefs.get(keyPredicateName);
- }
- }
-
- @Override
- protected EdmStructuralType buildBaseType(final FullQualifiedName baseTypeName) {
- EdmEntityType baseType = null;
- if (baseTypeName != null) {
- baseType = edm.getEntityType(baseTypeName);
- if (baseType == null) {
- throw new EdmException("Cant find base type with name: " + baseTypeName + " for entity type: " + getName());
- }
- }
- return baseType;
- }
-
-}