com.fasterxml.jackson.core.Base64Variant Java Examples

The following examples show how to use com.fasterxml.jackson.core.Base64Variant. 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: BaseSettings.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public BaseSettings(ClassIntrospector ci, AnnotationIntrospector ai,
        PropertyNamingStrategy pns, TypeFactory tf,
        TypeResolverBuilder<?> typer, DateFormat dateFormat, HandlerInstantiator hi,
        Locale locale, TimeZone tz, Base64Variant defaultBase64)
{
    _classIntrospector = ci;
    _annotationIntrospector = ai;
    _propertyNamingStrategy = pns;
    _typeFactory = tf;
    _typeResolverBuilder = typer;
    _dateFormat = dateFormat;
    _handlerInstantiator = hi;
    _locale = locale;
    _timeZone = tz;
    _defaultBase64 = defaultBase64;
}
 
Example #2
Source File: BaseSettings.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @since 2.1
 */
public BaseSettings with(Base64Variant base64) {
    if (base64 == _defaultBase64) {
        return this;
    }
    return new BaseSettings(_classIntrospector, _annotationIntrospector,
            _propertyNamingStrategy, _typeFactory,
            _typeResolverBuilder, _dateFormat, _handlerInstantiator, _locale,
            _timeZone, base64);
}
 
Example #3
Source File: HoconTreeTraversingParser.java    From jackson-dataformat-hocon with Apache License 2.0 5 votes vote down vote up
@Override
public int readBinaryValue(Base64Variant b64variant, OutputStream out)
        throws IOException, JsonParseException
{
    byte[] data = getBinaryValue(b64variant);
    if (data != null) {
        out.write(data, 0, data.length);
        return data.length;
    }
    return 0;
}
 
Example #4
Source File: HoconTreeTraversingParser.java    From jackson-dataformat-hocon with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] getBinaryValue(Base64Variant b64variant)
    throws IOException, JsonParseException
{
    // otherwise return null to mark we have no binary content
    return null;
}
 
Example #5
Source File: BsonParser.java    From immutables with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] getBinaryValue(Base64Variant variant) throws IOException {
  if (type() != BsonType.BINARY) {
    throw new JsonParseException(this, String.format("Can't read binary data. Expected type %s got %s", BsonType.BINARY, type()));
  }

  if (!context.hasValue()) {
    readValue();
  }

  return (byte[]) context.value;
}
 
Example #6
Source File: PropertyFilteringJsonGenerator.java    From jackson-jaxrs-propertyfiltering with Apache License 2.0 5 votes vote down vote up
@Override
public int writeBinary(Base64Variant b64variant, InputStream data, int dataLength) throws IOException {
  if (itemFilter != null) {
    return delegate.writeBinary(b64variant, data, dataLength);
  } else {
    return -1;
  }
}
 
Example #7
Source File: KixeyeBsonParser.java    From chassis with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] getBinaryValue(Base64Variant b64variant) throws IOException, JsonParseException {
	Object obj = getEmbeddedObject();
	if (obj instanceof byte[]) {
		return (byte[])obj;
	} else {
		return getText().getBytes();
	}
}
 
Example #8
Source File: DocumentParser.java    From ojai with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] getBinaryValue(Base64Variant bv) throws IOException {
  ByteBuffer buf = r.getBinary();
  byte[] result = new byte[buf.remaining()];
  buf.get(result);
  return result;
}
 
Example #9
Source File: DocumentGenerator.java    From ojai with Apache License 2.0 5 votes vote down vote up
@Override
public void writeBinary(Base64Variant bv,
    byte[] data, int offset, int len) throws IOException {
  ByteBuffer buff = ByteBuffer.wrap(data, offset, len);
  if (inMap()) {
    b.put(currFieldName, buff);
  } else {
    b.add(buff);
  }
}
 
