abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1226026 - in /abdera/abdera2: common/src/main/java/org/apache/abdera2/common/io/ core/src/main/java/org/apache/abdera2/parser/ core/src/main/java/org/apache/abdera2/parser/axiom/ core/src/main/java/org/apache/abdera2/protocol/client/ examp...
Date Sat, 31 Dec 2011 02:10:13 GMT
Author: jmsnell
Date: Sat Dec 31 02:10:12 2011
New Revision: 1226026

URL: http://svn.apache.org/viewvc?rev=1226026&view=rev
Log:
Noticed that everywhere the ParserOptions was actually being used, we were making defensive copies of it anyway to ward off the evil spirits of mutability... this goes ahead and makes ParserOptions immutable and threadsafe just like all the other similar things throughout Abdera2.

Removed:
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/AbstractParserOptions.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParserOptions.java
    abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/html/HtmlParserOptions.java
Modified:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/io/Compression.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/AbstractParser.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/Parser.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/ParserOptions.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMBuilder.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMElement.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParser.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClientResponseImpl.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/FeedToStreamConversionExample.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MapRedExample.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PrintTitles.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/UnacceptableElementsExample.java
    abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedParser.java
    abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/html/HtmlParser.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/EncodingTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/ParserTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/axiom/FOMTest.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/AbstractParserOptionsTest.java

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/io/Compression.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/io/Compression.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/io/Compression.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/io/Compression.java Sat Dec 31 02:10:12 2011
@@ -25,6 +25,8 @@ import java.util.zip.GZIPInputStream;
 import java.util.zip.GZIPOutputStream;
 import java.util.zip.InflaterInputStream;
 
+import com.google.common.collect.Iterables;
+
 import static org.apache.abdera2.common.text.CharUtils.splitAndTrim;
 import static com.google.common.base.Preconditions.*;
 
