当前位置: 首页>>代码示例>>Java>>正文


Java EdmTypeKind.ENUM属性代码示例

本文整理汇总了Java中org.apache.olingo.commons.api.edm.constants.EdmTypeKind.ENUM属性的典型用法代码示例。如果您正苦于以下问题:Java EdmTypeKind.ENUM属性的具体用法?Java EdmTypeKind.ENUM怎么用?Java EdmTypeKind.ENUM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.olingo.commons.api.edm.constants.EdmTypeKind的用法示例。


在下文中一共展示了EdmTypeKind.ENUM属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createProperty

private Property createProperty(final EdmProperty edmProperty, final String propertyName)
    throws DataProviderException {
  final EdmType type = edmProperty.getType();
  Property newProperty;
  if (edmProperty.isPrimitive()
      || type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
    newProperty = edmProperty.isCollection() ?
        DataCreator.createPrimitiveCollection(propertyName) :
        DataCreator.createPrimitive(propertyName, null);
  } else {
    if (edmProperty.isCollection()) {
      @SuppressWarnings("unchecked")
      Property newProperty2 = DataCreator.createComplexCollection(propertyName, 
          edmProperty.getType().getFullQualifiedName().getFullQualifiedNameAsString());
      newProperty = newProperty2;
    } else {
      newProperty = DataCreator.createComplex(propertyName,
          edmProperty.getType().getFullQualifiedName().getFullQualifiedNameAsString());
      createProperties((EdmComplexType) type, newProperty.asComplex().getValue());
    }
  }
  return newProperty;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:DataProvider.java

示例2: EdmEnumTypeImpl

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;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:EdmEnumTypeImpl.java

示例3: getJavaClassForPrimitiveType

/**
 * Returns the primitive type's default class or the manually mapped class if present.
 * @param mapping
 * @param edmPrimitiveType
 * @return the java class to be used during deserialization
 */
private Class<?> getJavaClassForPrimitiveType(final EdmMapping mapping, final EdmPrimitiveType type) {
  final EdmPrimitiveType edmPrimitiveType =
      type.getKind() == EdmTypeKind.ENUM ? ((EdmEnumType) type).getUnderlyingType() : type
          .getKind() == EdmTypeKind.DEFINITION ? ((EdmTypeDefinition) type).getUnderlyingType() : type;
  return mapping == null || mapping.getMappedJavaClass() == null ? edmPrimitiveType.getDefaultType() : mapping
      .getMappedJavaClass();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:13,代码来源:ODataJsonDeserializer.java

示例4: checkJsonTypeBasedOnPrimitiveType

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);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:30,代码来源:ODataJsonDeserializer.java

示例5: isEnumType

private boolean isEnumType(final Expression expression) throws UriParserException {
  final EdmType expressionType = getType(expression);
  return expressionType == null
      || expressionType.getKind() == EdmTypeKind.ENUM
      || isType(expressionType,
          EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64,
          EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:8,代码来源:ExpressionParser.java

示例6: writePropertyType

private void writePropertyType(final EdmProperty edmProperty, JsonGenerator json)
    throws SerializerException, IOException {
  if (!isODataMetadataFull) {
    return;
  }
  String typeName = edmProperty.getName() + constants.getType();
  final EdmType type = edmProperty.getType();
  if (type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
    if (edmProperty.isCollection()) {
      json.writeStringField(typeName, 
          "#Collection(" + type.getFullQualifiedName().getFullQualifiedNameAsString() + ")");
    } else {
      json.writeStringField(typeName, "#" + type.getFullQualifiedName().getFullQualifiedNameAsString());
    }
  } else if (edmProperty.isPrimitive()) {
    if (edmProperty.isCollection()) {
      json.writeStringField(typeName, "#Collection(" + type.getFullQualifiedName().getName() + ")");
    } else {
      // exclude the properties that can be heuristically determined
      if (type != EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean) &&
          type != EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Double) &&
          type != EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String)) {
        json.writeStringField(typeName, "#" + type.getFullQualifiedName().getName());                  
      }
    }
  } else if (type.getKind() == EdmTypeKind.COMPLEX) {
    // non-collection case written in writeComplex method directly.
    if (edmProperty.isCollection()) {
      json.writeStringField(typeName, 
          "#Collection(" + type.getFullQualifiedName().getFullQualifiedNameAsString() + ")");
    }
  } else {
    throw new SerializerException("Property type not yet supported!",
        SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
  }    
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:36,代码来源:ODataJsonSerializer.java

示例7: writePropertyValue

private void writePropertyValue(final ServiceMetadata metadata, final EdmProperty edmProperty,
    final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json)
    throws IOException, SerializerException {
  final EdmType type = edmProperty.getType();
  try {
    if (edmProperty.isPrimitive()
        || type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
      if (edmProperty.isCollection()) {
        writePrimitiveCollection((EdmPrimitiveType) type, property,
            edmProperty.isNullable(), edmProperty.getMaxLength(),
            edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), json);
      } else {
        writePrimitive((EdmPrimitiveType) type, property,
            edmProperty.isNullable(), edmProperty.getMaxLength(),
            edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), json);
      }
    } else if (property.isComplex()) {
      if (edmProperty.isCollection()) {
        writeComplexCollection(metadata, (EdmComplexType) type, property, selectedPaths, json);
      } else {
       writeComplex(metadata, (EdmComplexType) type, property, selectedPaths, json);
      }
    } else {
      throw new SerializerException("Property type not yet supported!",
          SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
    }
  } catch (final EdmPrimitiveTypeException e) {
    throw new SerializerException("Wrong value for property!", e,
        SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
        edmProperty.getName(), property.getValue().toString());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:32,代码来源:ODataJsonSerializer.java

示例8: writePropertyValue

private void writePropertyValue(final ServiceMetadata metadata, final EdmProperty edmProperty,
    final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json)
    throws IOException, SerializerException {
  final EdmType type = edmProperty.getType();
  try {
    if (edmProperty.isPrimitive()
        || type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
      if (edmProperty.isCollection()) {
        writePrimitiveCollection((EdmPrimitiveType) type, property,
            edmProperty.isNullable(), edmProperty.getMaxLength(),
            edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), json);
      } else {
        writePrimitive((EdmPrimitiveType) type, property,
            edmProperty.isNullable(), edmProperty.getMaxLength(),
            edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(), json);
      }
    } else if (property.isComplex()) {
      if (edmProperty.isCollection()) {
        writeComplexCollection(metadata, (EdmComplexType) type, property, selectedPaths, json);
      } else {
        writeComplex(metadata, (EdmComplexType) type, property, selectedPaths, json);
      }
    } else {
      throw new SerializerException("Property type not yet supported!",
          SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
    }
  } catch (final EdmPrimitiveTypeException e) {
    throw new SerializerException("Wrong value for property!", e,
        SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
        edmProperty.getName(), property.getValue().toString());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:32,代码来源:JsonDeltaSerializerWithNavigations.java

示例9: addSelectPath

private void addSelectPath(UriTokenizer tokenizer, final EdmStructuredType referencedType, UriInfoImpl resource)
    throws UriParserException {
  final String name = tokenizer.getText();
  final EdmProperty property = referencedType.getStructuralProperty(name);

  if (property == null) {
    final EdmNavigationProperty navigationProperty = referencedType.getNavigationProperty(name);
    if (navigationProperty == null) {
      throw new UriParserSemanticException("Selected property not found.",
          UriParserSemanticException.MessageKeys.EXPRESSION_PROPERTY_NOT_IN_TYPE,
          referencedType.getName(), name);
    } else {
      resource.addResourcePart(new UriResourceNavigationPropertyImpl(navigationProperty));
    }

  } else if (property.isPrimitive()
      || property.getType().getKind() == EdmTypeKind.ENUM
      || property.getType().getKind() == EdmTypeKind.DEFINITION) {
    resource.addResourcePart(new UriResourcePrimitivePropertyImpl(property));

  } else {
    UriResourceComplexPropertyImpl complexPart = new UriResourceComplexPropertyImpl(property);
    resource.addResourcePart(complexPart);
    if (tokenizer.next(TokenKind.SLASH)) {
      if (tokenizer.next(TokenKind.QualifiedName)) {
        final FullQualifiedName qualifiedName = new FullQualifiedName(tokenizer.getText());
        final EdmComplexType type = edm.getComplexType(qualifiedName);
        if (type == null) {
          throw new UriParserSemanticException("Type not found.",
              UriParserSemanticException.MessageKeys.UNKNOWN_TYPE, qualifiedName.getFullQualifiedNameAsString());
        } else if (type.compatibleTo(property.getType())) {
          complexPart.setTypeFilter(type);
          if (tokenizer.next(TokenKind.SLASH)) {
            if (tokenizer.next(TokenKind.ODataIdentifier)) {
              addSelectPath(tokenizer, type, resource);
            } else {
              throw new UriParserSemanticException("Unknown part after '/'.",
                  UriParserSemanticException.MessageKeys.UNKNOWN_PART, "");
            }
          }
        } else {
          throw new UriParserSemanticException("The type cast is not compatible.",
              UriParserSemanticException.MessageKeys.INCOMPATIBLE_TYPE_FILTER, type.getName());
        }
      } else if (tokenizer.next(TokenKind.ODataIdentifier)) {
        addSelectPath(tokenizer, (EdmStructuredType) property.getType(), resource);
      } else if (tokenizer.next(TokenKind.SLASH)) {
        throw new UriParserSyntaxException("Illegal $select expression.",
            UriParserSyntaxException.MessageKeys.SYNTAX);
      } else {
        throw new UriParserSemanticException("Unknown part after '/'.",
            UriParserSemanticException.MessageKeys.UNKNOWN_PART, "");
      }
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:56,代码来源:SelectParser.java

示例10: nextPrimitiveTypeValue

private static boolean nextPrimitiveTypeValue(UriTokenizer tokenizer,
    final EdmPrimitiveType primitiveType, final boolean nullable) {
  final EdmPrimitiveType type = primitiveType instanceof EdmTypeDefinition ?
      ((EdmTypeDefinition) primitiveType).getUnderlyingType() :
      primitiveType;
  if (tokenizer.next(TokenKind.ParameterAliasName)) {
    return true;
  } else if (nullable && tokenizer.next(TokenKind.NULL)) {
    return true;

  // Special handling for frequently-used types and types with more than one token kind.
  } else if (odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Boolean).equals(type)) {
    return tokenizer.next(TokenKind.BooleanValue);
  } else if (odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String).equals(type)) {
    return tokenizer.next(TokenKind.StringValue);
  } else if (odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.SByte).equals(type)
      || odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Byte).equals(type)
      || odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int16).equals(type)
      || odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int32).equals(type)
      || odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Int64).equals(type)) {
    return tokenizer.next(TokenKind.IntegerValue);
  } else if (odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Guid).equals(type)) {
    return tokenizer.next(TokenKind.GuidValue);
  } else if (odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Decimal).equals(type)) {
    // The order is important.
    // A decimal value should not be parsed as integer and let the tokenizer stop at the decimal point.
    return tokenizer.next(TokenKind.DecimalValue)
        || tokenizer.next(TokenKind.IntegerValue);
  } else if (odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Double).equals(type)
      || odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Single).equals(type)) {
    // The order is important.
    // A floating-point value should not be parsed as decimal and let the tokenizer stop at 'E'.
    // A decimal value should not be parsed as integer and let the tokenizer stop at the decimal point.
    return tokenizer.next(TokenKind.DoubleValue)
        || tokenizer.next(TokenKind.DecimalValue)
        || tokenizer.next(TokenKind.IntegerValue);
  } else if (type.getKind() == EdmTypeKind.ENUM) {
    return tokenizer.next(TokenKind.EnumValue);
  } else {
    // Check the types that have not been checked already above.
    for (final Entry<TokenKind, EdmPrimitiveTypeKind> entry : tokenToPrimitiveType.entrySet()) {
      final EdmPrimitiveTypeKind kind = entry.getValue();
      if ((kind == EdmPrimitiveTypeKind.Date || kind == EdmPrimitiveTypeKind.DateTimeOffset
          || kind == EdmPrimitiveTypeKind.TimeOfDay || kind == EdmPrimitiveTypeKind.Duration
          || kind == EdmPrimitiveTypeKind.Binary
          || kind.isGeospatial())
          && odata.createPrimitiveTypeInstance(kind).equals(type)) {
        return tokenizer.next(entry.getKey());
      }
    }
    return false;
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:53,代码来源:ParserHelper.java

示例11: writePropertyValue

private void writePropertyValue(final ServiceMetadata metadata,
    final EdmProperty edmProperty, final Property property,
    final Set<List<String>> selectedPaths,
    final String xml10InvalidCharReplacement, final XMLStreamWriter writer)
    throws XMLStreamException, SerializerException {
  try {
    if (edmProperty.isPrimitive()
        || edmProperty.getType().getKind() == EdmTypeKind.ENUM
        || edmProperty.getType().getKind() == EdmTypeKind.DEFINITION) {
      if (edmProperty.isCollection()) {
        writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE,
            edmProperty.isPrimitive() ?
                "#Collection(" + edmProperty.getType().getName() + ")" :
                collectionType(edmProperty.getType()));
        writePrimitiveCollection((EdmPrimitiveType) edmProperty.getType(), property,
            edmProperty.isNullable(), edmProperty.getMaxLength(),
            edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(),
            xml10InvalidCharReplacement,writer);
      } else {
        writePrimitive((EdmPrimitiveType) edmProperty.getType(), property,
            edmProperty.isNullable(), edmProperty.getMaxLength(),
            edmProperty.getPrecision(), edmProperty.getScale(), edmProperty.isUnicode(),
            xml10InvalidCharReplacement, writer);
      }
    } else if (property.isComplex()) {
      if (edmProperty.isCollection()) {
        writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE, collectionType(edmProperty.getType()));
        writeComplexCollection(metadata, (EdmComplexType) edmProperty.getType(), property, selectedPaths, 
            xml10InvalidCharReplacement, writer);
      } else {
          writeComplex(metadata, edmProperty, property, selectedPaths, xml10InvalidCharReplacement, writer);
      }
    } else {
      throw new SerializerException("Property type not yet supported!",
          SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, edmProperty.getName());
    }
  } catch (final EdmPrimitiveTypeException e) {
    throw new SerializerException("Wrong value for property!", e,
        SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,
        edmProperty.getName(), property.getValue().toString());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:42,代码来源:ODataXmlSerializer.java


注:本文中的org.apache.olingo.commons.api.edm.constants.EdmTypeKind.ENUM属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。