Examples of Serializer


Examples of org.terasology.persistence.typeHandling.Serializer

    }


    private <T extends Component> Component deserializeOnto(Component targetComponent, EntityData.Component componentData,
                                                            ComponentMetadata<T> componentMetadata, FieldSerializeCheck<Component> fieldCheck) {
        Serializer serializer = typeSerializationLibrary.getSerializerFor(componentMetadata);
        DeserializationContext context = new ProtobufDeserializationContext(typeSerializationLibrary);
        Map<FieldMetadata<?, ?>, PersistedData> dataMap = Maps.newHashMapWithExpectedSize(componentData.getFieldCount());
        for (EntityData.NameValue field : componentData.getFieldList()) {
            FieldMetadata<?, ?> fieldInfo = null;
            if (field.hasNameIndex()) {
                fieldInfo = componentMetadata.getField(field.getNameIndex());
            } else if (field.hasName()) {
                fieldInfo = componentMetadata.getField(field.getName());
            }
            if (fieldInfo != null) {
                dataMap.put(fieldInfo, new ProtobufPersistedData(field.getValue()));
            } else if (field.hasNameIndex()) {
                logger.warn("Cannot deserialize unknown field '{}' onto '{}'", field.getName(), componentMetadata.getUri());
            }
        }
        serializer.deserializeOnto(targetComponent, dataMap, context, fieldCheck);
        return targetComponent;
    }
View Full Code Here

Examples of org.uengine.kernel.Serializer

    }

    if(args[1].indexOf(".") == -1) args[1] = "org.uengine.components.serializers." + args[1];
    if(args[2].indexOf(".") == -1) args[2] = "org.uengine.components.serializers." + args[2];
   
    Serializer sourceSerializer = (Serializer)Class.forName(args[1]).newInstance();
    Serializer targetSerializer = (Serializer)Class.forName(args[2]).newInstance();
   
    find(args[0], sourceSerializer, targetSerializer);
  }
View Full Code Here

Examples of org.wymiwyg.r3xserializer.Serializer

           
            if (stylesheet != null) {
              outS.write(("<?xml-stylesheet type=\"text/xsl\" href=\""+stylesheet+"\"?>\n").getBytes("utf-8"));
            }
            Writer outW = new OutputStreamWriter(outS, "utf-8");
            new Serializer().serialize(model, "", outW);
            outW.flush();
            //model.write(outS);
            outS.close();
          }
         
View Full Code Here

Examples of org.yaml.snakeyaml.serializer.Serializer

        {
            throw new IllegalArgumentException("rootNode is null");
        }
        DumperOptions dumperOptions = new DumperOptions();
        Tag rootTag = dumperOptions.getExplicitRoot();
        Serializer serializer = new Serializer(new Emitter(output, dumperOptions), new Resolver(),
                                               dumperOptions, rootTag);
        try
        {
            serializer.open();
            serializer.serialize(rootNode);
            serializer.close();
        }
        catch (IOException e)
        {
            throw new YAMLException(e);
        }
View Full Code Here

Examples of pivot.serialization.Serializer

