Search in sources :

Example 16 with SerializedString

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.

the class UTF8NamesParseTest method _testNextFieldName.

private void _testNextFieldName(int mode, byte[] doc) throws IOException {
    SerializedString id = new SerializedString("id");
    JsonParser parser = createParser(mode, doc);
    assertEquals(parser.nextToken(), JsonToken.START_OBJECT);
    assertTrue(parser.nextFieldName(id));
    assertEquals(parser.nextToken(), JsonToken.VALUE_NUMBER_INT);
    assertEquals(parser.nextToken(), JsonToken.END_OBJECT);
    parser.close();
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString)

Example 17 with SerializedString

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.

the class TestSerializedString method testAppending.

public void testAppending() throws IOException {
    final String INPUT = "\"quo\\ted\"";
    final String QUOTED = "\\\"quo\\\\ted\\\"";
    SerializableString sstr = new SerializedString(INPUT);
    // sanity checks first:
    assertEquals(sstr.getValue(), INPUT);
    assertEquals(QUOTED, new String(sstr.asQuotedChars()));
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    assertEquals(QUOTED.length(), sstr.writeQuotedUTF8(bytes));
    assertEquals(QUOTED, bytes.toString("UTF-8"));
    bytes.reset();
    assertEquals(INPUT.length(), sstr.writeUnquotedUTF8(bytes));
    assertEquals(INPUT, bytes.toString("UTF-8"));
    byte[] buffer = new byte[100];
    assertEquals(QUOTED.length(), sstr.appendQuotedUTF8(buffer, 3));
    assertEquals(QUOTED, new String(buffer, 3, QUOTED.length()));
    Arrays.fill(buffer, (byte) 0);
    assertEquals(INPUT.length(), sstr.appendUnquotedUTF8(buffer, 5));
    assertEquals(INPUT, new String(buffer, 5, INPUT.length()));
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializableString(com.fasterxml.jackson.core.SerializableString) SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializableString(com.fasterxml.jackson.core.SerializableString)

Example 18 with SerializedString

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-databind by FasterXML.

the class SequenceWriterTest method testSimpleNonArray.

public void testSimpleNonArray() throws Exception {
    StringWriter strw = new StringWriter();
    SequenceWriter w = WRITER.forType(Bean.class).writeValues(strw);
    w.write(new Bean(13)).write(new Bean(-6)).writeAll(new Bean[] { new Bean(3), new Bean(1) }).writeAll(Arrays.asList(new Bean(5), new Bean(7)));
    w.close();
    assertEquals(aposToQuotes("{'a':13}\n{'a':-6}\n{'a':3}\n{'a':1}\n{'a':5}\n{'a':7}"), strw.toString());
    strw = new StringWriter();
    JsonGenerator gen = WRITER.getFactory().createGenerator(strw);
    w = WRITER.withRootValueSeparator(new SerializedString("/")).writeValues(gen);
    w.write(new Bean(1)).write(new Bean(2));
    w.close();
    gen.close();
    assertEquals(aposToQuotes("{'a':1}/{'a':2}"), strw.toString());
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) StringWriter(java.io.StringWriter) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator)

Example 19 with SerializedString

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-databind by FasterXML.

the class ObjectIdWriter method construct.

/**
     * Factory method called by {@link com.fasterxml.jackson.databind.ser.std.BeanSerializerBase}
     * with the initial information based on standard settings for the type
     * for which serializer is being built.
     * 
     * @since 2.3
     */
public static ObjectIdWriter construct(JavaType idType, PropertyName propName, ObjectIdGenerator<?> generator, boolean alwaysAsId) {
    String simpleName = (propName == null) ? null : propName.getSimpleName();
    SerializableString serName = (simpleName == null) ? null : new SerializedString(simpleName);
    return new ObjectIdWriter(idType, serName, generator, null, alwaysAsId);
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializableString(com.fasterxml.jackson.core.SerializableString) SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializableString(com.fasterxml.jackson.core.SerializableString)

Example 20 with SerializedString

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-databind by FasterXML.

the class UnwrappingBeanPropertyWriter method rename.

@Override
public UnwrappingBeanPropertyWriter rename(NameTransformer transformer) {
    String oldName = _name.getValue();
    String newName = transformer.transform(oldName);
    // important: combine transformers:
    transformer = NameTransformer.chainedTransformer(transformer, _nameTransformer);
    return _new(transformer, new SerializedString(newName));
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializedString(com.fasterxml.jackson.core.io.SerializedString)

Aggregations

SerializedString (com.fasterxml.jackson.core.io.SerializedString)23 SerializableString (com.fasterxml.jackson.core.SerializableString)4 Test (org.junit.Test)4 JsonpCharacterEscapes (com.fasterxml.jackson.core.util.JsonpCharacterEscapes)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 CharacterEscapes (com.fasterxml.jackson.core.io.CharacterEscapes)1 UTF8DataInputJsonParser (com.fasterxml.jackson.core.json.UTF8DataInputJsonParser)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 RawValue (com.fasterxml.jackson.databind.util.RawValue)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 BigDecimal (java.math.BigDecimal)1 ByteBuffer (java.nio.ByteBuffer)1 Random (java.util.Random)1