Examples of EdmSimpleType


Examples of org.apache.olingo.odata2.api.edm.EdmSimpleType

            final String text = reader.getElementText();
            reader.require(XMLStreamConstants.END_ELEMENT, customNamespaceURI, tagName);

            final EntityPropertyInfo propertyInfo = getValidatedPropertyInfo(eia, tagName);
            final Class<?> typeMapping = typeMappings.getMappingClass(propertyInfo.getName());
            final EdmSimpleType type = (EdmSimpleType) propertyInfo.getType();
            final Object value = type.valueOfString(text, EdmLiteralKind.DEFAULT,
                readProperties == null || readProperties.isValidatingFacets() ? propertyInfo.getFacets() : null,
                typeMapping == null ? type.getDefaultType() : typeMapping);
            properties.put(tagName, value);
          }
        }
      } else {
        throw new EntityProviderException(EntityProviderException.INVALID_PROPERTY.addContent(tagName));
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmSimpleType

    }
  }

  private Object convert(final EntityPropertyInfo property, final String value, final Class<?> typeMapping,
      final EntityProviderReadProperties readProperties) throws EdmSimpleTypeException {
    final EdmSimpleType type = (EdmSimpleType) property.getType();
    return type.valueOfString(value, EdmLiteralKind.DEFAULT,
        readProperties == null || readProperties.isValidatingFacets() ? property.getFacets() : null,
        typeMapping == null ? type.getDefaultType() : typeMapping);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmSimpleType

  public void checkNull() throws Exception {
    for (EdmSimpleTypeKind kind : EdmSimpleTypeKind.values()) {
      if (kind == EdmSimpleTypeKind.Null) {
        continue;
      }
      final EdmSimpleType instance = kind.getEdmSimpleTypeInstance();
      assertNull(instance.valueToString(null, EdmLiteralKind.DEFAULT, null));
      assertNull(instance.valueToString(null, EdmLiteralKind.DEFAULT, getNullableFacets(true)));
      assertNull(instance.valueToString(null, EdmLiteralKind.DEFAULT, getNullableFacets(null)));

      expectErrorInValueToString(instance, null, EdmLiteralKind.DEFAULT, getNullableFacets(false),
          EdmSimpleTypeException.VALUE_NULL_NOT_ALLOWED);
    }
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmSimpleType

      Collection<EntityPropertyInfo> propertyInfos = eia.getETagPropertyInfos();
      for (EntityPropertyInfo propertyInfo : propertyInfos) {
        EdmType edmType = propertyInfo.getType();
        if (edmType instanceof EdmSimpleType) {
          EdmSimpleType edmSimpleType = (EdmSimpleType) edmType;
          if (etag == null) {
            etag =
                edmSimpleType.valueToString(data.get(propertyInfo.getName()), EdmLiteralKind.DEFAULT, propertyInfo
                    .getFacets());
          } else {
            etag =
                etag
                    + Edm.DELIMITER
                    + edmSimpleType.valueToString(data.get(propertyInfo.getName()), EdmLiteralKind.DEFAULT,
                        propertyInfo.getFacets());
          }
        }
      }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmSimpleType

      writer.writeStartElement(FormatXml.ATOM_TITLE);
      writer.writeAttribute(FormatXml.ATOM_TYPE, FormatXml.ATOM_TEXT);
      EntityPropertyInfo titleInfo = eia.getTargetPathInfo(EdmTargetPath.SYNDICATION_TITLE);
      if (titleInfo != null) {
        EdmSimpleType st = (EdmSimpleType) titleInfo.getType();
        Object object = data.get(titleInfo.getName());
        String title = st.valueToString(object, EdmLiteralKind.DEFAULT, titleInfo.getFacets());
        if (title != null) {
          writer.writeCharacters(title);
        }
      } else {
        writer.writeCharacters(eia.getEntitySetName());
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmSimpleType

  }

  @Test
  public void valueToStringBinary() throws Exception {
    final byte[] binary = new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF };
    final EdmSimpleType instance = EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance();

    assertEquals("qrvM3e7/", instance.valueToString(binary, EdmLiteralKind.DEFAULT, null));
    assertEquals("qrvM3e7/", instance.valueToString(binary, EdmLiteralKind.JSON, null));
    assertEquals("binary'AABBCCDDEEFF'", instance.valueToString(binary, EdmLiteralKind.URI, null));

    assertEquals("qrvM3e7/", instance.valueToString(binary, EdmLiteralKind.DEFAULT, getMaxLengthFacets(6)));
    assertEquals("qrvM3e7/", instance.valueToString(binary, EdmLiteralKind.JSON, getMaxLengthFacets(6)));
    assertEquals("binary'AABBCCDDEEFF'", instance.valueToString(binary, EdmLiteralKind.URI, getMaxLengthFacets(6)));
    assertEquals("qrvM3e7/", instance.valueToString(binary, EdmLiteralKind.DEFAULT,
        getMaxLengthFacets(Integer.MAX_VALUE)));
    assertEquals("binary'AABBCCDDEEFF'", instance.valueToString(binary, EdmLiteralKind.URI,
        getMaxLengthFacets(Integer.MAX_VALUE)));
    assertEquals("qrvM3e7/", instance.valueToString(binary, EdmLiteralKind.DEFAULT, getMaxLengthFacets(null)));

    assertEquals("qg==", instance.valueToString(new Byte[] { new Byte((byte) 170) }, EdmLiteralKind.DEFAULT, null));

    expectErrorInValueToString(instance, binary, EdmLiteralKind.DEFAULT, getMaxLengthFacets(3),
        EdmSimpleTypeException.VALUE_FACETS_NOT_MATCHED);
    expectErrorInValueToString(instance, binary, EdmLiteralKind.JSON, getMaxLengthFacets(3),
        EdmSimpleTypeException.VALUE_FACETS_NOT_MATCHED);
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmSimpleType

  private String getTargetPathValue(final EntityInfoAggregator eia, final String targetPath,
      final Map<String, Object> data) throws EntityProviderException {
    try {
      EntityPropertyInfo info = eia.getTargetPathInfo(targetPath);
      if (info != null) {
        EdmSimpleType type = (EdmSimpleType) info.getType();
        Object value = data.get(info.getName());
        return type.valueToString(value, EdmLiteralKind.DEFAULT, info.getFacets());
      }
      return null;
    } catch (EdmSimpleTypeException e) {
      throw new EntityProviderException(EntityProviderException.COMMON, e);
    }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmSimpleType

      final String name = keyPropertyInfo.getName();
      if (keyPropertyInfos.size() > 1) {
        keys.append(Encoder.encode(name)).append('=');
      }

      final EdmSimpleType type = (EdmSimpleType) keyPropertyInfo.getType();
      try {
        keys.append(Encoder.encode(type.valueToString(data.get(name), EdmLiteralKind.URI,
            keyPropertyInfo.getFacets())));
      } catch (final EdmSimpleTypeException e) {
        throw new EntityProviderException(EntityProviderException.COMMON, e);
      }
    }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmSimpleType

    expectErrorInValueToString(instance, binary, null, null, EdmSimpleTypeException.LITERAL_KIND_MISSING);
  }

  @Test
  public void valueToStringBoolean() throws Exception {
    final EdmSimpleType instance = EdmSimpleTypeKind.Boolean.getEdmSimpleTypeInstance();

    assertEquals("true", instance.valueToString(true, EdmLiteralKind.DEFAULT, null));
    assertEquals("true", instance.valueToString(true, EdmLiteralKind.JSON, null));
    assertEquals("true", instance.valueToString(true, EdmLiteralKind.URI, null));
    assertEquals("false", instance.valueToString(Boolean.FALSE, EdmLiteralKind.DEFAULT, null));

    expectErrorInValueToString(instance, 0, EdmLiteralKind.DEFAULT, null,
        EdmSimpleTypeException.VALUE_TYPE_NOT_SUPPORTED);
    expectErrorInValueToString(instance, false, null, null, EdmSimpleTypeException.LITERAL_KIND_MISSING);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.edm.EdmSimpleType

    expectErrorInValueToString(instance, false, null, null, EdmSimpleTypeException.LITERAL_KIND_MISSING);
  }

  @Test
  public void valueToStringByte() throws Exception {
    final EdmSimpleType instance = EdmSimpleTypeKind.Byte.getEdmSimpleTypeInstance();

    assertEquals("0", instance.valueToString(0, EdmLiteralKind.DEFAULT, null));
    assertEquals("0", instance.valueToString(0, EdmLiteralKind.JSON, null));
    assertEquals("0", instance.valueToString(0, EdmLiteralKind.URI, null));
    assertEquals("8", instance.valueToString((byte) 8, EdmLiteralKind.DEFAULT, null));
    assertEquals("16", instance.valueToString((short) 16, EdmLiteralKind.DEFAULT, null));
    assertEquals("32", instance.valueToString(Integer.valueOf(32), EdmLiteralKind.DEFAULT, null));
    assertEquals("255", instance.valueToString(255L, EdmLiteralKind.DEFAULT, null));

    expectErrorInValueToString(instance, -1, EdmLiteralKind.DEFAULT, null,
        EdmSimpleTypeException.VALUE_ILLEGAL_CONTENT);
    expectErrorInValueToString(instance, 256, EdmLiteralKind.DEFAULT, null,
        EdmSimpleTypeException.VALUE_ILLEGAL_CONTENT);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.