You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@abdera.apache.org by James M Snell <ja...@gmail.com> on 2006/06/28 16:16:13 UTC

Named Parsers and Writers

One of the goals I've been working towards is the ability to output and
parse Atom from alternative formats.  For instance, we have a JSON
rendering of Atom we've been working on.  There's also an RDF rendering.
I've extended Parser and have introduced new Writer interfaces to allow
for this.

For instance, suppose I want to output Atom as JSON...

  Writer writer = WriterFactory.getInstance("json");
  writer.writeTo(feed, outputStream);

Or, RDF

  Writer writer = WriterFactory.getInstance("rdf");
  writer.writeTo(feed, outputStream);

Alternatively, I could new up a Writer

  Writer writer = new JsonWriter();

It would work the same on the parsing side.  Suppose I want to parse
from JSON or RDF

  Parser parser = ParserFactory.getInstance("json");
  parser.parse(...)

  Parser parser = ParserFactory.getInstance("rdf");
  parser.parse(...)

The named parsers implement the exact same API as the default Abdera parser.

If there are no objections, I'll check it in.

- James

Re: Named Parsers and Writers

Posted by Elias Torres <el...@torrez.us>.
+1

On 6/28/06, James M Snell <ja...@gmail.com> wrote:
> One of the goals I've been working towards is the ability to output and
> parse Atom from alternative formats.  For instance, we have a JSON
> rendering of Atom we've been working on.  There's also an RDF rendering.
> I've extended Parser and have introduced new Writer interfaces to allow
> for this.
>
> For instance, suppose I want to output Atom as JSON...
>
>   Writer writer = WriterFactory.getInstance("json");
>   writer.writeTo(feed, outputStream);
>
> Or, RDF
>
>   Writer writer = WriterFactory.getInstance("rdf");
>   writer.writeTo(feed, outputStream);
>
> Alternatively, I could new up a Writer
>
>   Writer writer = new JsonWriter();
>
> It would work the same on the parsing side.  Suppose I want to parse
> from JSON or RDF
>
>   Parser parser = ParserFactory.getInstance("json");
>   parser.parse(...)
>
>   Parser parser = ParserFactory.getInstance("rdf");
>   parser.parse(...)
>
> The named parsers implement the exact same API as the default Abdera parser.
>
> If there are no objections, I'll check it in.
>
> - James
>