Example #10
Source File: CustomProtobufParser.java    From caravan with Apache License 2.0 5 votes vote down vote up
@Override
public int readBinaryValue(Base64Variant b64variant, OutputStream out) throws IOException
{
  if (_currToken != JsonToken.VALUE_EMBEDDED_OBJECT ) {
    _reportError("Current token ("+_currToken+") not VALUE_EMBEDDED_OBJECT, can not access as binary");
  }

  // !!! TBI
  return -1;
}
 
Example #11
Source File: CustomProtobufParser.java    From caravan with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] getBinaryValue(Base64Variant b64variant) throws IOException
{
  if (_tokenIncomplete) {
    _finishToken();
  }
  if (_currToken != JsonToken.VALUE_EMBEDDED_OBJECT ) {
    // TODO, maybe: support base64 for text?
    _reportError("Current token ("+_currToken+") not VALUE_EMBEDDED_OBJECT, can not access as binary");
  }
  return _binaryValue;
}
 
Example #12
Source File: JsonParserDecorator.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public byte[] getBinaryValue(final Base64Variant bv) throws IOException {
  return jsonParser.getBinaryValue(bv);
}
 
Example #13
Source File: JsonParserDecorator.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public int readBinaryValue(final Base64Variant bv, final OutputStream out) throws IOException {
  return jsonParser.readBinaryValue(bv, out);
}
 
Example #14
Source File: IonParser.java    From ibm-cos-sdk-java with Apache License 2.0 4 votes vote down vote up
@Override
public byte[] getBinaryValue(Base64Variant bv) throws IOException {
    throw new UnsupportedOperationException();
}
 
Example #15
Source File: DocumentGenerator.java    From ojai with Apache License 2.0 4 votes vote down vote up
@Override
public int writeBinary(Base64Variant bv,
    InputStream data, int dataLength) throws IOException {
  notImplemented();
  return 0;
}
 
Example #16
Source File: IonParser.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public byte[] getBinaryValue(Base64Variant bv) {
    throw new UnsupportedOperationException();
}
 
Example #17
Source File: MessagePackGenerator.java    From jackson-dataformat-msgpack with Apache License 2.0 4 votes vote down vote up
@Override
public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException, JsonGenerationException {
    addValueToStackTop(ByteBuffer.wrap(data, offset, len));
}
 
Example #18
Source File: PropertyFilteringJsonGenerator.java    From jackson-jaxrs-propertyfiltering with Apache License 2.0 4 votes vote down vote up
@Override
public void writeBinary(Base64Variant b64variant, byte[] data, int offset, int len) throws IOException {
  if (itemFilter != null) {
    delegate.writeBinary(b64variant, data, offset, len);
  }
}
 
Example #19
Source File: MincodeParser.java    From divolte-collector with Apache License 2.0 4 votes vote down vote up
@Override
public byte[] getBinaryValue(final Base64Variant b64variant) throws IOException {
    return b64variant.decode(_textBuffer.contentsAsString());
}
 
Example #20
Source File: BsonGenerator.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Override
public void writeBinary(Base64Variant bv, byte[] data, int offset, int len) throws IOException {
  throw new UnsupportedOperationException();
}
 
Example #21
Source File: BsonGenerator.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Override
public void writeBinary(Base64Variant bv, byte[] data, int offset, int len) throws IOException {
  BsonBinary binary = new BsonBinary(Arrays.copyOfRange(data, offset, offset + len));
  writer.writeBinaryData(binary);
}
 
Example #22
Source File: BaseSettings.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Base64Variant getBase64Variant() {
    return _defaultBase64;
}
 
Example #23
Source File: MapperConfigBase.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Method for constructing and returning a new instance with different
 * default {@link Base64Variant} to use with base64-encoded binary values.
 */
public final T with(Base64Variant base64) {
    return _withBase(_base.with(base64));
}
 
Example #24
Source File: MapperConfig.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Method called during deserialization if Base64 encoded content
 * needs to be decoded. Default version just returns default Jackson
 * uses, which is modified-mime which does not add linefeeds (because
 * those would have to be escaped in JSON strings); but this can
 * be configured on {@link ObjectWriter}.
 */
public Base64Variant getBase64Variant() {
    return _base.getBase64Variant();
}