Package org.apache.abdera.ext.serializer

Examples of org.apache.abdera.ext.serializer.ConventionSerializationContext


    public void testSimple() throws Exception {
        Abdera abdera = Abdera.getInstance();
        StreamWriter sw = abdera.newStreamWriter();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        sw.setOutputStream(out).setAutoIndent(true);
        ConventionSerializationContext c = new ConventionSerializationContext(sw);
        c.setSerializer(MyEntry.class, new EntrySerializer());
        sw.startDocument();
        c.serialize(new MyEntry());
        sw.endDocument();

        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        Document<Entry> doc = abdera.getParser().parse(in);
        Entry entry = doc.getRoot();
View Full Code Here


    public void testAnnotated() throws Exception {
        Abdera abdera = Abdera.getInstance();
        StreamWriter sw = abdera.newStreamWriter();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        sw.setOutputStream(out).setAutoIndent(true);
        ConventionSerializationContext c = new ConventionSerializationContext(sw);
        sw.startDocument();
        c.serialize(new MyAnnotatedEntry());
        sw.endDocument();

        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        Document<Entry> doc = abdera.getParser().parse(in);
        Entry entry = doc.getRoot();
View Full Code Here

    try {
      if (tuple.length == 1) {       
        StreamWriter sw = abdera.newStreamWriter();
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          sw.setOutputStream(out).setAutoIndent(true);
          ConventionSerializationContext c =
            new ConventionSerializationContext(sw);
          c.setSerializer(tuple[0].getClass(), new EntrySerializer());
          sw.startDocument();
          c.serialize(tuple[0]);
          sw.endDocument();
         
          ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
          Document<Entry> doc = abdera.getParser().parse(in);
          Entry entry = doc.getRoot();
View Full Code Here

        // demonstrate serialization of a non-annotated java object
        StreamWriter sw = abdera.newStreamWriter();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        sw.setOutputStream(out).setAutoIndent(true);
        ConventionSerializationContext c = new ConventionSerializationContext(sw);
        c.setSerializer(MyEntry.class, new EntrySerializer());
        sw.startDocument();
        c.serialize(new MyEntry());
        sw.endDocument();

        // once the object has been serialized, we can see that it's a parseable Atom document
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        Document<Entry> doc = abdera.getParser().parse(in);
        Entry entry = doc.getRoot();
        entry.writeTo(System.out);

        System.out.println();

        // demonstrate serialization using an annotated java object
        // annotations allow the developer to customize the way the
        // object is serialized
        sw = abdera.newStreamWriter();
        out = new ByteArrayOutputStream();
        sw.setOutputStream(out).setAutoIndent(true);
        c = new ConventionSerializationContext(sw);
        sw.startDocument();
        c.serialize(new MyAnnotatedEntry());
        sw.endDocument();

        in = new ByteArrayInputStream(out.toByteArray());
        doc = abdera.getParser().parse(in);
        entry = doc.getRoot();
View Full Code Here

    // demonstrate serialization of a non-annotated java object
    StreamWriter sw = abdera.newStreamWriter();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    sw.setOutputStream(out)
      .setAutoIndent(true);
    ConventionSerializationContext c =
      new ConventionSerializationContext(sw);
    c.setSerializer(MyEntry.class, new EntrySerializer());
    sw.startDocument();
    c.serialize(new MyEntry());
    sw.endDocument();
   
    // once the object has been serialized, we can see that it's a parseable Atom document
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    Document<Entry> doc = abdera.getParser().parse(in);
    Entry entry = doc.getRoot();
    entry.writeTo(System.out);
   
    System.out.println();
   
    // demonstrate serialization using an annotated java object
    // annotations allow the developer to customize the way the
    // object is serialized
    sw = abdera.newStreamWriter();
    out = new ByteArrayOutputStream();
    sw.setOutputStream(out)
      .setAutoIndent(true);
    c = new ConventionSerializationContext(sw);
    sw.startDocument();
    c.serialize(new MyAnnotatedEntry());
    sw.endDocument();
   
    in = new ByteArrayInputStream(out.toByteArray());
    doc = abdera.getParser().parse(in);
    entry = doc.getRoot();
View Full Code Here

    Abdera abdera = Abdera.getInstance();
    StreamWriter sw = abdera.newStreamWriter();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    sw.setOutputStream(out)
      .setAutoIndent(true);
    ConventionSerializationContext c =
      new ConventionSerializationContext(sw);
    c.setSerializer(MyEntry.class, new EntrySerializer());
    sw.startDocument();
    c.serialize(new MyEntry());
    sw.endDocument();
   
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    Document<Entry> doc = abdera.getParser().parse(in);
    Entry entry = doc.getRoot();
View Full Code Here

    Abdera abdera = Abdera.getInstance();
    StreamWriter sw = abdera.newStreamWriter();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    sw.setOutputStream(out)
      .setAutoIndent(true);
    ConventionSerializationContext c =
      new ConventionSerializationContext(sw);
    sw.startDocument();
    c.serialize(new MyAnnotatedEntry());
    sw.endDocument();
   
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    Document<Entry> doc = abdera.getParser().parse(in);
    Entry entry = doc.getRoot();
View Full Code Here

TOP

Related Classes of org.apache.abdera.ext.serializer.ConventionSerializationContext

Copyright © 2018 www.massapicom. 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.