private Builder() { options = new PrimitiveValueSerializerOptions(); }
@Override public InputStream primitiveValue(final EdmPrimitiveType type, final Object value, final PrimitiveValueSerializerOptions options) throws SerializerException { try { final String result = type.valueToString(value, options.isNullable(), options.getMaxLength(), options.getPrecision(), options.getScale(), options.isUnicode()); return new ByteArrayInputStream(result.getBytes("UTF-8")); } catch (final EdmPrimitiveTypeException e) { throw new SerializerException("Error in primitive-value formatting.", e, SerializerException.MessageKeys.WRONG_PRIMITIVE_VALUE, type.getFullQualifiedName().getFullQualifiedNameAsString(), value.toString()); } catch (final UnsupportedEncodingException e) { throw new SerializerException("Encoding exception.", e, SerializerException.MessageKeys.IO_EXCEPTION); } }
@Override public SerializerResult serialize(final Annotatable result, final EdmType entityType) throws SerializerException, ODataJPASerializerException { final PrimitiveValueSerializerOptions options = PrimitiveValueSerializerOptions.with().build(); return new JPAValueSerializerResult(serializer.primitiveValue((EdmPrimitiveType) entityType, ((Property) result) .getValue(), options)); }
final PrimitiveValueSerializerOptions options = PrimitiveValueSerializerOptions.with().build(); serializerResult = serializer.primitiveValue(edmPropertyType, info.getProperty().getValue(), options);
@Override public InputStream primitiveValue(final EdmPrimitiveType type, final Object value, final PrimitiveValueSerializerOptions options) throws SerializerException { try { final String result = type.valueToString(value, options.isNullable(), options.getMaxLength(), options.getPrecision(), options.getScale(), options.isUnicode()); return new ByteArrayInputStream(result.getBytes("UTF-8")); } catch (final EdmPrimitiveTypeException e) { throw new SerializerException("Error in primitive-value formatting.", e, SerializerException.MessageKeys.WRONG_PRIMITIVE_VALUE, type.getFullQualifiedName().getFullQualifiedNameAsString(), value.toString()); } catch (final UnsupportedEncodingException e) { throw new SerializerException("Encoding exception.", e, SerializerException.MessageKeys.IO_EXCEPTION); } }
public void write(Object value) throws SerializerException { if (value == null) { writeNoContent(true); return; } if (this.type != null) { PrimitiveValueSerializerOptions options = PrimitiveValueSerializerOptions.with() .facetsFrom(this.type).build(); this.response.setContent(this.serializer.primitiveValue((EdmPrimitiveType) this.type.getType(), value, options)); } else { PrimitiveValueSerializerOptions options = PrimitiveValueSerializerOptions.with() .nullable(this.returnType.isNullable()).maxLength(this.returnType.getMaxLength()) .precision(this.returnType.getPrecision()).scale(this.returnType.getScale()).build(); this.response.setContent(this.serializer.primitiveValue( (EdmPrimitiveType) this.returnType.getType(), value, options)); } writeOK(ContentType.TEXT_PLAIN); }
private Builder() { options = new PrimitiveValueSerializerOptions(); }
public void write(Object value) throws SerializerException { if (value == null) { writeNoContent(true); return; } if (this.type != null) { PrimitiveValueSerializerOptions options = PrimitiveValueSerializerOptions.with() .facetsFrom(this.type).build(); this.response.setContent(this.serializer.primitiveValue((EdmPrimitiveType) this.type.getType(), value, options)); } else { PrimitiveValueSerializerOptions options = PrimitiveValueSerializerOptions.with() .nullable(this.returnType.isNullable()).maxLength(this.returnType.getMaxLength()) .precision(this.returnType.getPrecision()).scale(this.returnType.getScale()).build(); this.response.setContent(this.serializer.primitiveValue( (EdmPrimitiveType) this.returnType.getType(), value, options)); } writeOK(ContentType.TEXT_PLAIN); }