Java Code Examples for org.apache.olingo.commons.api.edm.EdmPrimitiveType#getDefaultType()

The following examples show how to use org.apache.olingo.commons.api.edm.EdmPrimitiveType#getDefaultType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ODataAdapter.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This method returns java class to read primitive values.
 *
 * @param edmProperty      EdmProperty
 * @param edmPrimitiveType EdmPrimitiveType
 * @return javaClass
 * @see EdmPrimitiveType#valueOfString(String, Boolean, Integer, Integer, Integer, Boolean, Class)
 */
private Class<?> getJavaClassForPrimitiveType(EdmProperty edmProperty, EdmPrimitiveType edmPrimitiveType) {
    Class<?> javaClass;
    if (edmProperty.getMapping() != null && edmProperty.getMapping().getMappedJavaClass() != null) {
        javaClass = edmProperty.getMapping().getMappedJavaClass();
    } else {
        javaClass = edmPrimitiveType.getDefaultType();
    }
    edmPrimitiveType.getDefaultType();
    return javaClass;
}
 
Example 2
Source File: ODataJsonDeserializer.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the primitive type's default class or the manually mapped class if present.
 * @param mapping
 * @param edmPrimitiveType
 * @return the java class to be used during deserialization
 */
private Class<?> getJavaClassForPrimitiveType(final EdmMapping mapping, final EdmPrimitiveType type) {
  final EdmPrimitiveType edmPrimitiveType =
      type.getKind() == EdmTypeKind.ENUM ? ((EdmEnumType) type).getUnderlyingType() : type
          .getKind() == EdmTypeKind.DEFINITION ? ((EdmTypeDefinition) type).getUnderlyingType() : type;
  return mapping == null || mapping.getMappedJavaClass() == null ? edmPrimitiveType.getDefaultType() : mapping
      .getMappedJavaClass();
}
 
Example 3
Source File: TripPinDataModel.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
static Class<?> getJavaClassForPrimitiveType(EdmProperty edmProperty, EdmPrimitiveType edmPrimitiveType) {
  Class<?> javaClass = null;
  if (edmProperty.getMapping() != null && edmProperty.getMapping().getMappedJavaClass() != null) {
    javaClass = edmProperty.getMapping().getMappedJavaClass();
  } else {
    javaClass = edmPrimitiveType.getDefaultType();
  }

  edmPrimitiveType.getDefaultType();
  return javaClass;
}
 
Example 4
Source File: AtomDeserializer.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private Object fromPrimitive(final XMLEventReader reader, final StartElement start,
    final EdmTypeInfo typeInfo) throws XMLStreamException, EdmPrimitiveTypeException {

  Object value = null;

  boolean foundEndProperty = false;
  while (reader.hasNext() && !foundEndProperty) {
    final XMLEvent event = reader.nextEvent();

    if (event.isStartElement() && typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
      final EdmPrimitiveTypeKind geoType =
          EdmPrimitiveTypeKind.valueOfFQN(typeInfo.getFullQualifiedName().toString());
      value = geoDeserializer.deserialize(reader, event.asStartElement(), geoType);
    }

    if (event.isCharacters() && !event.asCharacters().isWhiteSpace()
        && (typeInfo == null || !typeInfo.getPrimitiveTypeKind().isGeospatial())) {
      final String stringValue = event.asCharacters().getData();
      if (typeInfo == null) {
        value = stringValue;
      } else {
        final EdmPrimitiveType primitiveType = (EdmPrimitiveType) typeInfo.getType();
        final Class<?> returnType = primitiveType.getDefaultType().isAssignableFrom(Calendar.class)
            ? Timestamp.class : primitiveType.getDefaultType();
        value = ((EdmPrimitiveType) typeInfo.getType()).valueOfString(stringValue, true, null,
            Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, true,
            returnType);
      }
    }

    if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
      foundEndProperty = true;
    }
  }

  return value;
}
 
Example 5
Source File: VisitorOperand.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
protected Class<?> getDefaultType(final EdmPrimitiveType type) {
    return defaultTypeMapping.get(type) != null ? defaultTypeMapping.get(type) : type.getDefaultType();
}
 
Example 6
Source File: VisitorOperand.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
protected Class<?> getDefaultType(final EdmPrimitiveType type) {
  return defaultTypeMapping.get(type) != null ? defaultTypeMapping.get(type) : type.getDefaultType();
}