本文整理汇总了Java中org.apache.olingo.commons.api.edm.EdmPrimitiveType.valueOfString方法的典型用法代码示例。如果您正苦于以下问题:Java EdmPrimitiveType.valueOfString方法的具体用法?Java EdmPrimitiveType.valueOfString怎么用?Java EdmPrimitiveType.valueOfString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.commons.api.edm.EdmPrimitiveType
的用法示例。
在下文中一共展示了EdmPrimitiveType.valueOfString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readPrimitiveValue
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
private Object readPrimitiveValue(final String name, final EdmPrimitiveType type,
final boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale,
final boolean isUnicode, final EdmMapping mapping, final JsonNode jsonNode) throws DeserializerException {
if (isValidNull(name, isNullable, jsonNode)) {
return null;
}
final boolean isGeoType = type.getName().startsWith("Geo");
if (!isGeoType) {
checkForValueNode(name, jsonNode);
}
checkJsonTypeBasedOnPrimitiveType(name, type, jsonNode);
try {
if (isGeoType) {
return readPrimitiveGeoValue(name, type, (ObjectNode) jsonNode);
}
return type.valueOfString(jsonNode.asText(),
isNullable, maxLength, precision, scale, isUnicode,
getJavaClassForPrimitiveType(mapping, type));
} catch (final EdmPrimitiveTypeException e) {
throw new DeserializerException(
"Invalid value: " + jsonNode.asText() + " for property: " + name, e,
DeserializerException.MessageKeys.INVALID_VALUE_FOR_PROPERTY, name);
}
}
示例2: readPrimitiveValue
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
static Object readPrimitiveValue(EdmProperty edmProperty, String value)
throws ODataApplicationException {
if (value == null) {
return null;
}
try {
if (value.startsWith("'") && value.endsWith("'")) {
value = value.substring(1,value.length()-1);
}
EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmProperty.getType();
Class<?> javaClass = getJavaClassForPrimitiveType(edmProperty, edmPrimitiveType);
return edmPrimitiveType.valueOfString(value, edmProperty.isNullable(),
edmProperty.getMaxLength(), edmProperty.getPrecision(), edmProperty.getScale(),
edmProperty.isUnicode(), javaClass);
} catch (EdmPrimitiveTypeException e) {
throw new ODataApplicationException("Invalid value: " + value + " for property: "
+ edmProperty.getName(), 500, Locale.getDefault());
}
}
示例3: readPrimitiveValue
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
/**
* This method returns the object which is the value of the property.
*
* @param edmProperty EdmProperty
* @param value String value
* @return Object
* @throws ODataApplicationException
*/
private Object readPrimitiveValue(EdmProperty edmProperty, String value) throws ODataApplicationException {
if (value == null) {
return null;
}
try {
if (value.startsWith("'") && value.endsWith("'")) {
value = value.substring(1, value.length() - 1);
}
EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmProperty.getType();
Class<?> javaClass = getJavaClassForPrimitiveType(edmProperty, edmPrimitiveType);
return edmPrimitiveType.valueOfString(value, edmProperty.isNullable(), edmProperty.getMaxLength(),
edmProperty.getPrecision(), edmProperty.getScale(),
edmProperty.isUnicode(), javaClass);
} catch (EdmPrimitiveTypeException e) {
throw new ODataApplicationException("Invalid value: " + value + " for property: " + edmProperty.getName(),
HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
Locale.getDefault());
}
}
示例4: read
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
public Entity read(final EdmEntityType edmEntityType, final EntityCollection entitySet,
final List<UriParameter> keys) throws DataProviderException {
try {
for (final Entity entity : entitySet.getEntities()) {
boolean found = true;
for (final UriParameter key : keys) {
final EdmProperty property = (EdmProperty) edmEntityType.getProperty(key.getName());
final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
final Object value = entity.getProperty(key.getName()).getValue();
final Object keyValue =
type.valueOfString(type.fromUriLiteral(key.getText()), property.isNullable(),
property.getMaxLength(), property.getPrecision(), property.getScale(),
property.isUnicode(), Calendar.class.isAssignableFrom(value.getClass())
? Calendar.class : value.getClass());
if (!value.equals(keyValue)) {
found = false;
break;
}
}
if (found) {
return entity;
}
}
return null;
} catch (final EdmPrimitiveTypeException e) {
throw new DataProviderException("Wrong key!", e);
}
}
示例5: read
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
public Entity read(final EdmEntityType edmEntityType, final EntityCollection entitySet,
final List<UriParameter> keys) throws DataProviderException {
try {
for (final Entity entity : entitySet.getEntities()) {
boolean found = true;
for (final UriParameter key : keys) {
EdmKeyPropertyRef refType = edmEntityType.getKeyPropertyRef(key.getName());
Object value = findPropertyRefValue(entity, refType);
final EdmProperty property = refType.getProperty();
final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
if (key.getExpression() != null && !(key.getExpression() instanceof Literal)) {
throw new DataProviderException("Expression in key value is not supported yet!",
HttpStatusCode.NOT_IMPLEMENTED);
}
final String text = key.getAlias() == null ? key.getText() : ((Literal) key.getExpression()).getText();
final Object keyValue = type.valueOfString(type.fromUriLiteral(text),
property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
property.isUnicode(),
Calendar.class.isAssignableFrom(value.getClass()) ? Calendar.class : value.getClass());
if (!value.equals(keyValue)) {
found = false;
break;
}
}
if (found) {
return entity;
}
}
return null;
} catch (final EdmPrimitiveTypeException e) {
throw new DataProviderException("Wrong key!", HttpStatusCode.BAD_REQUEST, e);
}
}
示例6: readDataFromEntity
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
public Entity readDataFromEntity(final EdmEntityType edmEntityType,
final List<UriParameter> keys) throws DataProviderException {
EntityCollection coll = data.get(edmEntityType.getName());
List<Entity> entities = coll.getEntities();
try {
for (final Entity entity : entities) {
boolean found = true;
for (final UriParameter key : keys) {
EdmKeyPropertyRef refType = edmEntityType.getKeyPropertyRef(key.getName());
Object value = findPropertyRefValue(entity, refType);
final EdmProperty property = refType.getProperty();
final EdmPrimitiveType type = (EdmPrimitiveType) property.getType();
if (key.getExpression() != null && !(key.getExpression() instanceof Literal)) {
throw new DataProviderException("Expression in key value is not supported yet!",
HttpStatusCode.NOT_IMPLEMENTED);
}
final String text = key.getAlias() == null ? key.getText() : ((Literal) key.getExpression()).getText();
final Object keyValue = type.valueOfString(type.fromUriLiteral(text),
property.isNullable(), property.getMaxLength(), property.getPrecision(), property.getScale(),
property.isUnicode(),
Calendar.class.isAssignableFrom(value.getClass()) ? Calendar.class : value.getClass());
if (!value.equals(keyValue)) {
found = false;
break;
}
}
if (found) {
return entity;
}
}
return null;
} catch (final EdmPrimitiveTypeException e) {
throw new DataProviderException("Wrong key!", HttpStatusCode.BAD_REQUEST, e);
}
}
示例7: castTo
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
protected Object castTo(final String value, final EdmPrimitiveType type) throws EdmPrimitiveTypeException {
final EdmProperty edmProperty = getEdmProperty();
if (edmProperty != null) {
return type.valueOfString(value, edmProperty.isNullable(), edmProperty.getMaxLength(),
edmProperty.getPrecision(), edmProperty.getScale(),
edmProperty.isUnicode(), getDefaultType(type));
} else {
return type.valueOfString(value, null, null, null, null, null, getDefaultType(type));
}
}
示例8: expectErrorInValueOfString
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
private void expectErrorInValueOfString(final EdmPrimitiveType instance,
final String value, final Boolean isNullable, final Integer maxLength, final Integer precision,
final Integer scale, final Boolean isUnicode, final Class<?> returnType,
final String message) {
try {
instance.valueOfString(value, isNullable, maxLength, precision, scale, isUnicode, returnType);
fail("Expected exception not thrown");
} catch (final EdmPrimitiveTypeException e) {
assertNotNull(e.getLocalizedMessage());
assertThat(e.getLocalizedMessage(), containsString(message));
}
}
示例9: expectErrorInValueOfString
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
private void expectErrorInValueOfString(final EdmPrimitiveType instance, final String value,
final Boolean isNullable, final Class<?> returnType, final String message) {
try {
instance.valueOfString(value, isNullable, null, null, null, null, returnType);
fail("Expected exception not thrown");
} catch (final EdmPrimitiveTypeException e) {
assertNotNull(e.getLocalizedMessage());
assertThat(e.getLocalizedMessage(), containsString(message));
}
}
示例10: primitive
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
private Object primitive(final XMLEventReader reader, final StartElement start,
final EdmType type, final boolean isNullable, final Integer maxLength, final Integer precision,
final Integer scale, final boolean isUnicode) throws XMLStreamException, EdmPrimitiveTypeException,
DeserializerException {
Object value = null;
boolean foundEndProperty = false;
while (reader.hasNext() && !foundEndProperty) {
final XMLEvent event = reader.nextEvent();
if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
if (type instanceof AbstractGeospatialType<?>) {
throw new DeserializerException("geo types support not implemented",
DeserializerException.MessageKeys.NOT_IMPLEMENTED);
}
final EdmPrimitiveType primitiveType = (EdmPrimitiveType) type;
final String stringValue = event.asCharacters().getData();
value = primitiveType.valueOfString(stringValue,
isNullable,
maxLength,
precision,
scale,
isUnicode,
primitiveType.getDefaultType());
}
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
foundEndProperty = true;
}
}
return value;
}
示例11: castTo
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
protected Object castTo(final String value, final EdmPrimitiveType type) throws EdmPrimitiveTypeException {
final EdmProperty edmProperty = getEdmProperty();
if (edmProperty != null) {
return type.valueOfString(value, edmProperty.isNullable(), edmProperty.getMaxLength(),
edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(),
getDefaultType(type));
} else {
return type.valueOfString(value, null, null, null, null, null, getDefaultType(type));
}
}
示例12: valueOf
import org.apache.olingo.commons.api.edm.EdmPrimitiveType; //导入方法依赖的package包/类
protected Object valueOf(final String value, final EdmPrimitiveTypeKind kind) throws EdmPrimitiveTypeException {
final EdmPrimitiveType type = OData.newInstance().createPrimitiveTypeInstance(kind);
return type.valueOfString(value, true, null, null, null, true, type.getDefaultType());
}