Java Code Examples for org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind#valueOfFQN()
The following examples show how to use
org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind#valueOfFQN() .
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: EdmEnumTypeImpl.java From olingo-odata4 with Apache License 2.0 | 6 votes |
public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName enumName, final CsdlEnumType enumType) { super(edm, enumName, EdmTypeKind.ENUM, enumType); if (enumType.getUnderlyingType() == null) { underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32); } else { final EdmPrimitiveTypeKind underlyingTypeKind = EdmPrimitiveTypeKind.valueOfFQN(enumType.getUnderlyingType()); if (underlyingTypeKind == EdmPrimitiveTypeKind.Byte || underlyingTypeKind == EdmPrimitiveTypeKind.SByte || underlyingTypeKind == EdmPrimitiveTypeKind.Int16 || underlyingTypeKind == EdmPrimitiveTypeKind.Int32 || underlyingTypeKind == EdmPrimitiveTypeKind.Int64) { underlyingType = EdmPrimitiveTypeFactory.getInstance(underlyingTypeKind); } else { throw new EdmException("Not allowed as underlying type: " + underlyingTypeKind); } } this.enumType = enumType; this.enumName = enumName; }
Example 2
Source File: Services.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private String stringValue(final Property property) { EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOfFQN(property.getType()); try { return EdmPrimitiveTypeFactory.getInstance(kind) .valueToString(property.asPrimitive(), null, null, org.apache.olingo.commons.api.Constants.DEFAULT_PRECISION, org.apache.olingo.commons.api.Constants.DEFAULT_SCALE, null); } catch (final EdmPrimitiveTypeException e) { return property.asPrimitive().toString(); } }
Example 3
Source File: AtomDeserializer.java From olingo-odata4 with Apache License 2.0 | 5 votes |
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 4
Source File: ODataBinderImpl.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private boolean isPrimiteveType(final FullQualifiedName typeName) { try { return EdmPrimitiveTypeKind.valueOfFQN(typeName) != null; } catch (IllegalArgumentException e) { return false; } }
Example 5
Source File: JsonGeoValueDeserializer.java From olingo-odata4 with Apache License 2.0 | 4 votes |
public Geospatial deserialize(final JsonNode node, final EdmTypeInfo typeInfo) { final EdmPrimitiveTypeKind actualType; if ((typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geography || typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geometry) && node.has(Constants.ATTR_TYPE)) { String nodeType = node.get(Constants.ATTR_TYPE).asText(); if (nodeType.startsWith("Geo")) { final int yIdx = nodeType.indexOf('y'); nodeType = nodeType.substring(yIdx + 1); } actualType = EdmPrimitiveTypeKind.valueOfFQN(typeInfo.getFullQualifiedName().toString() + nodeType); } else { actualType = typeInfo.getPrimitiveTypeKind(); } final Iterator<JsonNode> cooItor = node.has(Constants.JSON_COORDINATES) ? node.get(Constants.JSON_COORDINATES).elements() : Collections.<JsonNode> emptyList().iterator(); SRID srid = null; if (node.has(Constants.JSON_CRS)) { srid = SRID.valueOf( node.get(Constants.JSON_CRS).get(Constants.PROPERTIES).get(Constants.JSON_NAME).asText().split(":")[1]); } Geospatial value = null; switch (actualType) { case GeographyPoint: case GeometryPoint: value = point(cooItor, actualType, srid); break; case GeographyMultiPoint: case GeometryMultiPoint: value = multipoint(cooItor, actualType, srid); break; case GeographyLineString: case GeometryLineString: value = lineString(cooItor, actualType, srid); break; case GeographyMultiLineString: case GeometryMultiLineString: value = multiLineString(cooItor, actualType, srid); break; case GeographyPolygon: case GeometryPolygon: value = polygon(cooItor, actualType, srid); break; case GeographyMultiPolygon: case GeometryMultiPolygon: value = multiPolygon(cooItor, actualType, srid); break; case GeographyCollection: case GeometryCollection: value = collection(node.get(Constants.JSON_GEOMETRIES).elements(), actualType, srid); break; default: } return value; }