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();
}
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()));
}
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());
}
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);
}
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));
}
Aggregations