Java Code Examples for org.apache.olingo.commons.api.data.ValueType#COLLECTION_ENUM
The following examples show how to use
org.apache.olingo.commons.api.data.ValueType#COLLECTION_ENUM .
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: ODataXmlDeserializer.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private ValueType getValueType(final EdmType edmType, final boolean isCollection) { if (edmType instanceof EdmPrimitiveType) { if (edmType instanceof EdmEnumType) { return isCollection ? ValueType.COLLECTION_ENUM : ValueType.ENUM; } else { return isCollection ? ValueType.COLLECTION_PRIMITIVE : ValueType.PRIMITIVE; } } else if (edmType instanceof EdmComplexType) { return isCollection ? ValueType.COLLECTION_COMPLEX : ValueType.COMPLEX; } else { return ValueType.PRIMITIVE; } }
Example 2
Source File: ODataBinderImpl.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void updateValuable(final Valuable propertyResource, final ClientValuable odataValuable) { final Object propertyValue = getValue(odataValuable.getValue()); if (odataValuable.hasPrimitiveValue()) { propertyResource.setType(odataValuable.getPrimitiveValue().getTypeName()); propertyResource.setValue( propertyValue instanceof Geospatial ? ValueType.GEOSPATIAL : ValueType.PRIMITIVE, propertyValue); } else if (odataValuable.hasEnumValue()) { propertyResource.setType(odataValuable.getEnumValue().getTypeName()); propertyResource.setValue(ValueType.ENUM, propertyValue); } else if (odataValuable.hasComplexValue()) { propertyResource.setType(odataValuable.getComplexValue().getTypeName()); propertyResource.setValue(ValueType.COMPLEX, propertyValue); } else if (odataValuable.hasCollectionValue()) { final ClientCollectionValue<ClientValue> collectionValue = odataValuable.getCollectionValue(); propertyResource.setType(collectionValue.getTypeName()); final ClientValue value = collectionValue.iterator().hasNext() ? collectionValue.iterator().next() : null; ValueType valueType = ValueType.COLLECTION_PRIMITIVE; if (value == null) { valueType = ValueType.COLLECTION_PRIMITIVE; } else if (value.isPrimitive()) { valueType = value.asPrimitive().toValue() instanceof Geospatial ? ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE; } else if (value.isEnum()) { valueType = ValueType.COLLECTION_ENUM; } else if (value.isComplex()) { valueType = ValueType.COLLECTION_COMPLEX; } propertyResource.setValue(valueType, propertyValue); } }
Example 3
Source File: AtomDeserializer.java From olingo-odata4 with Apache License 2.0 | 4 votes |
private void fromCollection(final Valuable valuable, final XMLEventReader reader, final StartElement start, final EdmTypeInfo typeInfo) throws XMLStreamException, EdmPrimitiveTypeException { List<Object> values = new ArrayList<>(); ValueType valueType = ValueType.COLLECTION_PRIMITIVE; final EdmTypeInfo type = typeInfo == null ? null : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build(); boolean foundEndProperty = false; while (reader.hasNext() && !foundEndProperty) { final XMLEvent event = reader.nextEvent(); if (event.isStartElement()) { switch (guessPropertyType(reader, typeInfo)) { case COMPLEX: final Object complexValue = fromComplexOrEnum(reader, event.asStartElement()); valueType = ValueType.COLLECTION_COMPLEX; final Attribute typeAttr = event.asStartElement().getAttributeByName(typeQName); final String typeAttrValue = typeAttr == null ? null : typeAttr.getValue(); final EdmTypeInfo typeInfoEle = StringUtils.isBlank(typeAttrValue) ? null : new EdmTypeInfo.Builder().setTypeExpression(typeAttrValue).build(); if (typeInfoEle != null) { ((ComplexValue)complexValue).setTypeName(typeInfoEle.external()); } values.add(complexValue); break; case ENUM: valueType = ValueType.COLLECTION_ENUM; values.add(fromComplexOrEnum(reader, event.asStartElement())); break; case PRIMITIVE: final Object value = fromPrimitive(reader, event.asStartElement(), type); valueType = value instanceof Geospatial ? ValueType.COLLECTION_GEOSPATIAL : ValueType.COLLECTION_PRIMITIVE; values.add(value); break; default: // do not add null or empty values } } if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) { foundEndProperty = true; } } valuable.setValue(valueType, values); }