Search in sources :

Example 16 with MediaContent

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;
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) MediaContent(data.media.MediaContent)

Example 17 with MediaContent

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);
}
Also used : Media(data.media.Media) ArrayList(java.util.ArrayList) MediaContent(data.media.MediaContent) Image(data.media.Image)

Example 18 with MediaContent

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);
}
Also used : MediaContent(data.media.MediaContent)

Example 19 with MediaContent

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);
}
Also used : MediaContent(data.media.MediaContent)

Example 20 with MediaContent

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);
    }
}
Also used : MediaContent(data.media.MediaContent)

Aggregations

MediaContent (data.media.MediaContent)23 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 SerFeatures (serializers.SerFeatures)4 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)3 Image (data.media.Image)3 Media (data.media.Media)2 ArrayList (java.util.ArrayList)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 JSONLexer (com.alibaba.fastjson.parser.JSONLexer)1 SerializeConfig (com.alibaba.fastjson.serializer.SerializeConfig)1 SerializeWriter (com.alibaba.fastjson.serializer.SerializeWriter)1 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JavaType (com.fasterxml.jackson.databind.JavaType)1 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 AvroFactory (com.fasterxml.jackson.dataformat.avro.AvroFactory)1 AvroSchema (com.fasterxml.jackson.dataformat.avro.AvroSchema)1 CBORFactory (com.fasterxml.jackson.dataformat.cbor.CBORFactory)1 SmileFactory (com.fasterxml.jackson.dataformat.smile.SmileFactory)1