Examples of Serialization


Examples of com.xmlcalabash.model.Serialization

                    default:
                        throw new UnsupportedOperationException(format("Unsupported output kind '%s'", output.getKind()));
                }
            }

            Serialization serial = pipeline.getSerialization(port);

            if (serial == null) {
                // Use the configuration options
                // FIXME: should each of these be considered separately?
                // FIXME: should there be command-line options to override these settings?
                serial = new Serialization(runtime, pipeline.getNode()); // The node's a hack
                for (String name : config.serializationOptions.keySet()) {
                    String value = config.serializationOptions.get(name);

                    if ("byte-order-mark".equals(name)) serial.setByteOrderMark("true".equals(value));
                    if ("escape-uri-attributes".equals(name)) serial.setEscapeURIAttributes("true".equals(value));
                    if ("include-content-type".equals(name)) serial.setIncludeContentType("true".equals(value));
                    if ("indent".equals(name)) serial.setIndent("true".equals(value));
                    if ("omit-xml-declaration".equals(name)) serial.setOmitXMLDeclaration("true".equals(value));
                    if ("undeclare-prefixes".equals(name)) serial.setUndeclarePrefixes("true".equals(value));
                    if ("method".equals(name)) serial.setMethod(new QName("", value));

                    // FIXME: if ("cdata-section-elements".equals(name)) serial.setCdataSectionElements();
                    if ("doctype-public".equals(name)) serial.setDoctypePublic(value);
                    if ("doctype-system".equals(name)) serial.setDoctypeSystem(value);
                    if ("encoding".equals(name)) serial.setEncoding(value);
                    if ("media-type".equals(name)) serial.setMediaType(value);
                    if ("normalization-form".equals(name)) serial.setNormalizationForm(value);
                    if ("standalone".equals(name)) serial.setStandalone(value);
                    if ("version".equals(name)) serial.setVersion(value);
                }
            }

            // I wonder if there's a better way...
            WritableDocument wd = null;
View Full Code Here