public class PropertiesSerializerTest
{
    @SuppressWarnings({"unchecked"})
    public static void main(String[] args) {
        Serializer serializer = new PropertiesSerializer();

        Map<String, Object> testMap = new HashMap<String, Object>();
        testMap.put("hello",   "Hello World");
        testMap.put("number"123.456);
        testMap.put("boolean", true);
        testMap.put("i18n",    "€ & אטלעש")// test some chars to encode ...
        testMap.put("object"new Object());

        ByteArrayOutputStream outputStream = null;
        try {
            try {
                outputStream = new ByteArrayOutputStream();
                serializer.writeObject(testMap, outputStream);
            } finally {
                outputStream.close();

                String dump = new String(outputStream.toByteArray());
                System.out.println("Succesfully Written");
                System.out.println(dump);
            }
        } catch(Exception exception) {
            System.out.println(exception);
        }

        ByteArrayInputStream inputStream = null;
        Map<String, Object> readData = null;
        try {
            try {
                inputStream = new ByteArrayInputStream(outputStream.toByteArray());
                readData = (Map<String, Object>) serializer.readObject(inputStream);

                System.out.println("Succesfully Read");
                for (String key : readData) {
                    System.out.println(key + "=" + readData.get(key));
                }
View Full Code Here

Examples of test.javax.management.compliance.serialization.support.Serializer

   }

   public void testDefaultSerialization()
   {
      int expectedHash = priceParamInfo.hashCode();
      Serializer serializer = new Serializer();

      try
      {
         byte[] data = serializer.serialize(priceParamInfo);

         Object obj = serializer.deserialize(data);
         // assert instanceof
         assertTrue(obj instanceof OpenMBeanParameterInfo);

         // if instanceof passes continue otherwise we will not get to the rest
         OpenMBeanParameterInfo type = (OpenMBeanParameterInfo)obj;
View Full Code Here

Examples of voldemort.serialization.Serializer

    public void testMapTypeKeyOrder() {
        String typeSig = "{\"name\":\"string\", \"color\":\"string\", \"age\":\"int32\"}";
        Object data = ImmutableMap.of("name", "xxx", "color", "yyy", "age", 28);

        Serializer outOfOrderSerializer = new JsonTypeSerializer(new JsonTypeDefinition(ImmutableMap.of("name",
                                                                                                        JsonTypes.STRING,
                                                                                                        "color",
                                                                                                        JsonTypes.STRING,
                                                                                                        "age",
                                                                                                        JsonTypes.INT32)));
        assertEquals("Key order in Map should not matter while serializing/deserializing",
                     data,
                     outOfOrderSerializer.toObject(getSerializer(typeSig).toBytes(data)));

        outOfOrderSerializer = new JsonTypeSerializer(new JsonTypeDefinition(ImmutableMap.of("color",
                                                                                             JsonTypes.STRING,
                                                                                             "age",
                                                                                             JsonTypes.INT32,
                                                                                             "name",
                                                                                             JsonTypes.STRING)));
        assertEquals("Key order in Map should not matter while serializing/deserializing",
                     data,
                     outOfOrderSerializer.toObject(getSerializer(typeSig).toBytes(data)));

        outOfOrderSerializer = new JsonTypeSerializer(new JsonTypeDefinition(ImmutableMap.of("age",
                                                                                             JsonTypes.INT32,
                                                                                             "name",
                                                                                             JsonTypes.STRING,
                                                                                             "color",
                                                                                             JsonTypes.STRING)));
        assertEquals("Key order in Map should not matter while serializing/deserializing",
                     data,
                     outOfOrderSerializer.toObject(getSerializer(typeSig).toBytes(data)));

        outOfOrderSerializer = new JsonTypeSerializer(new JsonTypeDefinition(ImmutableMap.of("color",
                                                                                             JsonTypes.STRING,
                                                                                             "name",
                                                                                             JsonTypes.STRING,
                                                                                             "age",
                                                                                             JsonTypes.INT32)));
        assertEquals("Key order in Map should not matter while serializing/deserializing",
                     data,
                     outOfOrderSerializer.toObject(getSerializer(typeSig).toBytes(data)));

    }
View Full Code Here

Examples of xbird.xquery.dm.ser.Serializer

        if(DEBUG_LIGHT) {
            System.err.println(query);
        }
        XQueryModule mod = processor.parse(query, uri);
        StringWriter res_sw = new StringWriter();
        Serializer ser = new SAXSerializer(new SAXWriter(res_sw), res_sw);
        processor.execute(mod, ser);
        //Sequence<? extends Item> reseq = processor.execute(mod);
        //ser.emit(reseq);
        String result = res_sw.toString();
        return result;
View Full Code Here

Examples of xbird.xquery.dm.ser.Serializer

                        try {
                            XQueryModule mod = proc.parse(query, baseUri);
                            Sequence result = proc.execute(mod);
                            SAXWriter saxwriter = new SAXWriter(res_sw, SAXWriter.DEFAULT_ENCODING);
                            saxwriter.setXMLDeclaration(false);
                            Serializer ser = new SAXSerializer(saxwriter, res_sw);
                            ser.emit(result);
                        } catch (Throwable ex) {
                            final int errors = expectedErrors.getLength();
                            if(errors == 0) {
                                final Node expectedOutputs = (Node) xpath.evaluate("./*[local-name()='output-file'][last()]", testCase, XPathConstants.NODE);
                                assert (expectedOutputs != null);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.