use of data.media.MediaContent in project jvm-serializers by eishay.
the class BaseStaxMediaSerializer method deserializeItems.
@Override
public MediaContent[] deserializeItems(InputStream in, int numberOfItems) throws XMLStreamException {
XMLStreamReader parser = createReader(in);
MediaContent[] result = _deserializer.readDocument(parser, numberOfItems);
parser.close();
return result;
}
use of data.media.MediaContent in project jvm-serializers by eishay.
the class StaxDeserializer method readMediaContent.
private MediaContent readMediaContent(XMLStreamReader parser) throws XMLStreamException {
searchTag(parser, "mc");
Media media = readMedia(parser);
List<Image> images = new ArrayList<Image>();
if (parser.nextTag() != XMLStreamConstants.START_ELEMENT) {
throw new IllegalStateException("Expected <im>, no START_ELEMENT encountered but " + parser.getEventType());
}
do {
if (!FULL_FIELD_NAME_IMAGES.equals(parser.getLocalName())) {
throw new IllegalStateException("Expected <" + FULL_FIELD_NAME_IMAGES + ">, got <" + parser.getLocalName() + ">");
}
images.add(readImage(parser));
} while (parser.nextTag() == XMLStreamConstants.START_ELEMENT);
// and should have closing </mc> at this point
if (!"mc".equals(parser.getLocalName())) {
throw new IllegalStateException("Expected closing </mc>, got </" + parser.getLocalName() + ">");
}
return new MediaContent(media, images);
}
use of data.media.MediaContent in project fastjson by alibaba.
the class TestASMEishay method test_asm.
public void test_asm() throws Exception {
String text = JSON.toJSONString(EishayEncode.mediaContent, SerializerFeature.WriteEnumUsingToString);
System.out.println(text);
System.out.println(text.getBytes().length);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
}
use of data.media.MediaContent in project fastjson by alibaba.
the class WriteAsArray_Eishay method test_0.
public void test_0() throws Exception {
MediaContent content = EishayDecodeBytes.instance.getContent();
String text = JSON.toJSONString(content, SerializerFeature.BeanToArray);
System.out.println(text.getBytes().length);
JSON.parseObject(text, MediaContent.class, Feature.SupportArrayToBean);
}
use of data.media.MediaContent in project fastjson by alibaba.
the class BenchmarkMain_EishayEncode method main.
public static void main(String[] args) throws Exception {
System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
System.out.println(arguments);
MediaContent content = EishayDecodeBytes.instance.getContent();
String text = encode(content);
System.out.println(text);
for (int i = 0; i < 10; ++i) {
perf(text);
}
}
Aggregations