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


Java EdmPrimitiveTypeException类代码示例

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


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

示例1: toDate

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
private static Date toDate(String sourceValue) {
  try {
    return EdmDateTimeOffset.getInstance().valueOfString(
        sourceValue,
        true,
        null,
        null,
        null,
        null,
        Date.class);
  } catch (EdmPrimitiveTypeException dateTimeOffsetException) {
    try {
      return EdmDate.getInstance().valueOfString(
          sourceValue,
          true,
          null,
          null,
          null,
          null,
          Date.class);
    } catch (EdmPrimitiveTypeException e) {
      throw new IllegalStateException("Cannot convert to EdmDate: " + sourceValue, e);
    }
  }
}
 
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:26,代码来源:EntityRepository.java

示例2: writePrimitive

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
/**
 * Writes primitive property into json.
 * 
 * @param type
 *            the EDM type
 * @param property
 *            property instance
 * @param options
 *            options for the serializer
 * @param json
 *            json generator
 * @throws EdmPrimitiveTypeException
 *             if any error occurred
 * @throws IOException
 *             if any error occurred
 * @throws SerializerException
 *             if any error occurred
 */
private void writePrimitive(EdmPrimitiveType type, Property property,
        PrimitiveSerializerOptions options, JsonGenerator json)
        throws EdmPrimitiveTypeException, IOException, SerializerException {
    Boolean isNullable = options == null ? null : options.isNullable();
    Integer maxLength = options == null ? null : options.getMaxLength();
    Integer precision = options == null ? null : options.getPrecision();
    Integer scale = options == null ? null : options.getScale();
    Boolean isUnicode = options == null ? null : options.isUnicode();
    if (property.isPrimitive()) {
        writePrimitiveValue(property.getName(), type, property.asPrimitive(), isNullable,
                maxLength, precision, scale, isUnicode, json);
    } else if (property.isGeospatial()) {
        throw new SerializerException("Property type not yet supported!",
                SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName());
    } else if (property.isEnum()) {
        writePrimitiveValue(property.getName(), type, property.asEnum(), isNullable, maxLength,
                precision, scale, isUnicode, json);
    } else {
        throw new SerializerException("Inconsistent property type!",
                SerializerException.MessageKeys.INCONSISTENT_PROPERTY_TYPE, property.getName());
    }
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:41,代码来源:ElasticODataJsonSerializer.java

示例3: stringToMultiLineString

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
protected MultiLineString stringToMultiLineString(final String value, final Boolean isNullable,
    final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode)
        throws EdmPrimitiveTypeException {

  final Matcher matcher = getMatcher(PATTERN, value);

  final List<LineString> lineStrings = new ArrayList<LineString>();
  for (String coo : matcher.group(4).contains("),(")
      ? matcher.group(4).split("\\),\\(") : new String[] { matcher.group(4) }) {

    String lineString = coo;
    if (lineString.charAt(0) == '(') {
      lineString = lineString.substring(1);
    }
    if (lineString.endsWith(")")) {
      lineString = lineString.substring(0, lineString.length() - 1);
    }

    lineStrings.add(newLineString(null, lineString, isNullable, maxLength, precision, scale, isUnicode));
  }

  return new MultiLineString(this.dimension, SRID.valueOf(matcher.group(2)), lineStrings);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:AbstractGeospatialType.java

示例4: update

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
private void update(final ContentType contentType) throws EdmPrimitiveTypeException {
  final ClientSingleton changes = getClient().getObjectFactory().newSingleton(
      new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"));
  changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Revenue",
      getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt64(132520L)));

  final URI uri = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company").build();
  final ODataEntityUpdateRequest<ClientSingleton> req = getClient().getCUDRequestFactory().
      getSingletonUpdateRequest(uri, UpdateType.PATCH, changes);
  req.setFormat(contentType);

  final ODataEntityUpdateResponse<ClientSingleton> res = req.execute();
  assertEquals(204, res.getStatusCode());

  final ClientSingleton updated =
      getClient().getRetrieveRequestFactory().getSingletonRequest(uri).execute().getBody();
  assertNotNull(updated);
  assertEquals(132520, updated.getProperty("Revenue").getPrimitiveValue().toCastValue(Integer.class), 0);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:SingletonTestITCase.java

示例5: createEntity

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
@Override
public void createEntity(DataRequest request, Entity entity, EntityResponse response)
        throws ODataApplicationException {
    EdmEntitySet edmEntitySet = request.getEntitySet();
    String baseURL = request.getODataRequest().getRawBaseUri();
    try {
        Entity created = createEntityInTable(edmEntitySet.getEntityType(), entity);
        entity.setId(new URI(ODataUtils.buildLocation(baseURL, created, edmEntitySet.getName(),
                                                      edmEntitySet.getEntityType())));
        response.writeCreatedEntity(edmEntitySet, created);
    } catch (ODataServiceFault | SerializerException | URISyntaxException | EdmPrimitiveTypeException e) {
        response.writeNotModified();
        String error = "Error occurred while creating entity. :" + e.getMessage();
        throw new ODataApplicationException(error, 500, Locale.ENGLISH);
    }
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:17,代码来源:ODataAdapter.java

示例6: readPrimitiveValue

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的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());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:TripPinDataModel.java

示例7: item6

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
/**
 * MUST NOT require <tt>odata.streaming=true</tt> in the <tt>Content-Type</tt> header (section 4.4).
 */
@Test
public void item6() throws EdmPrimitiveTypeException {
  final URI uri = edmClient.newURIBuilder().
      appendEntitySetSegment("Accounts").appendKeySegment(102).
      appendNavigationSegment("MyPaymentInstruments").appendKeySegment(102902).build();
  final ODataEntityRequest<ClientEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);

  // request format (via Accept header) does not contain odata.streaming=true
  assertEquals("application/json;odata.metadata=minimal", req.getAccept());

  final ODataRetrieveResponse<ClientEntity> res = req.execute();

  // response payload is understood
  final ClientEntity entity = res.getBody();
  assertNotNull(entity);
  assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", entity.getTypeName().toString());
  assertEquals(102902, entity.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0);
  assertEquals("Edm.DateTimeOffset", entity.getProperty("CreatedDate").getPrimitiveValue().getTypeName());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:JSONFormatConformanceTestITCase.java

示例8: toString

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
protected String toString(final MultiLineString multiLineString, final Boolean isNullable, final Integer maxLength,
    final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {

  if (dimension != multiLineString.getDimension()) {
    throw new EdmPrimitiveTypeException("The value '" + multiLineString + "' is not valid.");
  }

  final StringBuilder result = toStringBuilder(multiLineString.getSrid()).
      append(reference.getSimpleName()).
      append('(');

  for (final Iterator<LineString> itor = multiLineString.iterator(); itor.hasNext();) {
    result.append('(').
    append(lineString(itor.next(), isNullable, maxLength, precision, scale, isUnicode)).
    append(')');
    if (itor.hasNext()) {
      result.append(',');
    }
  }

  return result.append(")'").toString();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:AbstractGeospatialType.java

示例9: validateSet

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
private void validateSet(final URI uri, final String cookie, final short... keys) throws EdmPrimitiveTypeException {
  final EdmEnabledODataClient client = getEdmEnabledClient();
  final ODataEntitySetRequest<ClientEntitySet> request = client.getRetrieveRequestFactory()
      .getEntitySetRequest(uri);
  request.addCustomHeader(HttpHeader.COOKIE, cookie);
  final ODataRetrieveResponse<ClientEntitySet> response = request.execute();

  assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
  assertEquals(3, response.getBody().getEntities().size());

  for (final ClientEntity responseEntity : response.getBody().getEntities()) {
    short propertyInt16 = responseEntity.getProperty(PROPERTY_INT16)
        .getPrimitiveValue().toCastValue(Short.class);

    boolean found = false;
    for (int i = 0; i < keys.length && !found; i++) {
      if (propertyInt16 == keys[i]) {
        found = true;
      }
    }

    if (!found) {
      fail("Invalid key " + propertyInt16);
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:DeepInsertITCase.java

示例10: internalValueToString

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
@Override
protected <T> String internalValueToString(final T value,
    final Boolean isNullable, final Integer maxLength, final Integer precision,
    final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {

  if (value instanceof Byte) {
    return value.toString();
  } else if (value instanceof Short || value instanceof Integer || value instanceof Long) {
    if (((Number) value).longValue() >= Byte.MIN_VALUE && ((Number) value).longValue() <= Byte.MAX_VALUE) {
      return value.toString();
    } else {
      throw new EdmPrimitiveTypeException("The value '" + value + "' is not valid.");
    }
  } else if (value instanceof BigInteger) {
    if (((BigInteger) value).bitLength() < Byte.SIZE) {
      return value.toString();
    } else {
      throw new EdmPrimitiveTypeException("The value '" + value + "' is not valid.");
    }
  } else {
    throw new EdmPrimitiveTypeException("The value type " + value.getClass() + " is not supported.");
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:EdmSByte.java

示例11: valueOfString

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
@Override
public final <T> T valueOfString(final String value,
    final Boolean isNullable, final Integer maxLength, final Integer precision,
    final Integer scale, final Boolean isUnicode, final Class<T> returnType)
    throws EdmPrimitiveTypeException {
  if (value == null) {
    if (isNullable != null && !isNullable) {
      throw new EdmPrimitiveTypeException("The literal 'null' is not allowed.");
    }
    return null;
  }
  if (value.equals("null")) {
    return null;
  } else {
    throw new EdmPrimitiveTypeException("The literal '" + value + "' has illegal content.");
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:EdmNull.java

示例12: collection

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
private void collection(final Valuable valuable, final XMLEventReader reader, final StartElement start,
    final EdmType edmType, final boolean isNullable, final Integer maxLength, final Integer precision,
    final Integer scale, final boolean isUnicode) throws XMLStreamException, EdmPrimitiveTypeException,
    DeserializerException {

  List<Object> values = new ArrayList<Object>();
  boolean foundEndProperty = false;
  while (reader.hasNext() && !foundEndProperty) {
    final XMLEvent event = reader.nextEvent();
    if (event.isStartElement()) {
      if (edmType instanceof EdmPrimitiveType) {
        values.add(primitive(reader, event.asStartElement(), edmType, isNullable,
            maxLength, precision, scale, isUnicode));
      } else if (edmType instanceof EdmComplexType) {
        values.add(complex(reader, event.asStartElement(), (EdmComplexType) edmType));
      }
      // do not add null or empty values
    }

    if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
      foundEndProperty = true;
    }
  }
  valuable.setValue(getValueType(edmType, true), values);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:ODataXmlDeserializer.java

示例13: timeOfDay

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
@Test
public void timeOfDay() throws EdmPrimitiveTypeException {
  final Calendar expected = Calendar.getInstance();
  expected.clear();
  expected.set(2013, 0, 10, 21, 45, 17);

  final ClientValue value = client.getObjectFactory().newPrimitiveValueBuilder()
      .setType(EdmPrimitiveTypeKind.TimeOfDay).setValue(expected).build();
  assertEquals(EdmPrimitiveTypeKind.TimeOfDay, value.asPrimitive().getTypeKind());

  final Calendar actual = value.asPrimitive().toCastValue(Calendar.class);
  assertEquals(expected.get(Calendar.HOUR), actual.get(Calendar.HOUR));
  assertEquals(expected.get(Calendar.MINUTE), actual.get(Calendar.MINUTE));
  assertEquals(expected.get(Calendar.SECOND), actual.get(Calendar.SECOND));

  assertEquals("21:45:17", value.asPrimitive().toString());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:PrimitiveValueTest.java

示例14: valueToString

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
@Override
public String valueToString(final Object value, final Boolean isNullable, final Integer maxLength,
    final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {

  if (value == null) {
    if (isNullable != null && !isNullable) {
      throw new EdmPrimitiveTypeException("The value NULL is not allowed.");
    }
    return null;
  }
  if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long) {
    return constructEnumValue(((Number) value).longValue());
  } else {
    throw new EdmPrimitiveTypeException("The value type " + value.getClass() + " is not supported.");
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:EdmEnumTypeImpl.java

示例15: internalValueOfString

import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; //导入依赖的package包/类
@Override
protected <T> T internalValueOfString(final String value,
    final Boolean isNullable, final Integer maxLength, final Integer precision,
    final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {

  if (isUnicode != null && !isUnicode && !PATTERN_ASCII.matcher(value).matches()
      || maxLength != null && maxLength < value.length()) {
    throw new EdmPrimitiveTypeException("The literal '" + value + "' does not match the facets' constraints.");
  }

  if (returnType.isAssignableFrom(String.class)) {
    return returnType.cast(value);
  } else {
    throw new EdmPrimitiveTypeException("The value type " + returnType + " is not supported.");
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:EdmString.java


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