@@ -100,6 +102,13 @@ public class Compression {
 
     public static InputStream wrap(
       InputStream in, 
+      Iterable<CompressionCodec> codecs) 
+        throws IOException {
+      return wrap(in, Iterables.toArray(codecs, CompressionCodec.class));
+    }
+    
+    public static InputStream wrap(
+      InputStream in, 
       CompressionCodec... codecs)
       throws IOException {
       checkNotNull(in);

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/AbstractParser.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/AbstractParser.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/AbstractParser.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/AbstractParser.java Sat Dec 31 02:10:12 2011
@@ -122,38 +122,22 @@ public abstract class AbstractParser imp
     public <T extends Element> Document<T> parse(ReadableByteChannel buf) throws ParseException {
         return parse(buf, null, getDefaultParserOptions());
     }
+    
+    public ParserOptions.Builder makeDefaultParserOptions() {
+      return initDefaultParserOptions();
+    }
 
     public synchronized ParserOptions getDefaultParserOptions() {
-        if (options == null)
-            options = initDefaultParserOptions();
-
-        // Make a copy of the options, so that changes to it don't result in
-        // changes to the Parser's defaults. Also, this allows us to remain
-        // thread safe without having to make ParseOptions implementations
-        // synchronized.
-
-        try {
-            return (ParserOptions)options.clone();
-        } catch (CloneNotSupportedException cnse) {
-            // This shouldn't actually happen
-            throw new RuntimeException(cnse);
-        }
+      if (options == null)
+        options = initDefaultParserOptions().get();
+      return options;
     }
 
-    protected abstract ParserOptions initDefaultParserOptions();
+    protected abstract ParserOptions.Builder initDefaultParserOptions();
 
     public synchronized Parser setDefaultParserOptions(ParserOptions options) {
-        // Ok, we need to make a defensive copy of the options, since otherwise
-        // the caller still has access to the object, which means our access to
-        // it isn't certain to be thread safe.
-
-        try {
-            this.options = (options != null) ? (ParserOptions)options.clone() : initDefaultParserOptions();
-            return this;
-        } catch (CloneNotSupportedException cnse) {
-            // This shouldn't actually happen
-            throw new RuntimeException(cnse);
-        }
+      this.options = options;
+      return this;
     }
 
     public Iterable<String> getInputFormats() {

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/Parser.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/Parser.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/Parser.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/Parser.java Sat Dec 31 02:10:12 2011
@@ -195,6 +195,8 @@ public interface Parser {
      * @return The default ParserOptions
      */
     ParserOptions getDefaultParserOptions();
+    
+    ParserOptions.Builder makeDefaultParserOptions();
 
     /**
      * Set the default parser options for this Parser. This method copies the specified options.

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/ParserOptions.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/ParserOptions.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/ParserOptions.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/ParserOptions.java Sat Dec 31 02:10:12 2011
@@ -22,145 +22,552 @@ import java.util.Map;
 import javax.xml.namespace.QName;
 
 import org.apache.abdera2.common.io.Compression;
+import org.apache.abdera2.common.io.Compression.CompressionCodec;
 import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.parser.axiom.FOMFactory;
 import org.apache.abdera2.parser.filter.ParseFilter;
 
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
 /**
  * Parser options are used to modify the behavior of the parser.
  */
-public interface ParserOptions extends Cloneable {
-
-    Object clone() throws CloneNotSupportedException;
+public class ParserOptions {
 
+  public static Builder make() {
+    return new Builder();
+  }
+  
+  public static Builder from(ParserOptions options) {
+    Builder builder = new Builder();
+    builder.factory = options.factory;
+    builder.charset = options.charset;
+    builder.parseFilter = options.parseFilter;
+    builder.detect = options.detect;
+    builder.preserve = options.preserve;
+    builder.filterreserved = options.filterreserved;
+    builder.replacement = options.replacement;
+    builder.resolveentities = options.resolveentities;
+    builder.qnamealiasing = options.qnamealiasing;
+    builder.codecs.addAll(options.codecs);
+    builder.aliases.putAll(options.aliases);
+    builder.entities.putAll(options.entities);
+    builder.fragment = options.fragment;
+    return builder;
+  }
+  
+  public static class Builder 
+    implements Supplier<ParserOptions> {
+
+    protected Factory factory = null;
+    protected String charset = "UTF-8";
+    protected ParseFilter parseFilter = null;
+    protected boolean detect = false;
+    protected boolean preserve = true;
+    protected boolean filterreserved = false;
+    protected char replacement = 0;
+    protected boolean resolveentities = true;
+    protected boolean fragment = false;
+    
+    protected ImmutableSet.Builder<Compression.CompressionCodec> codecs = 
+      ImmutableSet.builder();
+    protected ImmutableMap.Builder<String,String> entities = 
+      ImmutableMap.builder();
+
+    protected boolean qnamealiasing = false;
+    protected ImmutableMap.Builder<QName, QName> aliases = 
+      ImmutableMap.builder();
+    
+    public Builder() {
+      initDefaultEntities();
+    }
+    
+    public Builder factory(Factory factory) {
+      this.factory = factory;
+      return this;
+    }
+    
+    public Builder charset(String charset) {
+      this.charset = charset;
+      return this;
+    }
+    
+    public Builder filter(ParseFilter filter) {
+      this.parseFilter = filter;
+      return this;
+    }
+    
+    public Builder autodetectCharset() {
+      this.detect = true;
+      return this;
+    }
+    
+    public Builder doNotAutodetectCharset() {
+      this.detect = false;
+      return this;
+    }
+    
+    public Builder preserveWhitespace() {
+      this.preserve = true;
+      return this;
+    }
+    
+    public Builder doNotPreserveWhitespace() {
+      this.preserve = false;
+      return this;
+    }
+    
+    public Builder filterRestrictedCharacters() {
+      this.filterreserved = true;
+      return this;
+    }
+    
+    public Builder doNotFilterRestrictedCharacters() {
+      this.filterreserved = false;
+      return this;
+    }
+    
+    public Builder filterRestrictedCharacterReplacement(char c) {
+      this.replacement = c;
+      return this;
+    }
+    
+    public Builder compression(CompressionCodec codec) {
+      this.codecs.add(codec);
+      return this;
+    }
+    
+    public Builder entity(String name, String value) {
+      this.entities.put(name,value);
+      return this;
+    }
+    
+    public Builder entities(Map<String,String> map) {
+      this.entities = ImmutableMap.<String,String>builder().putAll(map);
+      return this;
+    }
+    
+    public Builder qNameAliasMappingEnabled() {
+      this.qnamealiasing = true;
+      return this;
+    }
+    
+    public Builder qNameAliasMappingNotEnabled() {
+      this.qnamealiasing = false;
+      return this;
+    }
+    
+    public Builder alias(QName qname1, QName qname2) {
+      this.aliases.put(qname1,qname2);
+      return this;
+    }
+    
+    public Builder fragment() {
+      this.fragment = true;
+      return this;
+    }
+    
+    public ParserOptions get() {
+      return new ParserOptions(this);
+    }
+    
+    private void initDefaultEntities() {
+      entity("quot", "\"");
+      entity("amp", "\u0026");
+      entity("lt", "\u003C");
+      entity("gt", "\u003E");
+      entity("nbsp", " ");
+      entity("iexcl", "\u00A1");
+      entity("cent", "\u00A2");
+      entity("pound", "\u00A3");
+      entity("curren", "\u00A4");
+      entity("yen", "\u00A5");
+      entity("brvbar", "\u00A6");
+      entity("sect", "\u00A7");
+      entity("uml", "\u00A8");
+      entity("copy", "\u00A9");
+      entity("ordf", "\u00AA");
+      entity("laquo", "\u00AB");
+      entity("not", "\u00AC");
+      entity("shy", "\u00AD");
+      entity("reg", "\u00AE");
+      entity("macr", "\u00AF");
+      entity("deg", "\u00B0");
+      entity("plusmn", "\u00B1");
+      entity("sup2", "\u00B2");
+      entity("sup3", "\u00B3");
+      entity("acute", "\u00B4");
+      entity("micro", "\u00B5");
+      entity("para", "\u00B6");
+      entity("middot", "\u00B7");
+      entity("cedil", "\u00B8");
+      entity("sup1", "\u00B9");
+      entity("ordm", "\u00BA");
+      entity("raquo", "\u00BB");
+      entity("frac14", "\u00BC");
+      entity("frac12", "\u00BD");
+      entity("frac34", "\u00BE");
+      entity("iquest", "\u00BF");
+      entity("Agrave", "\u00C0");
+      entity("Aacute", "\u00C1");
+      entity("Acirc", "\u00C2");
+      entity("Atilde", "\u00C3");
+      entity("Auml", "\u00C4");
+      entity("Aring", "\u00C5");
+      entity("AElig", "\u00C6");
+      entity("Ccedil", "\u00C7");
+      entity("Egrave", "\u00C8");
+      entity("Eacute", "\u00C9");
+      entity("Ecirc", "\u00CA");
+      entity("Euml", "\u00CB");
+      entity("Igrave", "\u00CC");
+      entity("Iacute", "\u00CD");
+      entity("Icirc", "\u00CE");
+      entity("Iuml", "\u00CF");
+      entity("ETH", "\u00D0");
+      entity("Ntilde", "\u00D1");
+      entity("Ograve", "\u00D2");
+      entity("Oacute", "\u00D3");
+      entity("Ocirc", "\u00D4");
+      entity("Otilde", "\u00D5");
+      entity("Ouml", "\u00D6");
+      entity("times", "\u00D7");
+      entity("Oslash", "\u00D8");
+      entity("Ugrave", "\u00D9");
+      entity("Uacute", "\u00DA");
+      entity("Ucirc", "\u00DB");
+      entity("Uuml", "\u00DC");
+      entity("Yacute", "\u00DD");
+      entity("THORN", "\u00DE");
+      entity("szlig", "\u00DF");
+      entity("agrave", "\u00E0");
+      entity("aacute", "\u00E1");
+      entity("acirc", "\u00E2");
+      entity("atilde", "\u00E3");
+      entity("auml", "\u00E4");
+      entity("aring", "\u00E5");
+      entity("aelig", "\u00E6");
+      entity("ccedil", "\u00E7");
+      entity("egrave", "\u00E8");
+      entity("eacute", "\u00E9");
+      entity("ecirc", "\u00EA");
+      entity("euml", "\u00EB");
+      entity("igrave", "\u00EC");
+      entity("iacute", "\u00ED");
+      entity("icirc", "\u00EE");
+      entity("iuml", "\u00EF");
+      entity("eth", "\u00F0");
+      entity("ntilde", "\u00F1");
+      entity("ograve", "\u00F2");
+      entity("oacute", "\u00F3");
+      entity("ocirc", "\u00F4");
+      entity("otilde", "\u00F5");
+      entity("ouml", "\u00F6");
+      entity("divide", "\u00F7");
+      entity("oslash", "\u00F8");
+      entity("ugrave", "\u00F9");
+      entity("uacute", "\u00FA");
+      entity("ucirc", "\u00FB");
+      entity("uuml", "\u00FC");
+      entity("yacute", "\u00FD");
+      entity("thorn", "\u00FE");
+      entity("yuml", "\u00FF");
+      entity("OElig", "\u0152");
+      entity("oelig", "\u0153");
+      entity("Scaron", "\u0160");
+      entity("scaron", "\u0161");
+      entity("Yuml", "\u0178");
+      entity("fnof", "\u0192");
+      entity("circ", "\u02C6");
+      entity("tilde", "\u02DC");
+      entity("Alpha", "\u0391");
+      entity("Beta", "\u0392");
+      entity("Gamma", "\u0393");
+      entity("Delta", "\u0394");
+      entity("Epsilon", "\u0395");
+      entity("Zeta", "\u0396");
+      entity("Eta", "\u0397");
+      entity("Theta", "\u0398");
+      entity("Iota", "\u0399");
+      entity("Kappa", "\u039A");
+      entity("Lambda", "\u039B");
+      entity("Mu", "\u039C");
+      entity("Nu", "\u039D");
+      entity("Xi", "\u039E");
+      entity("Omicron", "\u039F");
+      entity("Pi", "\u03A0");
+      entity("Rho", "\u03A1");
+      entity("Sigma", "\u03A3");
+      entity("Tau", "\u03A4");
+      entity("Upsilon", "\u03A5");
+      entity("Phi", "\u03A6");
+      entity("Chi", "\u03A7");
+      entity("Psi", "\u03A8");
+      entity("Omega", "\u03A9");
+      entity("alpha", "\u03B1");
+      entity("beta", "\u03B2");
+      entity("gamma", "\u03B3");
+      entity("delta", "\u03B4");
+      entity("epsilon", "\u03B5");
+      entity("zeta", "\u03B6");
+      entity("eta", "\u03B7");
+      entity("theta", "\u03B8");
+      entity("iota", "\u03B9");
+      entity("kappa", "\u03BA");
+      entity("lambda", "\u03BB");
+      entity("mu", "\u03BC");
+      entity("nu", "\u03BD");
+      entity("xi", "\u03BE");
+      entity("omicron", "\u03BF");
+      entity("pi", "\u03C0");
+      entity("rho", "\u03C1");
+      entity("sigmaf", "\u03C2");
+      entity("sigma", "\u03C3");
+      entity("tau", "\u03C4");
+      entity("upsilon", "\u03C5");
+      entity("phi", "\u03C6");
+      entity("chi", "\u03C7");
+      entity("psi", "\u03C8");
+      entity("omega", "\u03C9");
+      entity("thetasym", "\u03D1");
+      entity("upsih", "\u03D2");
+      entity("piv", "\u03D6");
+      entity("ensp", "\u2002");
+      entity("emsp", "\u2003");
+      entity("thinsp", "\u2009");
+      entity("zwnj", "\u200C");
+      entity("zwj", "\u200D");
+      entity("lrm", "\u200E");
+      entity("rlm", "\u200F");
+      entity("ndash", "\u2013");
+      entity("mdash", "\u2014");
+      entity("lsquo", "\u2018");
+      entity("rsquo", "\u2019");
+      entity("sbquo", "\u201A");
+      entity("ldquo", "\u201C");
+      entity("rdquo", "\u201D");
+      entity("bdquo", "\u201E");
+      entity("dagger", "\u2020");
+      entity("Dagger", "\u2021");
+      entity("bull", "\u2022");
+      entity("hellip", "\u2026");
+      entity("permil", "\u2030");
+      entity("prime", "\u2032");
+      entity("Prime", "\u2033");
+      entity("lsaquo", "\u2039");
+      entity("rsaquo", "\u203A");
+      entity("oline", "\u203E");
+      entity("frasl", "\u2044");
+      entity("euro", "\u20AC");
+      entity("image", "\u2111");
+      entity("weierp", "\u2118");
+      entity("real", "\u211C");
+      entity("trade", "\u2122");
+      entity("alefsym", "\u2135");
+      entity("larr", "\u2190");
+      entity("uarr", "\u2191");
+      entity("rarr", "\u2192");
+      entity("darr", "\u2193");
+      entity("harr", "\u2194");
+      entity("crarr", "\u21B5");
+      entity("lArr", "\u21D0");
+      entity("uArr", "\u21D1");
+      entity("rArr", "\u21D2");
+      entity("dArr", "\u21D3");
+      entity("hArr", "\u21D4");
+      entity("forall", "\u2200");
+      entity("part", "\u2202");
+      entity("exist", "\u2203");
+      entity("empty", "\u2205");
+      entity("nabla", "\u2207");
+      entity("isin", "\u2208");
+      entity("notin", "\u2209");
+      entity("ni", "\u220B");
+      entity("prod", "\u220F");
+      entity("sum", "\u2211");
+      entity("minus", "\u2212");
+      entity("lowast", "\u2217");
+      entity("radic", "\u221A");
+      entity("prop", "\u221D");
+      entity("infin", "\u221E");
+      entity("ang", "\u2220");
+      entity("and", "\u2227");
+      entity("or", "\u2228");
+      entity("cap", "\u2229");
+      entity("cup", "\u222A");
+      entity("int", "\u222B");
+      entity("there4", "\u2234");
+      entity("sim", "\u223C");
+      entity("cong", "\u2245");
+      entity("asymp", "\u2248");
+      entity("ne", "\u2260");
+      entity("equiv", "\u2261");
+      entity("le", "\u2264");
+      entity("ge", "\u2265");
+      entity("sub", "\u2282");
+      entity("sup", "\u2283");
+      entity("nsub", "\u2284");
+      entity("sube", "\u2286");
+      entity("supe", "\u2287");
+      entity("oplus", "\u2295");
+      entity("otimes", "\u2297");
+      entity("perp", "\u22A5");
+      entity("sdot", "\u22C5");
+      entity("lceil", "\u2308");
+      entity("rceil", "\u2309");
+      entity("lfloor", "\u230A");
+      entity("rfloor", "\u230B");
+      entity("lang", "\u2329");
+      entity("rang", "\u232A");
+      entity("loz", "\u25CA");
+      entity("spades", "\u2660");
+      entity("clubs", "\u2663");
+      entity("hearts", "\u2665");
+      entity("diams", "\u2666");
+    }
+  }
+  
+  private final Factory factory;
+  private final String charset;
+  private final ParseFilter parseFilter;
+  private final boolean detect;
+  private final boolean preserve;
+  private final boolean filterreserved;
+  private final char replacement;
+  private final boolean resolveentities;
+  private final ImmutableSet<Compression.CompressionCodec> codecs;
+  private final ImmutableMap<String,String> entities;
+  private final boolean qnamealiasing;
+  private final ImmutableMap<QName, QName> aliases;
+  private final boolean fragment;
+
+  ParserOptions(Builder builder) {
+    this.factory = builder.factory != null ?
+      builder.factory : new FOMFactory();
+    this.charset = builder.charset;
+    this.parseFilter = builder.parseFilter;
+    this.detect = builder.detect;
+    this.preserve = builder.preserve;
+    this.filterreserved = builder.filterreserved;
+    this.replacement = builder.replacement;
+    this.resolveentities = builder.resolveentities;
+    this.codecs = builder.codecs.build();
+    this.entities = builder.entities.build();
+    this.qnamealiasing = builder.qnamealiasing;
+    this.aliases = builder.aliases.build();
+    this.fragment = builder.fragment;
+  }
+  
+  ParserOptions(ParserOptions options, String charset) {
+    this.factory = options.factory;
+    this.charset = charset;
+    this.parseFilter = options.parseFilter;
+    this.detect = options.detect;
+    this.preserve = options.preserve;
+    this.filterreserved = options.filterreserved;
+    this.replacement = options.replacement;
+    this.resolveentities = options.resolveentities;
+    this.codecs = options.codecs;
+    this.entities = options.entities;
+    this.qnamealiasing = options.qnamealiasing;
+    this.aliases = options.aliases; 
+    this.fragment = options.fragment;
+  }
+  
+   public ParserOptions usingCharset(String charset) {
+     return new ParserOptions(this,charset);
+   }
+  
     /**
      * Returns the factory the parser should use
      */
-    Factory getFactory();
-
-    /**
-     * Sets the factory the parser should use
-     */
-    ParserOptions setFactory(Factory factory);
+    public Factory getFactory() {
+      return factory;
+    }
 
     /**
      * Returns the default character set to use for the parsed document
      */
-    String getCharset();
-
-    /**
-     * Sets the character set to use for the parsed document
-     */
-    ParserOptions setCharset(String charset);
-
+    public String getCharset() {
+      return charset;
+    }
+    
     /**
      * Returns the Parse Filter. The parse filter is a set of XML QNames that the parse should watch out for. If the
      * filter is null, the parser will parse all elements in the document. I the filter is not null, the parser will
      * only pay attention to elements whose QName's appear in the filter list.
      */
-    ParseFilter getParseFilter();
-
-    /**
-     * Sets the Parse Filter. The parse filter is a set of XML QNames that the parse should watch out for. If the filter
-     * is null, the parser will parse all elements in the document. I the filter is not null, the parser will only pay
-     * attention to elements whose QName's appear in the filter list.
-     */
-    ParserOptions setParseFilter(ParseFilter parseFilter);
+    public ParseFilter getParseFilter() {
+      return parseFilter;
+    }
 
     /**
      * Returns true if the parser should attempt to automatically detect the character encoding from the stream
      */
-    boolean getAutodetectCharset();
-
-    /**
-     * If true, the parser will attempt to automatically detect the character encoding from the stream by checking for
-     * the byte order mark or checking the XML prolog.
-     */
-    ParserOptions setAutodetectCharset(boolean detect);
-
-    /**
-     * If false, the parser will trim leading and trailing whitespace in element and attribute values unless there is an
-     * in-scope xml:space="preserve".
-     */
-    boolean getMustPreserveWhitespace();
+    public boolean getAutodetectCharset() {
+      return detect;
+    }
 
     /**
      * If false, the parser will trim leading and trailing whitespace in element and attribute values unless there is an
      * in-scope xml:space="preserve".
      */
-    ParserOptions setMustPreserveWhitespace(boolean preserve);
+    public boolean getMustPreserveWhitespace() {
+      return preserve;
+    }
 
     /**
      * If true, the parser will attempt to silently filter out invalid XML characters appearing within the XML document.
      */
-    boolean getFilterRestrictedCharacters();
-
-    /**
-     * If true, the parser will attempt to silently filter out invalid XML characters appearing within the XML document
-     */
-    ParserOptions setFilterRestrictedCharacters(boolean filter);
+    public boolean getFilterRestrictedCharacters() {
+      return this.filterreserved;
+    }
 
     /**
      * If getFilterRestrictedCharacters is true, restricted characters will be replaced with the specified character
      */
-    char getFilterRestrictedCharacterReplacement();
-
-    /**
-     * If getFilterRestrictedCharacters is true, restricted characters will be replaced with the specified character
-     */
-    ParserOptions setFilterRestrictedCharacterReplacement(char replacement);
-
-    /**
-     * When parsing an InputStream that contains compressed data, use these codecs to decompress the stream. Only used
-     * when parsing an InputStream. Ignored when parsing a Reader
-     */
-    Compression.CompressionCodec[] getCompressionCodecs();
+    public char getFilterRestrictedCharacterReplacement() {
+      return this.replacement;
+    }
 
     /**
      * When parsing an InputStream that contains compressed data, use these codecs to decompress the stream. Only used
      * when parsing an InputStream. Ignored when parsing a Reader
      */
-    ParserOptions setCompressionCodecs(Compression.CompressionCodec... codecs);
-
-    /**
-     * Register a named entity. This provides an escape clause for when feeds use entities that are not supported in XML
-     * without a DTD decl. By default, all of the (X)HTML entities are preregistered
-     */
-    ParserOptions registerEntity(String name, String value);
+    public Iterable<Compression.CompressionCodec> getCompressionCodecs() {
+      return codecs;
+    }
 
     /**
      * Resolves a value for a named entity. This provides an escape clause for when feeds use entities that are not
      * supported in XML without a DTD decl. By default, all of the (X)HTML entities are preregistered
      */
-    String resolveEntity(String name);
-
-    /**
-     * True if undeclared named entities should be resolved.
-     */
-    ParserOptions setResolveEntities(boolean resolve);
+    public String resolveEntity(String name) {
+      return entities.get(name);
+    }
 
     /**
      * True if undeclared named entities should be resolved.
      */
-    boolean getResolveEntities();
-
-    /**
-     * True if QName-Alias mapping is enabled
-     */
-    ParserOptions setQNameAliasMappingEnabled(boolean enabled);
+    public boolean getResolveEntities() {
+      return this.resolveentities;
+    }
 
     /**
      * True if QName-Alias mapping is enabled (default is false)
      */
-    boolean isQNameAliasMappingEnabled();
-
-    /**
-     * Get the QName-Alias Mapping (default null)
-     */
-    Map<QName, QName> getQNameAliasMap();
-
-    /**
-     * Set the QName-Alias Mapping
-     */
-    ParserOptions setQNameAliasMap(Map<QName, QName> map);
-
+    public boolean isQNameAliasMappingEnabled() {
+      return this.qnamealiasing;
+    }
+    
+    public QName getAlias(QName qname) {
+      return aliases.containsKey(qname) ? 
+        aliases.get(qname) : qname;
+    }
+
+    public boolean isFragment() {
+      return fragment;
+    }
 }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMBuilder.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMBuilder.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMBuilder.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMBuilder.java Sat Dec 31 02:10:12 2011
@@ -17,8 +17,6 @@
  */
 package org.apache.abdera2.parser.axiom;
 
-import java.util.Map;
-
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
@@ -247,11 +245,7 @@ public class FOMBuilder extends StAXOMBu
     }
 
     private QName getAlias(QName qname) {
-        Map<QName, QName> map = parserOptions.getQNameAliasMap();
-        if (map == null)
-            return qname;
-        QName alias = map.get(qname);
-        return alias != null ? alias : qname;
+      return parserOptions.getAlias(qname);
     }
 
     protected OMElement constructNode(OMContainer parent, String name) {

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMElement.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMElement.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMElement.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMElement.java Sat Dec 31 02:10:12 2011
@@ -530,9 +530,11 @@ public class FOMElement extends OMElemen
         charset = charset != null ? charset : "UTF-8";
         ByteArrayInputStream bais =
             new ByteArrayInputStream(value.getBytes(charset));
-        ParserOptions options = parser.getDefaultParserOptions();
-        options.setCharset(getXMLStreamReader().getCharacterEncodingScheme());
-        options.setFactory(fomfactory);
+        ParserOptions options = 
+          parser.makeDefaultParserOptions()
+           .charset(getXMLStreamReader().getCharacterEncodingScheme())
+           .factory(fomfactory)
+           .get();
         Document<?> doc = parser.parse(bais, (baseUri != null) ? baseUri.toString() : null, options);
         return doc.getRoot();
     }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParser.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParser.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParser.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMParser.java Sat Dec 31 02:10:12 2011
@@ -81,12 +81,12 @@ public class FOMParser extends AbstractP
         throws ParseException {
         Document<T> document = builder.getFomDocument();
         try {
-            if (base != null)
-                document.setBaseUri(base.toString());
-            if (options != null && options.getCharset() != null)
-                document.setCharset(options.getCharset());
-            if (options != null)
-                document.setMustPreserveWhitespace(options.getMustPreserveWhitespace());
+          if (base != null)
+              document.setBaseUri(base.toString());
+          if (options != null && options.getCharset() != null)
+              document.setCharset(options.getCharset());
+          if (options != null)
+              document.setMustPreserveWhitespace(options.getMustPreserveWhitespace());
         } catch (Exception e) {
             if (!(e instanceof ParseException))
                 e = new ParseException(e);
@@ -101,18 +101,18 @@ public class FOMParser extends AbstractP
             throw new IllegalArgumentException(Localizer.get("INPUTSTREAM.NOT.NULL"));
         try {
             if (options == null)
-                options = getDefaultParserOptions();
-            if (options.getCompressionCodecs() != null) {
-                in = Compression.wrap(in, options.getCompressionCodecs());
-            }
+              options = getDefaultParserOptions();
+            if (options.getCompressionCodecs() != null)
+              in = Compression.wrap(in, options.getCompressionCodecs());
             String charset = options.getCharset();
             if (charset == null && options.getAutodetectCharset()) {
                 XMLStreamSniffingInputStream sin =
-                    (in instanceof XMLStreamSniffingInputStream) ? (XMLStreamSniffingInputStream)in
-                        : new XMLStreamSniffingInputStream(in);
+                    (in instanceof XMLStreamSniffingInputStream) ? 
+                      (XMLStreamSniffingInputStream)in : 
+                      new XMLStreamSniffingInputStream(in);
                 charset = sin.getEncoding();
                 if (charset != null)
-                    options.setCharset(charset);
+                  options = options.usingCharset(charset);
                 in = sin;
             }
             if (options.getFilterRestrictedCharacters()) {
@@ -184,8 +184,8 @@ public class FOMParser extends AbstractP
     }
 
     @Override
-    protected ParserOptions initDefaultParserOptions() {
-        return new FOMParserOptions(getFactory());
+    protected ParserOptions.Builder initDefaultParserOptions() {
+        return ParserOptions.make().factory(getFactory());
     }
 
 }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClientResponseImpl.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClientResponseImpl.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClientResponseImpl.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/protocol/client/AbderaClientResponseImpl.java Sat Dec 31 02:10:12 2011
@@ -54,15 +54,16 @@ class AbderaClientResponseImpl 
       return getDocument(parser,null);
   }
 
-  public <T extends Element> Document<T> getDocument(Parser parser,
-      ParserOptions options) throws ParseException {
+  public <T extends Element> Document<T> getDocument(
+    Parser parser,
+    ParserOptions options) throws ParseException {
     try {
       if (options == null) 
       options = parser.getDefaultParserOptions();
       
       String charset = getCharacterEncoding();
       if (charset != null)
-          options.setCharset(charset);
+        options = options.usingCharset(charset);
       IRI cl = getContentLocation();
       if (cl != null && !cl.isAbsolute()) {
           IRI r = new IRI(getUri());

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/FeedToStreamConversionExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/FeedToStreamConversionExample.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/FeedToStreamConversionExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/FeedToStreamConversionExample.java Sat Dec 31 02:10:12 2011
@@ -20,8 +20,8 @@ public class FeedToStreamConversionExamp
     Abdera abdera = Abdera.getInstance();
     URL url = new URL("http://intertwingly.net/blog/index.atom");
     Parser parser = abdera.getParser();
-    ParserOptions options = parser.getDefaultParserOptions();
-    options.setCharset("UTF-8");
+    ParserOptions options = 
+      parser.makeDefaultParserOptions().charset("UTF-8").get();
     Document<Feed> doc = abdera.getParser().parse(url.openStream(),url.toString(),options);
     Feed feed = doc.getRoot();    
     feed.writeTo("activity", System.out);

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MapRedExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MapRedExample.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MapRedExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/activities/MapRedExample.java Sat Dec 31 02:10:12 2011
@@ -92,8 +92,8 @@ public class MapRedExample {
     Abdera abdera = Abdera.getInstance();
     URL url = new URL("http://planet.intertwingly.net/atom.xml");
     Parser parser = abdera.getParser();
-    ParserOptions options = parser.getDefaultParserOptions();
-    options.setCharset("UTF-8");
+    ParserOptions options = 
+      parser.makeDefaultParserOptions().charset("UTF-8").get();
     Document<Feed> doc = abdera.getParser().parse(url.openStream(),url.toString(),options);
     Feed feed = doc.getRoot();    
     ByteArrayOutputStream out = new ByteArrayOutputStream();

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PrintTitles.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PrintTitles.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PrintTitles.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PrintTitles.java Sat Dec 31 02:10:12 2011
@@ -26,7 +26,6 @@ import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.parser.Parser;
 import org.apache.abdera2.parser.ParserOptions;
-import org.apache.abdera2.parser.filter.ParseFilter;
 import org.apache.abdera2.parser.filter.WhiteListParseFilter;
 import org.apache.abdera2.common.Constants;
 
@@ -43,16 +42,15 @@ public class PrintTitles {
 
         InputStream in = Parse.class.getResourceAsStream("/simple.xml");
 
-        ParserOptions opts = parser.getDefaultParserOptions();
-
-        ParseFilter filter = 
-          WhiteListParseFilter
-            .make()
-            .add(Constants.FEED)
-            .add(Constants.ENTRY)
-            .add(Constants.TITLE)
-            .get();
-        opts.setParseFilter(filter);
+        ParserOptions opts = 
+          parser.makeDefaultParserOptions()
+            .filter(
+              WhiteListParseFilter
+                .make()
+                .add(Constants.FEED)
+                .add(Constants.ENTRY)
+                .add(Constants.TITLE)
+                .get()).get();
 
         Document<Feed> doc;
 

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/UnacceptableElementsExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/UnacceptableElementsExample.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/UnacceptableElementsExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/UnacceptableElementsExample.java Sat Dec 31 02:10:12 2011
@@ -25,23 +25,21 @@ import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.parser.Parser;
 import org.apache.abdera2.parser.ParserOptions;
 import org.apache.abdera2.parser.filter.BlackListParseFilter;
-import org.apache.abdera2.parser.filter.ParseFilter;
 
 public class UnacceptableElementsExample {
 
     public static void main(String[] args) throws Exception {
 
         Parser parser = Abdera.getInstance().getParser();
-
-        ParseFilter exceptionFilter =
-          BlackListParseFilter
+        ParserOptions options = 
+          parser.makeDefaultParserOptions()
+            .filter(BlackListParseFilter
             .make()
             .add(new QName("http://example.org", "a"))
             .throwOnUnacceptable()
+            .get())
             .get();
         
-        ParserOptions options = parser.getDefaultParserOptions();
-        options.setParseFilter(exceptionFilter);
         Document<Feed> doc =
             parser.parse(
               UnacceptableElementsExample.class.getResourceAsStream("/xmlcontent.xml"), 

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedParser.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedParser.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedParser.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/activities/ActivityToFeedParser.java Sat Dec 31 02:10:12 2011
@@ -12,11 +12,9 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.Collection;
 import org.apache.abdera2.activities.model.IO;
 import org.apache.abdera2.common.anno.Name;
-import org.apache.abdera2.factory.Factory;
 import org.apache.abdera2.model.Document;
 import org.apache.abdera2.model.Element;
 import org.apache.abdera2.parser.AbstractParser;
-import org.apache.abdera2.parser.AbstractParserOptions;
 import org.apache.abdera2.parser.ParseException;
 import org.apache.abdera2.parser.ParserOptions;
 import org.apache.abdera2.writer.StreamWriter;
@@ -40,11 +38,8 @@ public class ActivityToFeedParser 
     io = IO.get();
   }
 
-  protected ParserOptions initDefaultParserOptions() {
-    return new AbstractParserOptions() {
-      protected void initFactory() {}
-      protected void checkFactory(Factory factory) {}
-    };
+  protected ParserOptions.Builder initDefaultParserOptions() {
+    return ParserOptions.make();
   }
   
   @SuppressWarnings("unchecked")

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/html/HtmlParser.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/html/HtmlParser.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/html/HtmlParser.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/html/HtmlParser.java Sat Dec 31 02:10:12 2011
@@ -29,6 +29,7 @@ import org.apache.abdera2.model.Element;
 import org.apache.abdera2.parser.AbstractParser;
 import org.apache.abdera2.parser.ParseException;
 import org.apache.abdera2.parser.ParserOptions;
+import org.apache.abdera2.parser.ParserOptions.Builder;
 
 @Name("html")
 public class HtmlParser extends AbstractParser {
@@ -42,13 +43,13 @@ public class HtmlParser extends Abstract
     }
 
     @Override
-    protected ParserOptions initDefaultParserOptions() {
-        return new HtmlParserOptions();
+    protected Builder initDefaultParserOptions() {
+        return ParserOptions.make();
     }
 
     @SuppressWarnings("unchecked")
     public <T extends Element> Document<T> parse(Reader in, String base, ParserOptions options) throws ParseException {
-        boolean fragment = options instanceof HtmlParserOptions ? ((HtmlParserOptions)options).isHtmlFragment() : false;
+        boolean fragment = options.isFragment();
         Document<T> doc = null;
         if (fragment) {
             Div div = HtmlHelper.parse(abdera, in);

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java Sat Dec 31 02:10:12 2011
@@ -228,8 +228,9 @@ public class AppTest {
                             MimeType type = new MimeType(request.getContentType());
                             String charset = type.getParameter("charset");
                             String uri = AppTest.INSTANCE.getBase() + "/collections/entries";
-                            ParserOptions options = getParser().getDefaultParserOptions();
-                            options.setCharset(charset);
+                            ParserOptions options = 
+                              getParser().makeDefaultParserOptions()
+                               .charset(charset).get();
                             Document<?> doc = getParser().parse(request.getInputStream(), uri, options);
                             if (doc.getRoot() instanceof Entry) {
                                 Entry entry = (Entry)doc.getRoot().clone();
@@ -297,8 +298,9 @@ public class AppTest {
                             MimeType type = new MimeType(request.getContentType());
                             String charset = type.getParameter("charset");
                             String uri = AppTest.INSTANCE.getBase() + "/collections/entries/" + target;
-                            ParserOptions options = getParser().getDefaultParserOptions();
-                            options.setCharset(charset);
+                            ParserOptions options = 
+                              getParser().makeDefaultParserOptions()
+                                .charset(charset).get();
                             Document<?> doc = getParser().parse(request.getInputStream(), uri, options);
                             if (doc.getRoot() instanceof Entry) {
                                 Entry newentry = (Entry)doc.getRoot().clone();

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/EncodingTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/EncodingTest.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/EncodingTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/EncodingTest.java Sat Dec 31 02:10:12 2011
@@ -70,8 +70,9 @@ public class EncodingTest {
         byte[] bytes = out.toByteArray();
         ByteArrayInputStream in = new ByteArrayInputStream(bytes);
         Parser parser = abdera.getParser();
-        ParserOptions options = parser.getDefaultParserOptions();
-        options.setCompressionCodecs(CompressionCodec.GZIP);
+        ParserOptions options = 
+          parser.makeDefaultParserOptions()
+            .compression(CompressionCodec.GZIP).get();
         Document<Entry> doc = abdera.getParser().parse(in, null, options);
         entry = doc.getRoot();
     }
@@ -84,8 +85,9 @@ public class EncodingTest {
         String s = "<?xml version='1.1'?><t t='\u007f' />";
         Abdera abdera = Abdera.getInstance();
         Parser parser = abdera.getParser();
-        ParserOptions options = parser.getDefaultParserOptions();
-        options.setFilterRestrictedCharacters(true);
+        ParserOptions options = 
+          parser.makeDefaultParserOptions()
+           .filterRestrictedCharacters().get();
         Document<Element> doc = parser.parse(new StringReader(s), null, options);
         doc.getRoot().toString();
     }
@@ -98,9 +100,10 @@ public class EncodingTest {
         String s = "<?xml version='1.0'?><t t='\u0002' />";
         Abdera abdera = Abdera.getInstance();
         Parser parser = abdera.getParser();
-        ParserOptions options = parser.getDefaultParserOptions();
-        options.setFilterRestrictedCharacters(true);
-        options.setCharset("UTF-8");
+        ParserOptions options = 
+          parser.makeDefaultParserOptions()
+           .charset("UTF-8")
+           .filterRestrictedCharacters().get();
         Document<Element> doc = parser.parse(new ByteArrayInputStream(s.getBytes("UTF-8")), null, options);
         doc.getRoot().toString();
     }
@@ -126,8 +129,9 @@ public class EncodingTest {
 
         ByteArrayInputStream in = new ByteArrayInputStream(bytes);
         Parser parser = abdera.getParser();
-        ParserOptions options = parser.getDefaultParserOptions();
-        options.setCompressionCodecs(CompressionCodec.DEFLATE);
+        ParserOptions options = 
+          parser.makeDefaultParserOptions()
+            .compression(CompressionCodec.DEFLATE).get();
         Document<Entry> doc = abdera.getParser().parse(in, null, options);
 
         doc.getRoot().toString();

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/ParserTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/ParserTest.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/ParserTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/ParserTest.java Sat Dec 31 02:10:12 2011
@@ -24,8 +24,9 @@ public class ParserTest {
     Abdera abdera = Abdera.getInstance();
     Parser parser = abdera.getParser();
     assertNotNull(parser);
-    ParserOptions options = parser.getDefaultParserOptions();
-    options.setFilterRestrictedCharacters(true);// invalid xml char will be filtered 
+    ParserOptions options = 
+      parser.makeDefaultParserOptions()
+       .filterRestrictedCharacters().get();// invalid xml char will be filtered 
     assertNotNull(options);
     Document<Element> doc = parser.parse(new StringReader(s),options);
     assertNotNull(doc);
@@ -42,7 +43,10 @@ public class ParserTest {
         .make()
         .add(new QName("b"))
         .get();
-    options.setParseFilter(filter);
+    options = ParserOptions
+      .from(options)
+      .filter(filter)
+      .get();
     
     doc = parser.parse(new StringReader(s),options);
     root = doc.getRoot();

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/axiom/FOMTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/axiom/FOMTest.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/axiom/FOMTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/parser/axiom/FOMTest.java Sat Dec 31 02:10:12 2011
@@ -180,8 +180,9 @@ public class FOMTest {
             .add(Constants.TITLE)
             .add(Constants.ID)
             .get();
-        ParserOptions options = getParser().getDefaultParserOptions();
-        options.setParseFilter(filter);
+        ParserOptions options = 
+          getParser().makeDefaultParserOptions()
+            .filter(filter).get();
 
         URL url = FOMTest.class.getResource("/simple.xml");
         InputStream in = url.openStream();
@@ -215,8 +216,9 @@ public class FOMTest {
             .make()
             .add(Constants.UPDATED)
             .get();
-        ParserOptions options = getParser().getDefaultParserOptions();
-        options.setParseFilter(filter);
+        ParserOptions options = 
+          getParser().makeDefaultParserOptions()
+            .filter(filter).get();
 
         URL url = FOMTest.class.getResource("/simple.xml");
         InputStream in = url.openStream();

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/AbstractParserOptionsTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/AbstractParserOptionsTest.java?rev=1226026&r1=1226025&r2=1226026&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/AbstractParserOptionsTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/util/AbstractParserOptionsTest.java Sat Dec 31 02:10:12 2011
@@ -19,26 +19,14 @@ package org.apache.abdera2.test.util;
 
 import static org.junit.Assert.assertEquals;
 
-import org.apache.abdera2.factory.Factory;
-import org.apache.abdera2.parser.AbstractParserOptions;
+import org.apache.abdera2.parser.ParserOptions;
 import org.junit.Test;
 
 public class AbstractParserOptionsTest {
 
-    private static final class TestParserOptions extends AbstractParserOptions {
-
-        @Override
-        protected void checkFactory(Factory factory) {
-        }
-
-        @Override
-        protected void initFactory() {
-        }
-    }
-
     @Test
     public void checkAllEntities() throws Exception {
-        TestParserOptions fomParserOptions = new TestParserOptions();
+        ParserOptions fomParserOptions = ParserOptions.make().get();
 
         assertEquals("00A1", getHexValue("iexcl", fomParserOptions));
         assertEquals("00A2", getHexValue("cent", fomParserOptions));
@@ -291,7 +279,7 @@ public class AbstractParserOptionsTest {
         assertEquals("20AC", getHexValue("euro", fomParserOptions));
     }
 
-    private String getHexValue(String entity, AbstractParserOptions fomParserOptions) {
+    private String getHexValue(String entity, ParserOptions fomParserOptions) {
         String hexValue = fomParserOptions.resolveEntity(entity);
         char hexChar = hexValue.charAt(0);
         StringBuilder result = new StringBuilder(Integer.toHexString(hexChar));



Mime
View raw message