Examples of com.xmlcalabash.model.Serialization

    }

    private void xmlReport(Output output) {
        if (!output.getPort().endsWith("|")) {
            pr.println("  <output port='" + output.getPort() + "'>");
            Serialization ser = output.getSerialization();
            if (ser != null) {
                pr.println("    <serialization method='" + ser.getMethod() + "'/>");
            }
            for (Binding binding : output.getBinding()) {
                xmlReport(binding);
            }
            pr.println("  </output>");
View Full Code Here

Examples of com.xmlcalabash.model.Serialization

    public WritableDocument(XProcRuntime xproc, String uri, Serialization serial) {
        this.runtime = xproc;
        this.uri = uri;

        if (serial == null) {
            this.serial = new Serialization(xproc, null);
            this.serial.setIndent(xproc.getDebug()); // indent stdio by default when debugging
        } else {
            this.serial = serial;
        }
    }
View Full Code Here

Examples of com.xmlcalabash.model.Serialization

        this.runtime = xproc;
        this.uri = uri;
        this.ostream = out;

        if (serial == null) {
            this.serial = new Serialization(xproc, null);
            this.serial.setIndent(xproc.getDebug()); // indent stdio by default when debugging
        } else {
            this.serial = serial;
        }
View Full Code Here

Examples of com.xmlcalabash.model.Serialization

    protected Representation getOutput(PipelineConfiguration pipeconfig, String port) {
        XProcConfiguration config = getConfiguration();
        XPipeline pipeline = pipeconfig.pipeline;
        XProcRuntime runtime = pipeconfig.runtime;
        Serialization serial = pipeline.getSerialization(port);

        if (serial == null) {
            // Use the configuration options
            // FIXME: should each of these be considered separately?
            // FIXME: should there be command-line options to override these settings?
            serial = new Serialization(runtime, pipeline.getNode()); // The node's a hack
            for (String name : config.serializationOptions.keySet()) {
                String value = config.serializationOptions.get(name);

                if ("byte-order-mark".equals(name)) serial.setByteOrderMark("true".equals(value));
                if ("escape-uri-attributes".equals(name)) serial.setEscapeURIAttributes("true".equals(value));
                if ("include-content-type".equals(name)) serial.setIncludeContentType("true".equals(value));
                if ("indent".equals(name)) serial.setIndent("true".equals(value));
                if ("omit-xml-declaration".equals(name)) serial.setOmitXMLDeclaration("true".equals(value));
                if ("undeclare-prefixes".equals(name)) serial.setUndeclarePrefixes("true".equals(value));
                if ("method".equals(name)) serial.setMethod(new QName("", value));

                // FIXME: if ("cdata-section-elements".equals(name)) serial.setCdataSectionElements();
                if ("doctype-public".equals(name)) serial.setDoctypePublic(value);
                if ("doctype-system".equals(name)) serial.setDoctypeSystem(value);
                if ("encoding".equals(name)) serial.setEncoding(value);
                if ("media-type".equals(name)) serial.setMediaType(value);
                if ("normalization-form".equals(name)) serial.setNormalizationForm(value);
                if ("standalone".equals(name)) serial.setStandalone(value);
                if ("version".equals(name)) serial.setVersion(value);
            }
        }

        if (!pipeconfig.outputs.containsKey(port)) {
            return badRequest(Status.CLIENT_ERROR_BAD_REQUEST, "no port named: " + port, MediaType.APPLICATION_XML);
View Full Code Here

Examples of io.fabric8.dosgi.api.Serialization

                    params[i] = decodeClass(parts[i+1]);
                }
                Method method = clazz.getMethod(name, params);


                Serialization annotation = method.getAnnotation(Serialization.class);
                SerializationStrategy serializationStrategy;
                if( annotation!=null ) {
                    serializationStrategy = serializationStrategies.get(annotation.value());
                    if( serializationStrategy==null ) {
                        throw new RuntimeException("Could not find the serialization strategy named: "+annotation.value());
                    }
                } else {
                    serializationStrategy = ObjectSerializationStrategy.INSTANCE;
                }
View Full Code Here

Examples of net.sf.uadetector.json.internal.data.serializer.Serialization

   * URL to retrieve the version of the UAS data
   */
  private static final URL VERSION_URL = JsonDataCreator.class.getClassLoader().getResource("samples/uas.version");

  public static void createOrUpdate(final DataStore store) throws IOException {
    final Serialization serialization = JsonConverter.serialize(store.getData(), SerDeOption.PRETTY_PRINTING);
    final String json = serialization.getJson();

    // get resources directory
    final File resourcesDir = new File(ClassLoader.getSystemResource(".").getPath() + "../../src/test/resources");
    Check.stateIsTrue(resourcesDir.exists(), "the specified resources directory must be available");

View Full Code Here

Examples of net.sf.uadetector.json.internal.data.serializer.Serialization

  @Test
  public void testConversionViceVersa() throws IOException, URISyntaxException {
    final SerDeOption options = SerDeOption.PRETTY_PRINTING;
    final DataStore store = TestDataStoreFactory.produce();
    Serialization serialization = JsonConverter.serialize(store.getData(), options);
    assertThat(serialization.getWarnings()).isEmpty();
    final String json = serialization.getJson();
    final Data parsedData = JsonConverter.deserialize(json).getData();

    // can not be equals, because the IDs are different
    assertThat(store.getData().equals(parsedData)).isFalse();

    // must be equals, because the IDs are identical after conversion
    Serialization serialization2 = JsonConverter.serialize(store.getData(), options);
    assertThat(serialization2.getWarnings()).isEmpty();
    final String expectedJson = serialization2.getJson();
    final Data expectedData = JsonConverter.deserialize(expectedJson).getData();
    assertThat(json).isEqualTo(expectedJson);
    assertThat(parsedData).isEqualTo(expectedData);

    // print some JSON
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.io.Serialization

        final Serialization.TYPE[] types = {Serialization.TYPE.HADOOP, Serialization.TYPE.JAVA};

        for (final Serialization.TYPE type : types) {

            Serialization ser = Serialization.getSerializationStrategy(type);

            final Random random = new Random(System.currentTimeMillis());

            // Boolean array
            final List<Boolean> boolList = Lists.newArrayList();
            for (int i = 0; i < total; i++)
                boolList.add((random.nextInt() % 2) > 0);
            final boolean[] boolarr1 = new boolean[boolList.size()];
            pos = 0;
            for (final Boolean val : boolList)
                boolarr1[pos++] = val;
            b = ser.getArrayAsBytes(FieldType.BooleanType, boolarr1);
            final boolean[] boolarr2 = (boolean[])ser.getArrayFromBytes(FieldType.BooleanType, Boolean.TYPE, b);
            assertTrue(Arrays.equals(boolarr1, boolarr2));

            // Byte array
            final List<Byte> byteList = Lists.newArrayList();
            for (int i = 0; i < total; i++)
                byteList.add((byte)(random.nextInt() % Byte.MAX_VALUE));
            final byte[] bytearr1 = new byte[byteList.size()];
            pos = 0;
            for (final Byte val : byteList)
                bytearr1[pos++] = val;
            b = ser.getArrayAsBytes(FieldType.ByteType, bytearr1);
            final byte[] bytearr2 = (byte[])ser.getArrayFromBytes(FieldType.ByteType, Byte.TYPE, b);
            assertTrue(Arrays.equals(bytearr1, bytearr2));

            // Char array
            final StringBuilder sbuf = new StringBuilder();
            for (int i = 0; i < total; i++) {
                String s = "" + System.nanoTime();
                String t = s.substring(s.length() - 5, s.length() - 4);
                sbuf.append(t);
            }
            final char[] chararr1 = sbuf.toString().toCharArray();
            b = ser.getArrayAsBytes(FieldType.CharType, chararr1);
            final char[] chararr2 = (char[])ser.getArrayFromBytes(FieldType.CharType, Short.TYPE, b);
            assertTrue(Arrays.equals(chararr1, chararr2));

            // Short array
            final List<Short> shortList = Lists.newArrayList();
            for (int i = 0; i < total; i++)
                shortList.add((short)random.nextInt());
            final short[] shortarr1 = new short[shortList.size()];
            pos = 0;
            for (final Short val : shortList)
                shortarr1[pos++] = val;
            b = ser.getArrayAsBytes(FieldType.ShortType, shortarr1);
            final short[] shortarr2 = (short[])ser.getArrayFromBytes(FieldType.ShortType, Short.TYPE, b);
            assertTrue(Arrays.equals(shortarr1, shortarr2));

            // Int array
            final List<Integer> intList = Lists.newArrayList();
            for (int i = 0; i < total; i++)
                intList.add(random.nextInt());
            final int[] intarr1 = new int[intList.size()];
            pos = 0;
            for (final Integer val : intList)
                intarr1[pos++] = val;
            b = ser.getArrayAsBytes(FieldType.IntegerType, intarr1);
            final int[] intarr2 = (int[])ser.getArrayFromBytes(FieldType.IntegerType, Integer.TYPE, b);
            assertTrue(Arrays.equals(intarr1, intarr2));

            // Long Array
            final List<Long> longList = Lists.newArrayList();
            for (int i = 0; i < total; i++)
                longList.add(random.nextLong());
            final long[] longarr1 = new long[longList.size()];
            pos = 0;
            for (final Long val : longList)
                longarr1[pos++] = val;
            b = ser.getArrayAsBytes(FieldType.LongType, longarr1);
            final long[] longarr2 = (long[])ser.getArrayFromBytes(FieldType.LongType, Long.TYPE, b);
            assertTrue(Arrays.equals(longarr1, longarr2));

            // Float Array
            final List<Float> floatList = Lists.newArrayList();
            for (int i = 0; i < total; i++)
                floatList.add(random.nextFloat());
            final float[] floatarr1 = new float[floatList.size()];
            pos = 0;
            for (final Float val : floatList)
                floatarr1[pos++] = val;
            b = ser.getArrayAsBytes(FieldType.FloatType, floatarr1);
            final float[] floatarr2 = (float[])ser.getArrayFromBytes(FieldType.FloatType, Float.TYPE, b);
            assertTrue(Arrays.equals(floatarr1, floatarr2));

            // Double Array
            final List<Double> doubleList = Lists.newArrayList();
            for (int i = 0; i < total; i++)
                doubleList.add(random.nextDouble());
            final double[] doublearr1 = new double[doubleList.size()];
            pos = 0;
            for (final Double val : doubleList)
                doublearr1[pos++] = val;
            b = ser.getArrayAsBytes(FieldType.DoubleType, doublearr1);
            final double[] doublearr2 = (double[])ser.getArrayFromBytes(FieldType.DoubleType, Double.TYPE, b);
            assertTrue(Arrays.equals(doublearr1, doublearr2));

            // String Array
            final List<String> stringList = Lists.newArrayList();
            for (int i = 0; i < total; i++)
                stringList.add((new Date(random.nextLong()).toString()));
            final String[] stringarr1 = new String[stringList.size()];
            pos = 0;
            for (final String val : stringList)
                stringarr1[pos++] = val;
            b = ser.getArrayAsBytes(FieldType.StringType, stringarr1);
            final String[] stringarr2 = (String[])ser.getArrayFromBytes(FieldType.StringType, String.class, b);
            assertTrue(Arrays.equals(stringarr1, stringarr2));

            // Date Array
            final List<Date> dateList = Lists.newArrayList();
            for (int i = 0; i < total; i++)
                dateList.add(new Date(random.nextLong()));
            final Date[] datearr1 = new Date[dateList.size()];
            pos = 0;
            for (final Date val : dateList)
                datearr1[pos++] = val;
            b = ser.getArrayAsBytes(FieldType.DateType, datearr1);
            final Date[] datearr2 = (Date[])ser.getArrayFromBytes(FieldType.DateType, Date.class, b);
            assertTrue(Arrays.equals(datearr1, datearr2));

            // Object Array
            final List<Object> objectList = Lists.newArrayList();
            for (int i = 0; i < total; i++)
                objectList.add(new TestClass("" + random.nextDouble(), random.nextInt(), random.nextDouble()));
            final Object[] objarr1 = new Object[objectList.size()];
            pos = 0;
            for (final Object val : objectList)
                objarr1[pos++] = val;
            b = ser.getArrayAsBytes(FieldType.ObjectType, objarr1);
            final Object[] objarr2 = (Object[])ser.getArrayFromBytes(FieldType.ObjectType, Object.class, b);
            assertTrue(Arrays.equals(objarr1, objarr2));
        }
    }
View Full Code Here

Examples of org.apache.hadoop.io.serializer.Serialization

   */
  @SuppressWarnings({"unchecked"})
  public OutputCollector getMapperCollector(int mapperIndex,
                                            OutputCollector output,
                                            Reporter reporter) {
    Serialization keySerialization = mappersKeySerialization.get(mapperIndex);
    Serialization valueSerialization =
      mappersValueSerialization.get(mapperIndex);
    return new ChainOutputCollector(mapperIndex, keySerialization,
                                    valueSerialization, output, reporter);
  }
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.