/** * Gets the {@link EdmPrimitiveTypeKind} from a full type expression (like <code>Edm.Int32</code>). * @param fqn String containing a full-qualified type name * @return {@link EdmPrimitiveTypeKind} object */ public static EdmPrimitiveTypeKind valueOfFQN(final String fqn) { if (!fqn.startsWith(EdmPrimitiveType.EDM_NAMESPACE + ".")) { throw new IllegalArgumentException(fqn + " does not look like an Edm primitive type"); } return valueOf(fqn.substring(4)); }
/** * Gets the {@link EdmPrimitiveTypeKind} from a full type expression (like <code>Edm.Int32</code>). * @param fqn String containing a full-qualified type name * @return {@link EdmPrimitiveTypeKind} object */ public static EdmPrimitiveTypeKind valueOfFQN(final String fqn) { if (!fqn.startsWith(EdmPrimitiveType.EDM_NAMESPACE + ".")) { throw new IllegalArgumentException(fqn + " does not look like an Edm primitive type"); } return valueOf(fqn.substring(4)); }
/** * Gets the {@link EdmPrimitiveTypeKind} from a full-qualified type name. * @param fqn full-qualified type name * @return {@link EdmPrimitiveTypeKind} object */ public static EdmPrimitiveTypeKind valueOfFQN(final FullQualifiedName fqn) { if (EdmPrimitiveType.EDM_NAMESPACE.equals(fqn.getNamespace())) { return valueOf(fqn.getName()); } else { throw new IllegalArgumentException(fqn + " does not look like an EDM primitive type."); } }
/** * Gets the {@link EdmPrimitiveTypeKind} from a full-qualified type name. * @param fqn full-qualified type name * @return {@link EdmPrimitiveTypeKind} object */ public static EdmPrimitiveTypeKind valueOfFQN(final FullQualifiedName fqn) { if (EdmPrimitiveType.EDM_NAMESPACE.equals(fqn.getNamespace())) { return valueOf(fqn.getName()); } else { throw new IllegalArgumentException(fqn + " does not look like an EDM primitive type."); } }
@Override public BuilderImpl setType(final EdmType type) { EdmPrimitiveTypeKind primitiveTypeKind = null; if (type != null) { if (type.getKind() != EdmTypeKind.PRIMITIVE) { throw new IllegalArgumentException(String.format("Provided type %s is not primitive", type)); } primitiveTypeKind = EdmPrimitiveTypeKind.valueOf(type.getName()); } return setType(primitiveTypeKind); }
@Override public BuilderImpl setType(final EdmType type) { EdmPrimitiveTypeKind primitiveTypeKind = null; if (type != null) { if (type.getKind() != EdmTypeKind.PRIMITIVE) { throw new IllegalArgumentException(String.format("Provided type %s is not primitive", type)); } primitiveTypeKind = EdmPrimitiveTypeKind.valueOf(type.getName()); } return setType(primitiveTypeKind); }
private EdmType getPrimitiveType(final FullQualifiedName fullQualifiedName) { if (EdmPrimitiveType.EDM_NAMESPACE.equals(fullQualifiedName.getNamespace())) { final EdmPrimitiveTypeKind primitiveTypeKind = EdmPrimitiveTypeKind.valueOf(fullQualifiedName.getName()); return primitiveTypeKind == null ? null : odata.createPrimitiveTypeInstance(primitiveTypeKind); } else { return null; } }
private EdmType getPrimitiveType(final FullQualifiedName fullQualifiedName) { if (EdmPrimitiveType.EDM_NAMESPACE.equals(fullQualifiedName.getNamespace())) { final EdmPrimitiveTypeKind primitiveTypeKind = EdmPrimitiveTypeKind.valueOf(fullQualifiedName.getName()); return primitiveTypeKind == null ? null : odata.createPrimitiveTypeInstance(primitiveTypeKind); } else { return null; } }
propertyType = propertyType.substring(4); EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(propertyType); String value = EdmPrimitiveTypeFactory.getInstance(kind).valueToString( propertyValue, property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
propertyType = propertyType.substring(4); EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(propertyType); String value = EdmPrimitiveTypeFactory.getInstance(kind).valueToString( propertyValue, property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
public static Object parseLiteral(String odataType, String value) throws TeiidException { EdmPrimitiveType primitiveType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind .valueOf(odataType.substring(4)));
public static String convertToODataURIValue(Object val, String odataType) throws EdmPrimitiveTypeException { if (val == null) { return "null"; // is this correct? //$NON-NLS-1$ } if(odataType.startsWith("Edm.")) { //$NON-NLS-1$ odataType = odataType.substring(4); } if (val instanceof AbstractGeospatialType) { Geometry g; try { g = GeometryUtils.getGeometry((AbstractGeospatialType)val); } catch (FunctionExecutionException e1) { throw new EdmPrimitiveTypeException(e1.getMessage(), e1); } return geometryToODataValueString(g, val instanceof GeometryType); } EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(odataType); String value = EdmPrimitiveTypeFactory.getInstance(kind).valueToString( val, true, null, null, Integer.MAX_VALUE, true); if (kind == EdmPrimitiveTypeKind.String) { return EdmString.getInstance().toUriLiteral(value); } return value; }
public static String convertToODataURIValue(Object val, String odataType) throws EdmPrimitiveTypeException { if (val == null) { return "null"; // is this correct? //$NON-NLS-1$ } if(odataType.startsWith("Edm.")) { //$NON-NLS-1$ odataType = odataType.substring(4); } if (val instanceof AbstractGeospatialType) { Geometry g; try { g = GeometryUtils.getGeometry((AbstractGeospatialType)val); } catch (FunctionExecutionException e1) { throw new EdmPrimitiveTypeException(e1.getMessage(), e1); } return geometryToODataValueString(g, val instanceof GeometryType); } EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOf(odataType); String value = EdmPrimitiveTypeFactory.getInstance(kind).valueToString( val, true, null, null, Integer.MAX_VALUE, true); if (kind == EdmPrimitiveTypeKind.String) { return EdmString.getInstance().toUriLiteral(value); } return value; }
private void checkJsonTypeBasedOnPrimitiveType(final String propertyName, final EdmPrimitiveType edmPrimitiveType, final JsonNode jsonNode) throws DeserializerException { boolean valid = true; if (edmPrimitiveType.getKind() == EdmTypeKind.DEFINITION) { checkJsonTypeBasedOnPrimitiveType(propertyName, ((EdmTypeDefinition) edmPrimitiveType).getUnderlyingType(), jsonNode); } else if (edmPrimitiveType.getKind() == EdmTypeKind.ENUM) { // Enum values must be strings. valid = jsonNode.isTextual(); } else { final String name = edmPrimitiveType.getName(); EdmPrimitiveTypeKind primKind; try { primKind = EdmPrimitiveTypeKind.valueOf(name); } catch (final IllegalArgumentException e) { throw new DeserializerException("Unknown Primitive Type: " + name, e, DeserializerException.MessageKeys.UNKNOWN_PRIMITIVE_TYPE, name, propertyName); } valid = matchTextualCase(jsonNode, primKind) || matchNumberCase(jsonNode, primKind) || matchBooleanCase(jsonNode, primKind) || matchIEEENumberCase(jsonNode, primKind) || jsonNode.isObject() && name.startsWith("Geo"); } if (!valid) { throw new DeserializerException( "Invalid json type: " + jsonNode.getNodeType() + " for " + edmPrimitiveType + " property: " + propertyName, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, propertyName); } }
private void checkJsonTypeBasedOnPrimitiveType(final String propertyName, final EdmPrimitiveType edmPrimitiveType, final JsonNode jsonNode) throws DeserializerException { boolean valid = true; if (edmPrimitiveType.getKind() == EdmTypeKind.DEFINITION) { checkJsonTypeBasedOnPrimitiveType(propertyName, ((EdmTypeDefinition) edmPrimitiveType).getUnderlyingType(), jsonNode); } else if (edmPrimitiveType.getKind() == EdmTypeKind.ENUM) { // Enum values must be strings. valid = jsonNode.isTextual(); } else { final String name = edmPrimitiveType.getName(); EdmPrimitiveTypeKind primKind; try { primKind = EdmPrimitiveTypeKind.valueOf(name); } catch (final IllegalArgumentException e) { throw new DeserializerException("Unknown Primitive Type: " + name, e, DeserializerException.MessageKeys.UNKNOWN_PRIMITIVE_TYPE, name, propertyName); } valid = matchTextualCase(jsonNode, primKind) || matchNumberCase(jsonNode, primKind) || matchBooleanCase(jsonNode, primKind) || matchIEEENumberCase(jsonNode, primKind) || jsonNode.isObject() && name.startsWith("Geo"); } if (!valid) { throw new DeserializerException( "Invalid json type: " + jsonNode.getNodeType() + " for " + edmPrimitiveType + " property: " + propertyName, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, propertyName); } }
private void checkJsonTypeBasedOnPrimitiveType(final String propertyName, final EdmPrimitiveType edmPrimitiveType, final JsonNode jsonNode) throws DeserializerException { boolean valid = true; if (edmPrimitiveType.getKind() == EdmTypeKind.DEFINITION) { checkJsonTypeBasedOnPrimitiveType(propertyName, ((EdmTypeDefinition) edmPrimitiveType).getUnderlyingType(), jsonNode); } else if (edmPrimitiveType.getKind() == EdmTypeKind.ENUM) { // Enum values must be strings. valid = jsonNode.isTextual(); } else { final String name = edmPrimitiveType.getName(); EdmPrimitiveTypeKind primKind; try { primKind = EdmPrimitiveTypeKind.valueOf(name); } catch (final IllegalArgumentException e) { throw new DeserializerException("Unknown Primitive Type: " + name, e, DeserializerException.MessageKeys.UNKNOWN_PRIMITIVE_TYPE, name, propertyName); } valid = matchTextualCase(jsonNode, primKind) || matchNumberCase(jsonNode, primKind) || matchBooleanCase(jsonNode, primKind) || matchIEEENumberCase(jsonNode, primKind); } if (!valid) { throw new DeserializerException("Invalid json type: " + jsonNode.getNodeType() + " for " + edmPrimitiveType + " property: " + propertyName, DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, propertyName); } }
public static Object parseLiteral(EdmProperty edmProperty, Class<?> runtimeType, String value) throws TeiidException { EdmPrimitiveType primitiveType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind .valueOf(edmProperty.getType() .getFullQualifiedName() .getFullQualifiedNameAsString().substring(4))); try { if (EdmString.getInstance().equals(edmProperty.getType())) { value = EdmString.getInstance().fromUriLiteral(value); } Object converted = primitiveType.valueOfString(value, edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), true, runtimeType); return converted; } catch (EdmPrimitiveTypeException e) { throw new TeiidException(e); } }
public static Object parseLiteral(EdmParameter edmParameter, Class<?> runtimeType, String value) throws TeiidProcessingException { EdmPrimitiveType primitiveType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind .valueOf(edmParameter.getType() .getFullQualifiedName() .getFullQualifiedNameAsString().substring(4))); try { if (EdmString.getInstance().equals(edmParameter.getType())) { value = EdmString.getInstance().fromUriLiteral(value); } Object converted = primitiveType.valueOfString(value, edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter.getScale(), true, runtimeType); return converted; } catch (EdmPrimitiveTypeException e) { throw new TeiidProcessingException(e); } }
public static Object parseLiteral(EdmProperty edmProperty, Class<?> runtimeType, String value) throws TeiidException { EdmPrimitiveType primitiveType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind .valueOf(edmProperty.getType() .getFullQualifiedName() .getFullQualifiedNameAsString().substring(4))); try { if (EdmString.getInstance().equals(edmProperty.getType())) { value = EdmString.getInstance().fromUriLiteral(value); } Object converted = primitiveType.valueOfString(value, edmProperty.isNullable(), edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(), true, runtimeType); return converted; } catch (EdmPrimitiveTypeException e) { throw new TeiidException(e); } }
public static Object parseLiteral(EdmParameter edmParameter, Class<?> runtimeType, String value) throws TeiidProcessingException { EdmPrimitiveType primitiveType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind .valueOf(edmParameter.getType() .getFullQualifiedName() .getFullQualifiedNameAsString().substring(4))); try { if (EdmString.getInstance().equals(edmParameter.getType())) { value = EdmString.getInstance().fromUriLiteral(value); } Object converted = primitiveType.valueOfString(value, edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter.getScale(), true, runtimeType); return converted; } catch (EdmPrimitiveTypeException e) { throw new TeiidProcessingException(e); } }