Example usage for com.fasterxml.jackson.core JsonGenerator writeString

List of usage examples for com.fasterxml.jackson.core JsonGenerator writeString

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonGenerator writeString.

Prototype

public abstract void writeString(SerializableString text) throws IOException, JsonGenerationException;

Source Link

Document

Method similar to #writeString(String) , but that takes SerializableString which can make this potentially more efficient to call as generator may be able to reuse quoted and/or encoded representation.

Usage

From source file:com.googlecode.wickedcharts.highcharts.jackson.HexColorReferenceSerializer.java

@Override
protected void serializeIfNotNull(final HexColor color, final JsonGenerator jgen,
        final SerializerProvider provider) throws JsonGenerationException, IOException {
    if (color.getBrightness() == null) {
        jgen.writeString(color.getHexColor());
    } else {//ww  w .  j a  va  2s.  c  o  m
        String colorString = brighten("\"" + color.getHexColor() + "\"", color.getBrightness());
        jgen.writeRawValue(colorString);
    }

}

From source file:com.googlecode.wickedcharts.highcharts.jackson.SimpleColorReferenceSerializer.java

@Override
protected void serializeIfNotNull(final SimpleColor color, final JsonGenerator jgen,
        final SerializerProvider provider) throws IOException, JsonProcessingException {
    if (color.getBrightness() == null) {
        jgen.writeString(toHexString(color.getColor()));
    } else {// w w  w . ja  va  2  s  .c om
        String colorString = brighten("\"" + toHexString(color.getColor()) + "\"", color.getBrightness());
        jgen.writeRawValue(colorString);
    }

}

From source file:craterdog.security.mappers.PublicKeySerializer.java

@Override
public void serialize(PublicKey publicKey, JsonGenerator generator, SerializerProvider provider)
        throws IOException, JsonProcessingException {
    String pemValue = manager.encodePublicKey(publicKey);
    generator.writeString(pemValue);
}

From source file:com.hotelbeds.hotelcontentapi.auto.convert.json.DateSerializer.java

@Override
public void serialize(final LocalDate date, final JsonGenerator generator, final SerializerProvider provider)
        throws IOException {
    final String dateString = date.format(REST_FORMATTER);
    generator.writeString(dateString);
}

From source file:com.hotelbeds.hotelcontentapi.auto.convert.json.TimeSerializer.java

@Override
public void serialize(final LocalTime date, final JsonGenerator generator, final SerializerProvider provider)
        throws IOException {
    final String dateString = date.format(REST_FORMATTER);
    generator.writeString(dateString);
}

From source file:com.boundary.sdk.event.util.UnixTimeSerializer.java

@Override
public void serialize(Date value, JsonGenerator gen, SerializerProvider arg2)
        throws IOException, JsonProcessingException {
    long timestamp = value.getTime();
    timestamp = timestamp / 1000;/*  w  ww. j a va2  s  .c  o  m*/
    gen.writeString(Long.toString(timestamp));
}

From source file:org.moserp.common.rest.WithConverterSerializer.java

@Override
public void serialize(TYPE value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
    if (value == null) {
        serializers.defaultSerializeNull(gen);
    } else {/*from w  ww  . ja v a  2  s  .c  o  m*/
        gen.writeString(converter.convert(value));
    }
}

From source file:org.onebusaway.nextbus.impl.rest.jackson.CapitalizeSerializer.java

@Override
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers)
        throws IOException, JsonProcessingException {
    if (value == null) {
        gen.writeNull();/*from  ww  w .j  ava2  s.  co m*/
    }
    gen.writeString(WordUtils.capitalizeFully(value));
}

From source file:com.googlecode.wickedcharts.highcharts.jackson.RgbaColorReferenceSerializer.java

@Override
protected void serializeIfNotNull(final RgbaColor color, final JsonGenerator jgen,
        final SerializerProvider provider) throws IOException, JsonProcessingException {
    if (color.getBrightness() == null) {
        jgen.writeString(String.format(Locale.ENGLISH, RGBA, color.getRed(), color.getGreen(), color.getBlue(),
                color.getAlpha()));/*from  www .  jav  a  2 s .c o m*/
    } else {
        String colorString = brighten("\"" + String.format(Locale.ENGLISH, RGBA, color.getRed(),
                color.getGreen(), color.getBlue(), color.getAlpha()) + "\"", color.getBrightness());
        jgen.writeRawValue(colorString);
    }

}

From source file:de.terrestris.shogun.serializer.WKTSerializer.java

/**
 * Overwrite the original serialize and return a WKT of the JTS geometry.
 *///from w  ww .  ja  v  a  2  s  .c  om
@Override
public void serialize(Geometry jtsGeometry, JsonGenerator jgen, SerializerProvider provider)
        throws IOException, JsonProcessingException {
    // returns the geometry as well known text
    jgen.writeString(jtsGeometry.toText());
}