All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.olingo.commons.api.edm.EdmPrimitiveType Maven / Gradle / Ivy

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.olingo.commons.api.edm;

/**
 * EdmPrimitiveType is a primitive type as defined in the Entity Data Model (EDM).
 * 
* There are methods to convert EDM primitive types from and to Java objects, respectively. The following Java types are * supported: * * * * * * * * * * * * * * * * * * * * * * *
EDM primitive typeJava types
Binarybyte[], {@link Byte}[]
Boolean{@link Boolean}
Byte{@link Short}, {@link Byte}, {@link Integer}, {@link Long}, {@link java.math.BigInteger} *
Date{@link java.util.Calendar}, {@link java.util.Date}, {@link java.sql.Timestamp}, * {@link java.sql.Time}, {@link Long}
DateTimeOffset{@link java.sql.Timestamp}, {@link java.util.Calendar}, {@link java.util.Date}, * {@link java.sql.Time}, {@link Long}
Decimal{@link java.math.BigDecimal}, {@link java.math.BigInteger}, {@link Double}, {@link Float}, * {@link Byte}, {@link Short}, {@link Integer}, {@link Long}
Double{@link Double}, {@link Float}, {@link java.math.BigDecimal}, {@link Byte}, {@link Short}, * {@link Integer}, {@link Long}
Duration{@link java.math.BigDecimal}, {@link java.math.BigInteger}, {@link Double}, {@link Float}, * {@link Byte}, {@link Short}, {@link Integer}, {@link Long}
Guid{@link java.util.UUID}
Int16{@link Short}, {@link Byte}, {@link Integer}, {@link Long}, {@link java.math.BigInteger} *
Int32{@link Integer}, {@link Byte}, {@link Short}, {@link Long}, {@link java.math.BigInteger} *
Int64{@link Long}, {@link Byte}, {@link Short}, {@link Integer}, {@link java.math.BigInteger} *
SByte{@link Byte}, {@link Short}, {@link Integer}, {@link Long}, {@link java.math.BigInteger} *
Single{@link Float}, {@link Double}, {@link java.math.BigDecimal}, {@link Byte}, {@link Short}, * {@link Integer}, {@link Long}
String{@link String}
TimeOfDay{@link java.util.Calendar}, {@link java.util.Date}, {@link java.sql.Timestamp}, * {@link java.sql.Time}, {@link Long}
*

* The first Java type is the default type for the respective EDM primitive type. *

*

* For all EDM primitive types, the Nullable facet is taken into account. For Binary and * String, MaxLength is also applicable. For String, the facet * Unicode is considered additionally. The EDM primitive types DateTimeOffset, * Decimal, Duration, and TimeOfDay can have a Precision facet. * Additionally, Decimal can have the facet Scale. *

*/ public interface EdmPrimitiveType extends EdmType { String EDM_NAMESPACE = "Edm"; /** * Checks type compatibility. * * @param primitiveType the {@link EdmPrimitiveType} to be tested for compatibility * @return true if the provided type is compatible to this type */ boolean isCompatible(EdmPrimitiveType primitiveType); /** * Returns the default Java type for this EDM primitive type as described in the documentation of * {@link EdmPrimitiveType}. * * @return the default Java type */ Class getDefaultType(); /** * Validates literal value. * * @param value the literal value * @param isNullable whether the null value is allowed * @param maxLength the maximum length * @param precision the precision * @param scale the scale * @param isUnicode whether non-ASCII characters are allowed (relevant only for Edm.String) * @return true if the validation is successful */ boolean validate(String value, Boolean isNullable, Integer maxLength, Integer precision, Integer scale, Boolean isUnicode); /** * Converts literal representation of value to system data type. * * @param value the literal representation of value * @param isNullable whether the null value is allowed * @param maxLength the maximum length * @param precision the precision * @param scale the scale * @param isUnicode whether non-ASCII characters are allowed (relevant only for Edm.String) * @param returnType the class of the returned value; it must be one of the list in the documentation of * {@link EdmPrimitiveType} * @throws EdmPrimitiveTypeException * @return the value as an instance of the class the parameter returnType indicates */ T valueOfString(String value, Boolean isNullable, Integer maxLength, Integer precision, Integer scale, Boolean isUnicode, Class returnType) throws EdmPrimitiveTypeException; /** * Converts system data type to literal representation of value. *

* Returns null if value is null and null is an allowed value. *

* * @param value the Java value as Object; its type must be one of the list in the documentation of * {@link EdmPrimitiveType} * @param isNullable whether the null value is allowed * @param maxLength the maximum length * @param precision the precision * @param scale the scale * @param isUnicode whether non-ASCII characters are allowed (relevant only for Edm.String) * @throws EdmPrimitiveTypeException * @return literal representation as String */ String valueToString(Object value, Boolean isNullable, Integer maxLength, Integer precision, Integer scale, Boolean isUnicode) throws EdmPrimitiveTypeException; /** * Converts default literal representation to URI literal representation. *

* Returns null if the literal is null. Does not perform any validation. *

* * @param literal the literal in default representation * @return URI literal representation as String */ String toUriLiteral(String literal); /** * Converts URI literal representation to default literal representation. *

* Returns null if the literal is null. Checks the presence of a required prefix and of * required surrounding quotation marks but does not perform any further validation. *

* * @param literal the literal in URI representation * @return default literal representation as String * @throws EdmPrimitiveTypeException if a required prefix or required surrounding quotation marks are missing */ String fromUriLiteral(String literal) throws EdmPrimitiveTypeException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy