You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2007/08/21 23:03:09 UTC

svn commit: r568280 - /incubator/abdera/java/trunk/docs/gettingstarted.html

Author: jmsnell
Date: Tue Aug 21 14:03:09 2007
New Revision: 568280

URL: http://svn.apache.org/viewvc?rev=568280&view=rev
Log:
Updating docs

Modified:
    incubator/abdera/java/trunk/docs/gettingstarted.html

Modified: incubator/abdera/java/trunk/docs/gettingstarted.html
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/docs/gettingstarted.html?rev=568280&r1=568279&r2=568280&view=diff
==============================================================================
--- incubator/abdera/java/trunk/docs/gettingstarted.html (original)
+++ incubator/abdera/java/trunk/docs/gettingstarted.html Tue Aug 21 14:03:09 2007
@@ -45,24 +45,26 @@
     Atom Publishing Protocol Introspection Documents, and any other arbitrary, 
     well-formed XML document.</p>
     
-    <p>User's can either use the default <code>org.apache.abdera.parser.Parser</code> 
-    instance by calling <code>Parser.INSTANCE</code>, or they may create an new
-    <code>Parser</code> instance.
-    
-    <pre>Parser parser = Parser.INSTANCE;
-// or
-Parser parser = new FOMParser();
-// or
+    <pre>Abdera abdera = new Abdera();
+Parser parser = abdera.getParser();
+// or 
 Parser parser = new MyCustomParser();</pre>
 
     <p>The <code>Parser</code> will automatically detect the kind of document
     being parsed and will return an appropriate <code>org.apache.abdera.model.Document</code>.
+
+<pre>
+InputStream in = ...
+Document&lt;Feed&gt; feeddoc = parser.parse(in);
+Document&lt;Entry&gt; entrydoc = parser.parse(in);
+Document&lt;Service&gt; servicedoc = parser.parse(in);
+</pre>
     
     <h3>Parsing an Atom Feed</h3>
         
     <pre>URI uri = new URI("http://example.org/feed.xml");
 InputStream in = uri.toURL().openStream();
-Document&lt;Feed&gt; doc = Parser.INSTANCE.parse(in, uri);</pre>
+Document&lt;Feed&gt; doc = parser.parse(in, uri);</pre>
 
     <p>The <code>uri</code> parameter on the <code>parse</code> method establishes
     the Base URI for the parsed document and is used as the basis for relative
@@ -71,34 +73,31 @@
     <h3>Parsing an Atom Entry</h3>
     <pre>URI uri = new URI("http://example.org/entry.xml");
 InputStream in = uri.toURL().openStream();
-Document&lt;Entry&gt; doc = Parser.INSTANCE.parse(in, uri);</pre>
+Document&lt;Entry&gt; doc = parser.parse(in, uri);</pre>
    
     <h3>Configuring the Parser</h3>
     
     <pre>URI uri = new URI("http://example.org/feed.xml");
 InputStream in = uri.toURL().openStream();
-<b>ParserOptions options = Parser.INSTANCE.getDefaultParserOptions();
-options.setCharset('utf-8');
+<b>ParserOptions options = parser.getDefaultParserOptions();
+options.setCharset("utf-8");
 //.. set other parser options</b>
-Document&lt;Feed&gt; doc = Parser.INSTANCE.parse(in, uri, options);</pre>
+Document&lt;Feed&gt; doc = parser.parse(in, uri, options);</pre>
     
     <h2>Creating Atom Feed and Entry Documents</h2>
     
-    <t>Atom Feed and Entry documents are created using instances of the 
-    <code>org.apache.abdera.factory.Factory</code> interface.  User's can
-    either use the default configured Factory by calling <code>Factory.INSTANCE</code>,
-    or may create their own Factory instance.</t>
+    <p>Atom Feed and Entry documents are created using instances of the 
+    <code>org.apache.abdera.factory.Factory</code> interface.</p>
     
-    <pre>Factory factory = Factory.INSTANCE;
-// or
-Factory factory = new FOMFactory();
+    <pre>Abdera abdera = new Abdera();
+Factory factory = abdera.getFactory();
 // or
 Factory factory = new MyCustomFactory();</pre>
 
     <h3>Creating Atom Feed Documents</h3>
     
-    <pre>Feed feed = Factory.INSTANCE.newFeed();
-feed.setId("tag:example.org,2005:/myfeed", false);
+    <pre>Feed feed = factory.newFeed();
+feed.setId("tag:example.org,2005:/myfeed");
 feed.setTitle("My Example Feed");
 // .. set other feed properties
 Document&lt;Feed&gt; doc = feed.getDocument();
@@ -107,8 +106,8 @@
     
     <h3>Creating Atom Entry Documents</h3>
 
-    <pre>Entry entry = Factory.INSTANCE.newEntry();
-entry.setId("tag:example.org,2005:/myentry", false);
+    <pre>Entry entry = factory.newEntry();
+entry.setId("tag:example.org,2005:/myentry");
 entry.setTitle("My Example Entry");
 // .. set other feed properties
 Document&lt;Entry&gt; doc = entry.getDocument();
@@ -123,7 +122,7 @@
     
     <pre>URI uri = ...
 InputStream inputStream = ...
-Document&lt;Feed&gt; doc = Parser.INSTANCE.parse(inputStream, uri);
+Document&lt;Feed&gt; doc = parser.parse(inputStream, uri);
 Feed feed = doc.getRoot();
 URI id = feed.getId();
 Text.Type titleType = feed.getTitleType();
@@ -144,31 +143,32 @@
     
     <pre>URI uri = ...
 InputStream inputStream = ...
-Document&lt;Feed&gt; doc = Parser.INSTANCE.parse(inputStream, uri);
+Document&lt;Feed&gt; doc = parser.parse(inputStream, uri);
 
 // Select the id of the document
-String id = XPath.INSTANCE.valueOf("/a:feed/a:id", doc);
+XPath xpath = abdera.getXPath();
+String id = xpath.valueOf("/a:feed/a:id", doc);
 
 // Select all entries from the document
-List entries = XPath.INSTANCE.valueOf("//a:entry", doc);
+List entries = xpath.valueOf("//a:entry", doc);
 for (Iterator i = entries.iterator(); i.hasNext();) {
   Entry entry = (Entry)i.next();
   //...
 }
 
 // Determine if a feed contains a specific extension
-boolean hasFoo = XPath.INSTANCE.isTrue("//x:foo", doc);
+boolean hasFoo = xpath.booleanValueOf("//x:foo", doc);
 
 // The XPath support works on any element in the FOM
-Entry entry = (Entry)XPath.INSTANCE.selectSingleNode("//a:entry", doc);
-String id = XPath.INSTANCE.valueOf("a:id", entry);</pre>
+Entry entry = (Entry)xpath.selectSingleNode("//a:entry", doc);
+String id = xpath.valueOf("a:id", entry);</pre>
     
     <h2>Using Extensions</h2>
     
     <p>The Feed Object Model is designed to fully and dynamically support 
     extensions to the Atom Feed format.</p>
     
-    <pre>Feed feed = Factory.INSTANCE.newFeed();
+    <pre>Feed feed = factory.newFeed();
 // ... set other feed properties
 feed.addSimpleExtension(
   new QName("urn:foo", "myExtension", "a"), 
@@ -206,10 +206,13 @@
     
     <h3>Digitally Signing Atom Documents</h3>
     
-    <pre>Feed feed = Factory.INSTANCE.newFeed();
+    <pre>Abdera abdera = new Abdera();
+AbderaSecurity absec = new AbderaSecurity(abdera);
+Factory factory = abdera.getFactory();
+Feed feed = factory.newFeed();
 PrivateKey myPrivateKey = ...
 X509Certificate myX509Cert = ...
-Signature sig = Signature.INSTANCE;
+Signature sig = absec.getSignature();
 SignatureOptions options = sig.getDefaultSignatureOptions();
 options.setSigningKey(myPrivateKey);
 options.setCertificate(myX509Cert);
@@ -218,10 +221,12 @@
 
     <h3>Encrypting Atom Documents</h3>
     
-    <pre>Feed feed = Factory.INSTANCE.newFeed();
+    <pre>Abdera abdera = new Abdera();
+AbderaSecurity absec = new AbderaSecurity(abdera);
+Feed feed = factory.newFeed();
 Key kek = ... // Key encryption key
 Key dek = ... // Data encryption key
-Encryption enc = Encryption.INSTANCE;
+Encryption enc = absec.getEncryption();
 EncryptionOptions options = enc.getDefaultEncryptionOptions();
 options.setKeyEncryptionKey(kek);
 options.setDataEncryptionKey(dek);