juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject [28/34] incubator-juneau git commit: Add builder classes for all serializers and parsers.
Date Fri, 10 Mar 2017 16:51:24 GMT
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java
index c8f40d3..e0b6012 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java
@@ -21,7 +21,6 @@ import java.util.*;
 
 import org.apache.juneau.*;
 import org.apache.juneau.annotation.*;
-import org.apache.juneau.serializer.*;
 import org.apache.juneau.testbeans.*;
 import org.junit.*;
 
@@ -34,17 +33,17 @@ public class Common_UrlEncodingTest {
 	//====================================================================================================
 	@Test
 	public void testTrimNullsFromBeans() throws Exception {
-		UrlEncodingSerializer s = new UrlEncodingSerializer();
+		UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder();
 		A t1 = A.create(), t2;
 
-		s.setTrimNullProperties(false);
-		String r = s.serialize(t1);
+		s.trimNullProperties(false);
+		String r = s.build().serialize(t1);
 		assertEquals("s1=null&s2=s2", r);
 		t2 = p.parse(r, A.class);
 		assertEqualObjects(t1, t2);
 
-		s.setTrimNullProperties(true);
-		r = s.serialize(t1);
+		s.trimNullProperties(true);
+		r = s.build().serialize(t1);
 		assertEquals("s2=s2", r);
 		t2 = p.parse(r, A.class);
 		assertEqualObjects(t1, t2);
@@ -65,18 +64,18 @@ public class Common_UrlEncodingTest {
 	//====================================================================================================
 	@Test
 	public void testTrimEmptyMaps() throws Exception {
-		UrlEncodingSerializer s = UrlEncodingSerializer.DEFAULT.clone();
+		UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder();
 		B t1 = B.create(), t2;
 		String r;
 
-		s.setTrimEmptyMaps(false);
-		r = s.serialize(t1);
+		s.trimEmptyMaps(false);
+		r = s.build().serialize(t1);
 		assertEquals("f1=()&f2=(f2a=null,f2b=(s2=s2))", r);
 		t2 = p.parse(r, B.class);
 		assertEqualObjects(t1, t2);
 
-		s.setTrimEmptyMaps(true);
-		r = s.serialize(t1);
+		s.trimEmptyMaps(true);
+		r = s.build().serialize(t1);
 		assertEquals("f2=(f2a=null,f2b=(s2=s2))", r);
 		t2 = p.parse(r, B.class);
 		assertNull(t2.f1);
@@ -98,18 +97,18 @@ public class Common_UrlEncodingTest {
 	//====================================================================================================
 	@Test
 	public void testTrimEmptyLists() throws Exception {
-		UrlEncodingSerializer s = new UrlEncodingSerializer();
+		UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder();
 		C t1 = C.create(), t2;
 		String r;
 
-		s.setTrimEmptyCollections(false);
-		r = s.serialize(t1);
+		s.trimEmptyCollections(false);
+		r = s.build().serialize(t1);
 		assertEquals("f1=@()&f2=@(null,(s2=s2))", r);
 		t2 = p.parse(r, C.class);
 		assertEqualObjects(t1, t2);
 
-		s.setTrimEmptyCollections(true);
-		r = s.serialize(t1);
+		s.trimEmptyCollections(true);
+		r = s.build().serialize(t1);
 		assertEquals("f2=@(null,(s2=s2))", r);
 		t2 = p.parse(r, C.class);
 		assertNull(t2.f1);
@@ -131,18 +130,18 @@ public class Common_UrlEncodingTest {
 	//====================================================================================================
 	@Test
 	public void testTrimEmptyArrays() throws Exception {
-		UrlEncodingSerializer s = new UrlEncodingSerializer();
+		UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder();
 		D t1 = D.create(), t2;
 		String r;
 
-		s.setTrimEmptyCollections(false);
-		r = s.serialize(t1);
+		s.trimEmptyCollections(false);
+		r = s.build().serialize(t1);
 		assertEquals("f1=@()&f2=@(null,(s2=s2))", r);
 		t2 = p.parse(r, D.class);
 		assertEqualObjects(t1, t2);
 
-		s.setTrimEmptyCollections(true);
-		r = s.serialize(t1);
+		s.trimEmptyCollections(true);
+		r = s.build().serialize(t1);
 		assertEquals("f2=@(null,(s2=s2))", r);
 		t2 = p.parse(r, D.class);
 		assertNull(t2.f1);
@@ -242,13 +241,13 @@ public class Common_UrlEncodingTest {
 	//====================================================================================================
 	@Test
 	public void testUris() throws Exception {
-		WriterSerializer s = new UrlEncodingSerializer();
+		UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder();
 		TestURI t = new TestURI();
 		String r;
 		String expected = "";
 
-		s.setRelativeUriBase(null);
-		r = s.serialize(t);
+		s.relativeUriBase(null);
+		r = s.build().serialize(t);
 		expected = ""
 			+"f0=f0/x0"
 			+"&f1=f1/x1"
@@ -267,12 +266,12 @@ public class Common_UrlEncodingTest {
 			+"&fe='http://www.apache.org/fe/xe?foo=bar%26label2=MY_LABEL'";
 		assertEquals(expected, r);
 
-		s.setRelativeUriBase("");  // Same as null.
-		r = s.serialize(t);
+		s.relativeUriBase("");  // Same as null.
+		r = s.build().serialize(t);
 		assertEquals(expected, r);
 
-		s.setRelativeUriBase("/cr");
-		r = s.serialize(t);
+		s.relativeUriBase("/cr");
+		r = s.build().serialize(t);
 		expected = ""
 			+"f0=/cr/f0/x0"
 			+"&f1=/cr/f1/x1"
@@ -291,12 +290,12 @@ public class Common_UrlEncodingTest {
 			+"&fe='http://www.apache.org/fe/xe?foo=bar%26label2=MY_LABEL'";
 		assertEquals(expected, r);
 
-		s.setRelativeUriBase("/cr/");  // Same as above
-		r = s.serialize(t);
+		s.relativeUriBase("/cr/");  // Same as above
+		r = s.build().serialize(t);
 		assertEquals(expected, r);
 
-		s.setRelativeUriBase("/");
-		r = s.serialize(t);
+		s.relativeUriBase("/");
+		r = s.build().serialize(t);
 		expected = ""
 			+"f0=/f0/x0"
 			+"&f1=/f1/x1"
@@ -315,10 +314,10 @@ public class Common_UrlEncodingTest {
 			+"&fe='http://www.apache.org/fe/xe?foo=bar%26label2=MY_LABEL'";
 		assertEquals(expected, r);
 
-		s.setRelativeUriBase(null);
+		s.relativeUriBase(null);
 
-		s.setAbsolutePathUriBase("http://foo");
-		r = s.serialize(t);
+		s.absolutePathUriBase("http://foo");
+		r = s.build().serialize(t);
 		expected = ""
 			+"f0=f0/x0"
 			+"&f1=f1/x1"
@@ -337,12 +336,12 @@ public class Common_UrlEncodingTest {
 			+"&fe='http://www.apache.org/fe/xe?foo=bar%26label2=MY_LABEL'";
 		assertEquals(expected, r);
 
-		s.setAbsolutePathUriBase("http://foo/");
-		r = s.serialize(t);
+		s.absolutePathUriBase("http://foo/");
+		r = s.build().serialize(t);
 		assertEquals(expected, r);
 
-		s.setAbsolutePathUriBase("");  // Same as null.
-		r = s.serialize(t);
+		s.absolutePathUriBase("");  // Same as null.
+		r = s.build().serialize(t);
 		expected = ""
 			+"f0=f0/x0"
 			+"&f1=f1/x1"
@@ -363,31 +362,11 @@ public class Common_UrlEncodingTest {
 	}
 
 	//====================================================================================================
-	// Validate that you cannot update properties on locked serializer.
-	//====================================================================================================
-	@Test
-	public void testLockedSerializer() throws Exception {
-		UrlEncodingSerializer s = new UrlEncodingSerializer().lock();
-		try {
-			s.setUseWhitespace(true);
-			fail("Locked exception not thrown");
-		} catch (LockedException e) {}
-		try {
-			s.setAddBeanTypeProperties(true);
-			fail("Locked exception not thrown");
-		} catch (LockedException e) {}
-		try {
-			s.setBeanMapPutReturnsOldValue(true);
-			fail("Locked exception not thrown");
-		} catch (LockedException e) {}
-	}
-
-	//====================================================================================================
 	// Recursion
 	//====================================================================================================
 	@Test
 	public void testRecursion() throws Exception {
-		WriterSerializer s = new UrlEncodingSerializer();
+		UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder();
 
 		R1 r1 = new R1();
 		R2 r2 = new R2();
@@ -398,7 +377,7 @@ public class Common_UrlEncodingTest {
 
 		// No recursion detection
 		try {
-			s.serialize(r1);
+			s.build().serialize(r1);
 			fail("Exception expected!");
 		} catch (Exception e) {
 			String msg = e.getLocalizedMessage();
@@ -406,9 +385,9 @@ public class Common_UrlEncodingTest {
 		}
 
 		// Recursion detection, no ignore
-		s.setDetectRecursions(true);
+		s.detectRecursions(true);
 		try {
-			s.serialize(r1);
+			s.build().serialize(r1);
 			fail("Exception expected!");
 		} catch (Exception e) {
 			String msg = e.getLocalizedMessage();
@@ -418,8 +397,8 @@ public class Common_UrlEncodingTest {
 			assertTrue(msg.contains("->[3]r1:org.apache.juneau.urlencoding.Common_UrlEncodingTest$R1"));
 		}
 
-		s.setIgnoreRecursions(true);
-		assertEquals("name=foo&r2=(name=bar,r3=(name=baz))", s.serialize(r1));
+		s.ignoreRecursions(true);
+		assertEquals("name=foo&r2=(name=bar,r3=(name=baz))", s.build().serialize(r1));
 	}
 
 	public static class R1 {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonParserReaderTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonParserReaderTest.java b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonParserReaderTest.java
index ee37cb0..32833b9 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonParserReaderTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonParserReaderTest.java
@@ -17,6 +17,7 @@ import static org.junit.Assert.*;
 import java.io.*;
 
 import org.apache.juneau.*;
+import org.apache.juneau.uon.*;
 import org.junit.*;
 
 @SuppressWarnings({"javadoc","resource"})

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonParserTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonParserTest.java b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonParserTest.java
index de54711..87b46e1 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonParserTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonParserTest.java
@@ -17,6 +17,7 @@ import static org.junit.Assert.*;
 import java.util.*;
 
 import org.apache.juneau.parser.*;
+import org.apache.juneau.uon.*;
 import org.junit.*;
 
 @SuppressWarnings({"rawtypes","javadoc"})

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonSerializerTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonSerializerTest.java b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonSerializerTest.java
index 4c6d001..bf3bc75 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonSerializerTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UonSerializerTest.java
@@ -15,6 +15,7 @@ package org.apache.juneau.urlencoding;
 import static org.junit.Assert.*;
 
 import org.apache.juneau.*;
+import org.apache.juneau.uon.*;
 import org.junit.*;
 
 @SuppressWarnings("javadoc")

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingParserTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingParserTest.java b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingParserTest.java
index 753d585..474c467 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingParserTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingParserTest.java
@@ -850,7 +850,7 @@ public class UrlEncodingParserTest {
 		UrlEncodingParser p;
 		String in;
 
-		p = UrlEncodingParser.DEFAULT.clone().setExpandedParams(true);
+		p = new UrlEncodingParserBuilder().expandedParams(true).build();
 		in = ""
 			+ "f01=a&f01=b"
 			+ "&f02=c&f02=d"

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingSerializerTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingSerializerTest.java b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingSerializerTest.java
index 84f240b..91dc1a6 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingSerializerTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingSerializerTest.java
@@ -17,7 +17,7 @@ import static org.junit.Assert.*;
 import java.util.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.json.JsonSerializer;
+import org.apache.juneau.json.*;
 import org.junit.*;
 
 @SuppressWarnings("javadoc")
@@ -343,7 +343,7 @@ public class UrlEncodingSerializerTest {
 			+ "&f20=@(@((a=a,b=1,c=true)),@((a=a,b=1,c=true)))";
 		assertEquals(e, r);
 
-		s = UrlEncodingSerializer.DEFAULT.clone().setExpandedParams(true);
+		s = new UrlEncodingSerializerBuilder().expandedParams(true).build();
 		r = s.serialize(t);
 		e = ""
 			+ "f01=a&f01=b"
@@ -404,7 +404,7 @@ public class UrlEncodingSerializerTest {
 			+ "&f20=@((a=a,b=1,c=true))&f20=@((a=a,b=1,c=true))";
 		assertEquals(e, r);
 
-		s = UrlEncodingSerializer.DEFAULT.clone().setExpandedParams(true);
+		s = new UrlEncodingSerializerBuilder().expandedParams(true).build();
 		r = s.serialize(t);
 		e = ""
 			+ "f01=a&f01=b"

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/utils/PojoQueryTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/utils/PojoQueryTest.java b/juneau-core-test/src/test/java/org/apache/juneau/utils/PojoQueryTest.java
index 5f451fd..c73d51a 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/utils/PojoQueryTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/utils/PojoQueryTest.java
@@ -87,7 +87,7 @@ public class PojoQueryTest {
 		int limit = 0;
 		boolean ignoreCase = false;
 		BeanSession session = BeanContext.DEFAULT.createSession();
-		WriterSerializer s = new JsonSerializer.Simple().addPojoSwaps(CalendarSwap.DateTimeSimple.class);
+		WriterSerializer s = new JsonSerializerBuilder().simple().pojoSwaps(CalendarSwap.DateTimeSimple.class).build();
 		B[] in;
 		PojoQuery filter;
 
@@ -603,7 +603,7 @@ public class PojoQueryTest {
 		int limit = 0;
 		boolean ignoreCase = false;
 		BeanSession session = BeanContext.DEFAULT.createSession();
-		WriterSerializer s = new JsonSerializer.Simple().addPojoSwaps(CalendarSwap.DateTimeSimple.class);
+		WriterSerializer s = new JsonSerializerBuilder().simple().pojoSwaps(CalendarSwap.DateTimeSimple.class).build();
 		List results;
 
 		I[] in = new I[] {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/utils/PojoRestTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/utils/PojoRestTest.java b/juneau-core-test/src/test/java/org/apache/juneau/utils/PojoRestTest.java
index be25076..f274435 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/utils/PojoRestTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/utils/PojoRestTest.java
@@ -71,7 +71,7 @@ public class PojoRestTest {
 		model.put("/person1", p);
 
 		// Make sure it got stored correctly.
-		JsonSerializer serializer = JsonSerializer.DEFAULT_LAX.clone().setAddBeanTypeProperties(false);
+		JsonSerializer serializer = new JsonSerializerBuilder().simple().addBeanTypeProperties(false).build();
 		assertEquals("{person1:{name:'some name',age:123,addresses:[{street:'street A',city:'city A',state:'state A',zip:12345,isCurrent:true},{street:'street B',city:'city B',state:'state B',zip:12345,isCurrent:false}]}}", serializer.serialize(model.getRootObject()));
 
 		// Get the original Person object back.
@@ -82,7 +82,7 @@ public class PojoRestTest {
 		Address a3 = (Address)model.get("/person1/addresses/1");
 		assertEquals("city B", a3.city);
 
-		serializer = new JsonSerializer.Simple();
+		serializer = JsonSerializer.DEFAULT_LAX;
 		p = new Person("some name", 123,
 			new Address("street A", "city A", "state A", 12345, true),
 			new Address("street B", "city B", "state B", 12345, false)
@@ -94,7 +94,7 @@ public class PojoRestTest {
 		assertEquals(expectedValue, s);
 
 		// Parse it back to Java objects.
-		p = (Person)JsonParser.DEFAULT.clone().addToBeanDictionary(Person.class).parse(s, Object.class);
+		p = (Person)new JsonParserBuilder().beanDictionary(Person.class).build().parse(s, Object.class);
 		expectedValue = "city B";
 		s = p.addresses[1].city;
 		assertEquals(expectedValue, s);
@@ -115,7 +115,7 @@ public class PojoRestTest {
 		model.put("addresses/0", new Address("street D", "city D", "state D", 12345, false));
 		model.put("addresses/1", new Address("street E", "city E", "state E", 12345, false));
 		model.put("addresses/2", new Address("street F", "city F", "state F", 12345, false));
-		serializer = JsonSerializer.DEFAULT_LAX.clone().setAddBeanTypeProperties(false);
+		serializer = new JsonSerializerBuilder().simple().addBeanTypeProperties(false).build();
 		s = serializer.serialize(p);
 		expectedValue = "{name:'some name',age:123,addresses:[{street:'street D',city:'city D',state:'state D',zip:12345,isCurrent:false},{street:'street E',city:'city E',state:'state E',zip:12345,isCurrent:false},{street:'street F',city:'city F',state:'state F',zip:12345,isCurrent:false}]}";
 		assertEquals(expectedValue, s);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/utils/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/utils/StringUtilsTest.java b/juneau-core-test/src/test/java/org/apache/juneau/utils/StringUtilsTest.java
index 5adc446..95c340b 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/utils/StringUtilsTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/utils/StringUtilsTest.java
@@ -638,7 +638,7 @@ public class StringUtilsTest {
 	//====================================================================================================
 	@Test
 	public void testParseISO8601Date() throws Exception {
-		WriterSerializer s = new JsonSerializer.Simple().addPojoSwaps(DateSwap.ISO8601DTPZ.class).setTimeZone(TimeZone.getTimeZone("GMT"));
+		WriterSerializer s = new JsonSerializerBuilder().simple().pojoSwaps(DateSwap.ISO8601DTPZ.class).timeZone(TimeZone.getTimeZone("GMT")).build();
 
 		assertNull(parseISO8601Date(null));
 		assertNull(parseISO8601Date(""));

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/utils/StringVarResolverTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/utils/StringVarResolverTest.java b/juneau-core-test/src/test/java/org/apache/juneau/utils/StringVarResolverTest.java
index 9cc91ff..122dbd6 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/utils/StringVarResolverTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/utils/StringVarResolverTest.java
@@ -26,7 +26,7 @@ public class StringVarResolverTest {
 	//====================================================================================================
 	@Test
 	public void test() throws Exception {
-		VarResolver vr = new VarResolver().addVars(XVar.class);
+		VarResolver vr = new VarResolverBuilder().vars(XVar.class).build();
 		String t;
 
 		t = null;
@@ -99,7 +99,7 @@ public class StringVarResolverTest {
 	//====================================================================================================
 	@Test
 	public void test2() throws Exception {
-		VarResolver vr = new VarResolver().addVars(BlankVar.class);
+		VarResolver vr = new VarResolverBuilder().vars(BlankVar.class).build();
 		String t;
 
 		t = "${y}";
@@ -130,7 +130,7 @@ public class StringVarResolverTest {
 	//====================================================================================================
 	@Test
 	public void testEscaped$() throws Exception {
-		VarResolver vr = new VarResolver().addVars(BlankVar.class);
+		VarResolver vr = new VarResolverBuilder().vars(BlankVar.class).build();
 		String t;
 
 		t = "${y}";
@@ -151,7 +151,7 @@ public class StringVarResolverTest {
 	//====================================================================================================
 	@Test
 	public void testEscapedSequences() throws Exception {
-		VarResolver vr = new VarResolver().addVars(XVar.class);
+		VarResolver vr = new VarResolverBuilder().vars(XVar.class).build();
 		String t;
 		char b = '\\';
 
@@ -191,15 +191,15 @@ public class StringVarResolverTest {
 	//====================================================================================================
 	@Test
 	public void testParent() throws Exception {
-		VarResolver svr = VarResolver.DEFAULT.clone().addVars(XMultipartVar.class);
+		VarResolver vr = new VarResolverBuilder().defaultVars().vars(XMultipartVar.class).build();
 		String t;
 		System.setProperty("a", "a1");
 		System.setProperty("b", "b1");
 
 		t = "$X{$S{a},$S{b}}";
-		assertEquals("a1+b1", svr.resolve(t));
+		assertEquals("a1+b1", vr.resolve(t));
 		t = "$X{$S{a}}";
-		assertEquals("a1", svr.resolve(t));
+		assertEquals("a1", vr.resolve(t));
 	}
 
 	public static class XMultipartVar extends MultipartVar {
@@ -217,72 +217,76 @@ public class StringVarResolverTest {
 	//====================================================================================================
 	@Test
 	public void testFalseTriggers() throws Exception {
-		VarResolver svr = VarResolver.DEFAULT.clone();
+		VarResolverBuilder vrb = new VarResolverBuilder().defaultVars();
 		String in = null;
 
 		// Should reject names with characters outside A-Za-z
 		for (Class<?> c : new Class[]{InvalidVar1.class, InvalidVar2.class, InvalidVar3.class, InvalidVar4.class, InvalidVar5.class}) {
 			try {
-				svr.addVars(c);
+				vrb.vars(c);
 				fail();
 			} catch (IllegalArgumentException e) {
 				assertEquals("Invalid var name.  Must consist of only uppercase and lowercase ASCII letters.", e.getLocalizedMessage());
 			}
 		}
 
+		VarResolver vr = vrb.build();
+		
 		// These should all be unchanged.
 		in = "$@{foobar}";
-		assertEquals(in, svr.resolve(in));
+		assertEquals(in, vr.resolve(in));
 		in = "$[{foobar}";
-		assertEquals(in, svr.resolve(in));
+		assertEquals(in, vr.resolve(in));
 		in = "$`{foobar}";
-		assertEquals(in, svr.resolve(in));
+		assertEquals(in, vr.resolve(in));
 		in = "$|{foobar}";
-		assertEquals(in, svr.resolve(in));
+		assertEquals(in, vr.resolve(in));
 		in = "${{foobar}";
-		assertEquals(in, svr.resolve(in));
+		assertEquals(in, vr.resolve(in));
 		in = "${$foobar}";
-		assertEquals(in, svr.resolve(in));
+		assertEquals(in, vr.resolve(in));
 
 		System.setProperty("foobar", "baz");
 
 		in = "$";
-		assertEquals(in, svr.resolve(in));
+		assertEquals(in, vr.resolve(in));
 
 		in = "$S";
-		assertEquals(in, svr.resolve(in));
+		assertEquals(in, vr.resolve(in));
 
 		in = "$S{";
-		assertEquals(in, svr.resolve(in));
+		assertEquals(in, vr.resolve(in));
 
 		in = "$S{foobar";
 
-		assertEquals(in, svr.resolve(in));
+		assertEquals(in, vr.resolve(in));
 		in = "$S{foobar}$";
-		assertEquals("baz$", svr.resolve(in));
+		assertEquals("baz$", vr.resolve(in));
 
 		in = "$S{foobar}$S";
-		assertEquals("baz$S", svr.resolve(in));
+		assertEquals("baz$S", vr.resolve(in));
 
 		in = "$S{foobar}$S{";
-		assertEquals("baz$S{", svr.resolve(in));
+		assertEquals("baz$S{", vr.resolve(in));
 
 		in = "$S{foobar}$S{foobar";
-		assertEquals("baz$S{foobar", svr.resolve(in));
+		assertEquals("baz$S{foobar", vr.resolve(in));
 
 		System.clearProperty("foobar");
 		in = "$S{foobar}";
 
 		// Test nulls returned by StringVar.
 		// Should be converted to blanks.
-		svr.addVars(AlwaysNullVar.class);
+		vrb.vars(AlwaysNullVar.class);
 
+		vr = vrb.build();
+		
 		in = "$A{xxx}";
-		assertEquals("", svr.resolve(in));
+		assertEquals("", vr.resolve(in));
 		in = "x$A{xxx}";
-		assertEquals("x", svr.resolve(in));
+		assertEquals("x", vr.resolve(in));
 		in = "$A{xxx}x";
-		assertEquals("x", svr.resolve(in));
+		assertEquals("x", vr.resolve(in));
 	}
 
 	public static class AlwaysNullVar extends SimpleVar {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonParserTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonParserTest.java b/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonParserTest.java
index 68265db..6c06dc3 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonParserTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonParserTest.java
@@ -103,7 +103,7 @@ public class CommonParserTest {
 	//====================================================================================================
 	@Test
 	public void testCorrectHandlingOfUnknownProperties() throws Exception {
-		ReaderParser p = new XmlParser().setIgnoreUnknownBeanProperties(true);
+		ReaderParser p = new XmlParserBuilder().ignoreUnknownBeanProperties(true).build();
 		B t;
 
 		String in =  "<object><a>1</a><unknown>foo</unknown><b>2</b></object>";
@@ -118,7 +118,7 @@ public class CommonParserTest {
 
 
 		try {
-			p = new XmlParser();
+			p = XmlParser.DEFAULT;
 			p.parse(in, B.class);
 			fail("Exception expected");
 		} catch (ParseException e) {}
@@ -159,7 +159,7 @@ public class CommonParserTest {
 	@Test
 	public void testParserListeners() throws Exception {
 		final List<String> events = new LinkedList<String>();
-		XmlParser p = new XmlParser().setIgnoreUnknownBeanProperties(true);
+		XmlParser p = new XmlParserBuilder().ignoreUnknownBeanProperties(true).build();
 		p.addListener(
 			new ParserListener() {
 				@Override /* ParserListener */

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonTest.java b/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonTest.java
index 764847a..240b2e4 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonTest.java
@@ -23,7 +23,6 @@ import java.util.*;
 import org.apache.juneau.*;
 import org.apache.juneau.annotation.*;
 import org.apache.juneau.jena.annotation.*;
-import org.apache.juneau.serializer.*;
 import org.apache.juneau.testbeans.*;
 import org.apache.juneau.xml.annotation.*;
 import org.junit.*;
@@ -36,18 +35,18 @@ public class CommonTest {
 	//====================================================================================================
 	@Test
 	public void testTrimNullsFromBeans() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq();
-		XmlParser p = new XmlParser();
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq();
+		XmlParser p = XmlParser.DEFAULT;
 		A t1 = A.create(), t2;
 
-		s.setTrimNullProperties(false);
-		String r = s.serialize(t1);
+		s.trimNullProperties(false);
+		String r = s.build().serialize(t1);
 		assertEquals("<object><s1 _type='null'/><s2>s2</s2></object>", r);
 		t2 = p.parse(r, A.class);
 		assertEqualObjects(t1, t2);
 
-		s.setTrimNullProperties(true);
-		r = s.serialize(t1);
+		s.trimNullProperties(true);
+		r = s.build().serialize(t1);
 		assertEquals("<object><s2>s2</s2></object>", r);
 		t2 = p.parse(r, A.class);
 		assertEqualObjects(t1, t2);
@@ -68,19 +67,19 @@ public class CommonTest {
 	//====================================================================================================
 	@Test
 	public void testTrimEmptyMaps() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq();
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq();
 		XmlParser p = XmlParser.DEFAULT;
 		B t1 = B.create(), t2;
 		String r;
 
-		s.setTrimEmptyMaps(false);
-		r = s.serialize(t1);
+		s.trimEmptyMaps(false);
+		r = s.build().serialize(t1);
 		assertEquals("<object><f1/><f2><f2a _type='null'/><f2b><s2>s2</s2></f2b></f2></object>", r);
 		t2 = p.parse(r, B.class);
 		assertEqualObjects(t1, t2);
 
-		s.setTrimEmptyMaps(true);
-		r = s.serialize(t1);
+		s.trimEmptyMaps(true);
+		r = s.build().serialize(t1);
 		assertEquals("<object><f2><f2a _type='null'/><f2b><s2>s2</s2></f2b></f2></object>", r);
 		t2 = p.parse(r, B.class);
 		assertNull(t2.f1);
@@ -102,19 +101,19 @@ public class CommonTest {
 	//====================================================================================================
 	@Test
 	public void testTrimEmptyLists() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq();
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq();
 		XmlParser p = XmlParser.DEFAULT;
 		C t1 = C.create(), t2;
 		String r;
 
-		s.setTrimEmptyCollections(false);
-		r = s.serialize(t1);
+		s.trimEmptyCollections(false);
+		r = s.build().serialize(t1);
 		assertEquals("<object><f1></f1><f2><null/><object><s2>s2</s2></object></f2></object>", r);
 		t2 = p.parse(r, C.class);
 		assertEqualObjects(t1, t2);
 
-		s.setTrimEmptyCollections(true);
-		r = s.serialize(t1);
+		s.trimEmptyCollections(true);
+		r = s.build().serialize(t1);
 		assertEquals("<object><f2><null/><object><s2>s2</s2></object></f2></object>", r);
 		t2 = p.parse(r, C.class);
 		assertNull(t2.f1);
@@ -136,19 +135,19 @@ public class CommonTest {
 	//====================================================================================================
 	@Test
 	public void testTrimEmptyArrays() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq();
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq();
 		XmlParser p = XmlParser.DEFAULT;
 		D t1 = D.create(), t2;
 		String r;
 
-		s.setTrimEmptyCollections(false);
-		r = s.serialize(t1);
+		s.trimEmptyCollections(false);
+		r = s.build().serialize(t1);
 		assertEquals("<object><f1></f1><f2><null/><object><s2>s2</s2></object></f2></object>", r);
 		t2 = p.parse(r, D.class);
 		assertEqualObjects(t1, t2);
 
-		s.setTrimEmptyCollections(true);
-		r = s.serialize(t1);
+		s.trimEmptyCollections(true);
+		r = s.build().serialize(t1);
 		assertEquals("<object><f2><null/><object><s2>s2</s2></object></f2></object>", r);
 		t2 = p.parse(r, D.class);
 		assertNull(t2.f1);
@@ -258,13 +257,13 @@ public class CommonTest {
 	//====================================================================================================
 	@Test
 	public void testUris() throws Exception {
-		WriterSerializer s = new XmlSerializer.Sq();
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq();
 		TestURI t = new TestURI();
 		String r;
 		String expected;
 
-		s.setRelativeUriBase(null);
-		r = s.serialize(t);
+		s.relativeUriBase(null);
+		r = s.build().serialize(t);
 		expected = ""
 			+"<object f0='f0/x0'>"
 			+"<f1>f1/x1</f1>"
@@ -284,12 +283,12 @@ public class CommonTest {
 			+"</object>";
 		assertEquals(expected, r);
 
-		s.setRelativeUriBase("");  // Same as null.
-		r = s.serialize(t);
+		s.relativeUriBase("");  // Same as null.
+		r = s.build().serialize(t);
 		assertEquals(expected, r);
 
-		s.setRelativeUriBase("/cr");
-		r = s.serialize(t);
+		s.relativeUriBase("/cr");
+		r = s.build().serialize(t);
 		expected = ""
 			+"<object f0='/cr/f0/x0'>"
 			+"<f1>/cr/f1/x1</f1>"
@@ -309,12 +308,12 @@ public class CommonTest {
 			+"</object>";
 		assertEquals(expected, r);
 
-		s.setRelativeUriBase("/cr/");  // Same as above
-		r = s.serialize(t);
+		s.relativeUriBase("/cr/");  // Same as above
+		r = s.build().serialize(t);
 		assertEquals(expected, r);
 
-		s.setRelativeUriBase("/");
-		r = s.serialize(t);
+		s.relativeUriBase("/");
+		r = s.build().serialize(t);
 		expected = ""
 			+"<object f0='/f0/x0'>"
 			+"<f1>/f1/x1</f1>"
@@ -334,10 +333,10 @@ public class CommonTest {
 			+"</object>";
 		assertEquals(expected, r);
 
-		s.setRelativeUriBase(null);
+		s.relativeUriBase(null);
 
-		s.setAbsolutePathUriBase("http://foo");
-		r = s.serialize(t);
+		s.absolutePathUriBase("http://foo");
+		r = s.build().serialize(t);
 		expected = ""
 			+"<object f0='f0/x0'>"
 			+"<f1>f1/x1</f1>"
@@ -357,12 +356,12 @@ public class CommonTest {
 			+"</object>";
 		assertEquals(expected, r);
 
-		s.setAbsolutePathUriBase("http://foo/");
-		r = s.serialize(t);
+		s.absolutePathUriBase("http://foo/");
+		r = s.build().serialize(t);
 		assertEquals(expected, r);
 
-		s.setAbsolutePathUriBase("");  // Same as null.
-		r = s.serialize(t);
+		s.absolutePathUriBase("");  // Same as null.
+		r = s.build().serialize(t);
 		expected = ""
 			+"<object f0='f0/x0'>"
 			+"<f1>f1/x1</f1>"
@@ -384,31 +383,11 @@ public class CommonTest {
 	}
 
 	//====================================================================================================
-	// Validate that you cannot update properties on locked serializer.
-	//====================================================================================================
-	@Test
-	public void testLockedSerializer() throws Exception {
-		XmlSerializer s = new XmlSerializer().lock();
-		try {
-			s.setEnableNamespaces(true);
-			fail("Locked exception not thrown");
-		} catch (LockedException e) {}
-		try {
-			s.setAddBeanTypeProperties(true);
-			fail("Locked exception not thrown");
-		} catch (LockedException e) {}
-		try {
-			s.setBeanMapPutReturnsOldValue(true);
-			fail("Locked exception not thrown");
-		} catch (LockedException e) {}
-	}
-
-	//====================================================================================================
 	// Recursion
 	//====================================================================================================
 	@Test
 	public void testRecursion() throws Exception {
-		XmlSerializer s = new XmlSerializer().setEnableNamespaces(false);
+		XmlSerializerBuilder s = new XmlSerializerBuilder().enableNamespaces(false);
 
 		R1 r1 = new R1();
 		R2 r2 = new R2();
@@ -419,7 +398,7 @@ public class CommonTest {
 
 		// No recursion detection
 		try {
-			s.serialize(r1);
+			s.build().serialize(r1);
 			fail("Exception expected!");
 		} catch (Exception e) {
 			String msg = e.getLocalizedMessage();
@@ -427,9 +406,9 @@ public class CommonTest {
 		}
 
 		// Recursion detection, no ignore
-		s.setDetectRecursions(true);
+		s.detectRecursions(true);
 		try {
-			s.serialize(r1);
+			s.build().serialize(r1);
 			fail("Exception expected!");
 		} catch (Exception e) {
 			String msg = e.getLocalizedMessage();
@@ -439,11 +418,11 @@ public class CommonTest {
 			assertTrue(msg.contains("->[3]r1:org.apache.juneau.xml.CommonTest$R1"));
 		}
 
-		s.setIgnoreRecursions(true);
-		assertEquals("<object><name>foo</name><r2><name>bar</name><r3><name>baz</name></r3></r2></object>", s.serialize(r1));
+		s.ignoreRecursions(true);
+		assertEquals("<object><name>foo</name><r2><name>bar</name><r3><name>baz</name></r3></r2></object>", s.build().serialize(r1));
 
 		// Make sure this doesn't blow up.
-		s.getSchemaSerializer().serialize(r1);
+		s.build().getSchemaSerializer().serialize(r1);
 	}
 
 	public static class R1 {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonXmlTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonXmlTest.java b/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonXmlTest.java
index 996a6cf..031a879 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonXmlTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/xml/CommonXmlTest.java
@@ -61,7 +61,7 @@ public class CommonXmlTest {
 	//====================================================================================================
 	@Test
 	public void testBeanUriAnnotationOnlyUriProperty() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq().setAddNamespaceUrisToRoot(false);
+		XmlSerializer s = new XmlSerializerBuilder().sq().addNamespaceUrisToRoot(false).build();
 
 		B t = new B("http://foo");
 		String xml = s.serialize(t);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlContentTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlContentTest.java b/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlContentTest.java
index e11fe18..6f0738e 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlContentTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlContentTest.java
@@ -34,7 +34,7 @@ public class XmlContentTest {
 	public void testContentFormat() throws Exception {
 		A t = A.newInstance(), t2;
 		XmlSerializer s1 = XmlSerializer.DEFAULT_SQ,
-			s2 = new XmlSerializer().setQuoteChar('\'').setUseWhitespace(true).setEnableNamespaces(false);
+			s2 = new XmlSerializerBuilder().sq().ws().enableNamespaces(false).build();
 		XmlParser p = XmlParser.DEFAULT;
 		XmlSerializerSession session;
 		String r;
@@ -142,7 +142,7 @@ public class XmlContentTest {
 	public void testXmlMixed() throws Exception {
 		B t = B.newInstance(), t2;
 		XmlSerializer s1 = XmlSerializer.DEFAULT_SQ,
-			s2 = new XmlSerializer().setQuoteChar('\'').setUseWhitespace(true).setEnableNamespaces(false);
+			s2 = new XmlSerializerBuilder().sq().ws().enableNamespaces(false).build();
 		XmlParser p = XmlParser.DEFAULT;
 		XmlSerializerSession session;
 		String r;

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlParserTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlParserTest.java b/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlParserTest.java
index 64ca1c3..9e1f571 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlParserTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlParserTest.java
@@ -82,7 +82,7 @@ public class XmlParserTest {
 	public void testPreserveRootElement() throws Exception {
 		String xml;
 		ObjectMap m;
-		ReaderParser p = new XmlParser().setPreserveRootElement(true);
+		ReaderParser p = new XmlParserBuilder().preserveRootElement(true).build();
 
 		xml = "<A><B><C>c</C></B></A>";
 		m = p.parse(xml, ObjectMap.class);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlTest.java b/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlTest.java
index d7ece92..555ca49 100755
--- a/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlTest.java
+++ b/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlTest.java
@@ -77,12 +77,13 @@ public class XmlTest {
 			+"</object>\n";
 
 		ObjectMap m = (ObjectMap) XmlParser.DEFAULT.parse(xml1, Object.class);
-		String json2 = new JsonSerializer.SimpleReadable().setQuoteChar('"').setTrimNullProperties(false).serialize(m);
+		String json2 = new JsonSerializerBuilder().simple().ws().quoteChar('"').trimNullProperties(false).build().serialize(m);
 		assertEquals(json1, json2);
 
 		m = (ObjectMap) JsonParser.DEFAULT.parse(json1, Object.class);
-		String xml2 = new XmlSerializer.SqReadable()
-			.setTrimNullProperties(false)
+		String xml2 = new XmlSerializerBuilder().sq().ws()
+			.trimNullProperties(false)
+			.build()
 			.serialize(m);
 		assertEquals(xml1, xml2);
 	}
@@ -132,10 +133,11 @@ public class XmlTest {
 			+"</object>\n";
 
 		ObjectMap m = (ObjectMap) JsonParser.DEFAULT.parse(json1, Object.class);
-		String r = new XmlSerializer.NsSqReadable()
-			.setAddNamespaceUrisToRoot(true)
-			.setDefaultNamespace("http://www.apache.org")
-			.setTrimNullProperties(false)
+		String r = new XmlSerializerBuilder().ns().sq().ws()
+			.addNamespaceUrisToRoot(true)
+			.defaultNamespace("http://www.apache.org")
+			.trimNullProperties(false)
+			.build()
 			.serialize(m);
 		assertEquals(xml1, r);
 	}
@@ -351,21 +353,21 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testXmlFormatAttrWithNs() throws Exception {
-		XmlSerializer s = XmlSerializer.DEFAULT_SQ.clone();
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq();
 		XmlParser p = XmlParser.DEFAULT;
 		M t = new M();
 		String r = null;
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<object f1='1' f2='2' f3='3'/>", r);
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(true).setAutoDetectNamespaces(true).setTrimNullProperties(false);
+		s.enableNamespaces(true).addNamespaceUrisToRoot(true).autoDetectNamespaces(true).trimNullProperties(false);
 		t.f1 = 4; t.f2 = 5; t.f3 = 6;
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:bar='http://bar' xmlns:foo='http://foo' xmlns:baz='http://baz' bar:f1='4' foo:f2='5' baz:f3='6'/>", r);
 		t = p.parse(r, M.class);
 		assertEquals(4, t.f1);
 		assertEquals(5, t.f2);
 		assertEquals(6, t.f3);
-		validateXml(t, s);
+		validateXml(t, s.build());
 	}
 
 	@Xml(prefix="bar", namespace="http://bar")
@@ -519,51 +521,51 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testNsOnClass() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq().setAutoDetectNamespaces(false);
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq().autoDetectNamespaces(false);
 		XmlParser p = XmlParser.DEFAULT;
 
 		T1 t = new T1();
-		String r = s.serialize(t);
+		String r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T1.class)));
 
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(false);
-		r = s.serialize(t);
+		s.enableNamespaces(true).addNamespaceUrisToRoot(false);
+		r = s.build().serialize(t);
 		assertEquals("<object><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></object>", r);
 
 		// Add namespace URIs to root, but don't auto-detect.
 		// Only xsi should be added to root.
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></object>", r);
 
 		// Manually set namespaces
-		s.setNamespaces(
+		s.namespaces(
 			NamespaceFactory.get("foo","http://foo"),
 			NamespaceFactory.get("bar","http://bar"),
 			NamespaceFactory.get("baz","http://baz")
 		);
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T1.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 
 		// Auto-detect namespaces.
-		s = new XmlSerializer.Sq().setAutoDetectNamespaces(true);
-		r = s.serialize(t);
+		s = new XmlSerializerBuilder().sq().autoDetectNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T1.class)));
 
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T1.class)));
 
-		s.setEnableNamespaces(true);
-		r = s.serialize(t);
+		s.enableNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T1.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 	}
 
 	//====================================================================================================
@@ -571,49 +573,49 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testNsOnClassWithElementName() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq().setAutoDetectNamespaces(false);
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq().autoDetectNamespaces(false);
 		XmlParser p = XmlParser.DEFAULT;
 
 		T2 t = new T2();
-		String r = s.serialize(t);
+		String r = s.build().serialize(t);
 		assertEquals("<T2><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></T2>", r);
 		assertTrue(t.equals(p.parse(r, T2.class)));
 
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(false);
-		r = s.serialize(t);
+		s.enableNamespaces(true).addNamespaceUrisToRoot(false);
+		r = s.build().serialize(t);
 		assertEquals("<foo:T2><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></foo:T2>", r);
 
 		// Add namespace URIs to root, but don't auto-detect.
 		// Only xsi should be added to root.
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<foo:T2 xmlns='http://www.apache.org/2013/Juneau'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></foo:T2>", r);
 
 		// Manually set namespaces
-		s.setNamespaces(
+		s.namespaces(
 			NamespaceFactory.get("foo","http://foo"),
 			NamespaceFactory.get("bar","http://bar"),
 			NamespaceFactory.get("baz","http://baz")
 		);
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<foo:T2 xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></foo:T2>", r);
 		assertTrue(t.equals(p.parse(r, T2.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 
 		// Auto-detect namespaces.
-		s = new XmlSerializer.Sq().setAutoDetectNamespaces(true);
-		r = s.serialize(t);
+		s = new XmlSerializerBuilder().sq().autoDetectNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<T2><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></T2>", r);
 
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<T2><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></T2>", r);
 
-		s.setEnableNamespaces(true);
-		r = s.serialize(t);
+		s.enableNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<foo:T2 xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></foo:T2>", r);
 		assertTrue(t.equals(p.parse(r, T2.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 	}
 
 
@@ -622,51 +624,51 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testNsOnPackageNoNsOnClass() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq();
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq();
 		XmlParser p = XmlParser.DEFAULT;
 
 		T3 t = new T3();
-		String r = s.serialize(t);
+		String r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T3.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(false);
-		r = s.serialize(t);
+		s.enableNamespaces(true).addNamespaceUrisToRoot(false);
+		r = s.build().serialize(t);
 		assertEquals("<object><p1:f1>1</p1:f1><bar:f2>2</bar:f2><p1:f3>3</p1:f3><baz:f4>4</baz:f4></object>", r);
 
 		// Add namespace URIs to root, but don't auto-detect.
 		// Only xsi should be added to root.
-		s.setAddNamespaceUrisToRoot(true).setAutoDetectNamespaces(false);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true).autoDetectNamespaces(false);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau'><p1:f1>1</p1:f1><bar:f2>2</bar:f2><p1:f3>3</p1:f3><baz:f4>4</baz:f4></object>", r);
 
 		// Manually set namespaces
-		s.setAutoDetectNamespaces(false);
-		s.setNamespaces(
+		s.autoDetectNamespaces(false);
+		s.namespaces(
 			NamespaceFactory.get("p1","http://p1"),
 			NamespaceFactory.get("bar","http://bar"),
 			NamespaceFactory.get("baz","http://baz")
 		);
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:p1='http://p1' xmlns:bar='http://bar' xmlns:baz='http://baz'><p1:f1>1</p1:f1><bar:f2>2</bar:f2><p1:f3>3</p1:f3><baz:f4>4</baz:f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T3.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 
 		// Auto-detect namespaces.
-		s = new XmlSerializer.Sq().setAutoDetectNamespaces(true);
-		r = s.serialize(t);
+		s = new XmlSerializerBuilder().sq().autoDetectNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
 
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
 
-		s.setEnableNamespaces(true);
-		r = s.serialize(t);
+		s.enableNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:p1='http://p1' xmlns:bar='http://bar' xmlns:baz='http://baz'><p1:f1>1</p1:f1><bar:f2>2</bar:f2><p1:f3>3</p1:f3><baz:f4>4</baz:f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T3.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 	}
 
 	//====================================================================================================
@@ -674,50 +676,50 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testNsOnPackageNoNsOnClassElementNameOnClass() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq().setAutoDetectNamespaces(false);
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq().autoDetectNamespaces(false);
 		XmlParser p = XmlParser.DEFAULT;
 
 		T4 t = new T4();
-		String r = s.serialize(t);
+		String r = s.build().serialize(t);
 		assertEquals("<T4><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></T4>", r);
 		assertTrue(t.equals(p.parse(r, T4.class)));
 
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(false);
-		r = s.serialize(t);
+		s.enableNamespaces(true).addNamespaceUrisToRoot(false);
+		r = s.build().serialize(t);
 		assertEquals("<p1:T4><p1:f1>1</p1:f1><bar:f2>2</bar:f2><p1:f3>3</p1:f3><baz:f4>4</baz:f4></p1:T4>", r);
 
 		// Add namespace URIs to root, but don't auto-detect.
 		// Only xsi should be added to root.
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<p1:T4 xmlns='http://www.apache.org/2013/Juneau'><p1:f1>1</p1:f1><bar:f2>2</bar:f2><p1:f3>3</p1:f3><baz:f4>4</baz:f4></p1:T4>", r);
 
 		// Manually set namespaces
-		s.setNamespaces(
+		s.namespaces(
 			NamespaceFactory.get("foo","http://foo"),
 			NamespaceFactory.get("bar","http://bar"),
 			NamespaceFactory.get("baz","http://baz"),
 			NamespaceFactory.get("p1","http://p1")
 		);
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<p1:T4 xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz' xmlns:p1='http://p1'><p1:f1>1</p1:f1><bar:f2>2</bar:f2><p1:f3>3</p1:f3><baz:f4>4</baz:f4></p1:T4>", r);
 		assertTrue(t.equals(p.parse(r, T4.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 
 		// Auto-detect namespaces.
-		s = new XmlSerializer.Sq().setAutoDetectNamespaces(true);
-		r = s.serialize(t);
+		s = new XmlSerializerBuilder().sq().autoDetectNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<T4><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></T4>", r);
 
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<T4><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></T4>", r);
 
-		s.setEnableNamespaces(true);
-		r = s.serialize(t);
+		s.enableNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<p1:T4 xmlns='http://www.apache.org/2013/Juneau' xmlns:p1='http://p1' xmlns:bar='http://bar' xmlns:baz='http://baz'><p1:f1>1</p1:f1><bar:f2>2</bar:f2><p1:f3>3</p1:f3><baz:f4>4</baz:f4></p1:T4>", r);
 		assertTrue(t.equals(p.parse(r, T4.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 	}
 
 	//====================================================================================================
@@ -725,52 +727,52 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testNsOnPackageNsOnClassElementNameOnClass() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq();
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq();
 		XmlParser p = XmlParser.DEFAULT;
 
 		T5 t = new T5();
-		String r = s.serialize(t);
+		String r = s.build().serialize(t);
 		assertEquals("<T5><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></T5>", r);
 		assertTrue(t.equals(p.parse(r, T5.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(false).setAutoDetectNamespaces(false);
-		r = s.serialize(t);
+		s.ns().addNamespaceUrisToRoot(false).autoDetectNamespaces(false);
+		r = s.build().serialize(t);
 		assertEquals("<foo:T5><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></foo:T5>", r);
 
 		// Add namespace URIs to root, but don't auto-detect.
 		// Only xsi should be added to root.
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<foo:T5 xmlns='http://www.apache.org/2013/Juneau'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></foo:T5>", r);
 
 		// Manually set namespaces
-		s.setNamespaces(
+		s.namespaces(
 			NamespaceFactory.get("foo","http://foo"),
 			NamespaceFactory.get("bar","http://bar"),
 			NamespaceFactory.get("baz","http://baz")
 		);
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<foo:T5 xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></foo:T5>", r);
 		assertTrue(t.equals(p.parse(r, T5.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 
 		// Auto-detect namespaces.
-		s = new XmlSerializer.Sq().setAutoDetectNamespaces(true);
-		r = s.serialize(t);
+		s = new XmlSerializerBuilder().sq().autoDetectNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<T5><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></T5>", r);
-		validateXml(t, s);
+		validateXml(t, s.build());
 
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<T5><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></T5>", r);
-		validateXml(t, s);
+		validateXml(t, s.build());
 
-		s.setEnableNamespaces(true);
-		r = s.serialize(t);
+		s.ns();
+		r = s.build().serialize(t);
 		assertEquals("<foo:T5 xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></foo:T5>", r);
 		assertTrue(t.equals(p.parse(r, T5.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 	}
 
 	//====================================================================================================
@@ -778,51 +780,51 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testNsOnPackageNsOnClassNoElementNameOnClass() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq().setAutoDetectNamespaces(false);
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq().autoDetectNamespaces(false);
 		XmlParser p = XmlParser.DEFAULT;
 
 		T6 t = new T6();
-		String r = s.serialize(t);
+		String r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T6.class)));
 
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(false);
-		r = s.serialize(t);
+		s.ns().addNamespaceUrisToRoot(false);
+		r = s.build().serialize(t);
 		assertEquals("<object><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></object>", r);
 
 		// Add namespace URIs to root, but don't auto-detect.
 		// Only xsi should be added to root.
-		s.setAddNamespaceUrisToRoot(true).setAutoDetectNamespaces(false);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true).autoDetectNamespaces(false);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></object>", r);
 
 		// Manually set namespaces
-		s.setNamespaces(
+		s.namespaces(
 			NamespaceFactory.get("foo","http://foo"),
 			NamespaceFactory.get("bar","http://bar"),
 			NamespaceFactory.get("baz","http://baz")
 		);
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T6.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 
 		// Auto-detect namespaces.
-		s = new XmlSerializer.Sq().setAutoDetectNamespaces(true);
-		r = s.serialize(t);
+		s = new XmlSerializerBuilder().sq().autoDetectNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
-		validateXml(t, s);
+		validateXml(t, s.build());
 
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
-		validateXml(t, s);
+		validateXml(t, s.build());
 
-		s.setEnableNamespaces(true);
-		r = s.serialize(t);
+		s.ns();
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz'><foo:f1>1</foo:f1><bar:f2>2</bar:f2><foo:f3>3</foo:f3><baz:f4>4</baz:f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T6.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 	}
 
 	//====================================================================================================
@@ -830,49 +832,49 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testComboOfNsAndOverriddenBeanPropertyNames() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq().setAutoDetectNamespaces(false);
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq().autoDetectNamespaces(false);
 		XmlParser p = XmlParser.DEFAULT;
 
 		T7 t = new T7();
-		String r = s.serialize(t);
+		String r = s.build().serialize(t);
 		assertEquals("<object><g1>1</g1><g2>2</g2><g3>3</g3><g4>4</g4></object>", r);
 		assertTrue(t.equals(p.parse(r, T7.class)));
 
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(false);
-		r = s.serialize(t);
+		s.enableNamespaces(true).addNamespaceUrisToRoot(false);
+		r = s.build().serialize(t);
 		assertEquals("<object><p1:g1>1</p1:g1><bar:g2>2</bar:g2><p1:g3>3</p1:g3><baz:g4>4</baz:g4></object>", r);
 
 		// Add namespace URIs to root, but don't auto-detect.
 		// Only xsi should be added to root.
-		s.setAddNamespaceUrisToRoot(true).setAutoDetectNamespaces(false);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true).autoDetectNamespaces(false);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau'><p1:g1>1</p1:g1><bar:g2>2</bar:g2><p1:g3>3</p1:g3><baz:g4>4</baz:g4></object>", r);
 
 		// Manually set namespaces
-		s.setNamespaces(
+		s.namespaces(
 			NamespaceFactory.get("foo","http://foo"),
 			NamespaceFactory.get("bar","http://bar"),
 			NamespaceFactory.get("baz","http://baz"),
 			NamespaceFactory.get("p1","http://p1")
 		);
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz' xmlns:p1='http://p1'><p1:g1>1</p1:g1><bar:g2>2</bar:g2><p1:g3>3</p1:g3><baz:g4>4</baz:g4></object>", r);
 		assertTrue(t.equals(p.parse(r, T7.class)));
 
 		// Auto-detect namespaces.
-		s = new XmlSerializer.Sq().setAutoDetectNamespaces(true);
-		r = s.serialize(t);
+		s = new XmlSerializerBuilder().sq().autoDetectNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><g1>1</g1><g2>2</g2><g3>3</g3><g4>4</g4></object>", r);
 
-		s.setEnableNamespaces(false);
-		r = s.serialize(t);
+		s.enableNamespaces(false);
+		r = s.build().serialize(t);
 		assertEquals("<object><g1>1</g1><g2>2</g2><g3>3</g3><g4>4</g4></object>", r);
 
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.ns().addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:p1='http://p1' xmlns:bar='http://bar' xmlns:baz='http://baz'><p1:g1>1</p1:g1><bar:g2>2</bar:g2><p1:g3>3</p1:g3><baz:g4>4</baz:g4></object>", r);
 		assertTrue(t.equals(p.parse(r, T7.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 	}
 
 	//====================================================================================================
@@ -880,50 +882,50 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testXmlNsAnnotation() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq().setAutoDetectNamespaces(false);
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq().autoDetectNamespaces(false);
 		XmlParser p = XmlParser.DEFAULT;
 
 		T8 t = new T8();
-		String r = s.serialize(t);
+		String r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T8.class)));
 
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(false).setAutoDetectNamespaces(false);
-		r = s.serialize(t);
+		s.ns().addNamespaceUrisToRoot(false).autoDetectNamespaces(false);
+		r = s.build().serialize(t);
 		assertEquals("<object><p2:f1>1</p2:f1><p1:f2>2</p1:f2><c1:f3>3</c1:f3><f1:f4>4</f1:f4></object>", r);
 
 		// Add namespace URIs to root, but don't auto-detect.
 		// Only xsi should be added to root.
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau'><p2:f1>1</p2:f1><p1:f2>2</p1:f2><c1:f3>3</c1:f3><f1:f4>4</f1:f4></object>", r);
 
 		// Manually set namespaces
-		s.setNamespaces(
+		s.namespaces(
 			NamespaceFactory.get("foo","http://foo"),
 			NamespaceFactory.get("bar","http://bar"),
 			NamespaceFactory.get("baz","http://baz")
 		);
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz'><p2:f1>1</p2:f1><p1:f2>2</p1:f2><c1:f3>3</c1:f3><f1:f4>4</f1:f4></object>", r);
 
 		// Auto-detect namespaces.
-		s = new XmlSerializer.Sq().setAutoDetectNamespaces(true);
-		r = s.serialize(t);
+		s = new XmlSerializerBuilder().sq().autoDetectNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T8.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1><f2>2</f2><f3>3</f3><f4>4</f4></object>", r);
-		validateXml(t, s);
+		validateXml(t, s.build());
 
-		s.setEnableNamespaces(true);
-		r = s.serialize(t);
+		s.ns();
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:p2='http://p2' xmlns:p1='http://p1' xmlns:c1='http://c1' xmlns:f1='http://f1'><p2:f1>1</p2:f1><p1:f2>2</p1:f2><c1:f3>3</c1:f3><f1:f4>4</f1:f4></object>", r);
 		assertTrue(t.equals(p.parse(r, T8.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 	}
 
 	//====================================================================================================
@@ -931,50 +933,50 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testXmlNsOnPackageNsUriInXmlNs() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq().setAutoDetectNamespaces(false);
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq().autoDetectNamespaces(false);
 		XmlParser p = XmlParser.DEFAULT;
 
 		T9 t = new T9();
-		String r = s.serialize(t);
+		String r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1></object>", r);
 		assertTrue(t.equals(p.parse(r, T9.class)));
 
-		s.setEnableNamespaces(true).setAutoDetectNamespaces(false).setAddNamespaceUrisToRoot(false);
-		r = s.serialize(t);
+		s.ns().autoDetectNamespaces(false).addNamespaceUrisToRoot(false);
+		r = s.build().serialize(t);
 		assertEquals("<object><p1:f1>1</p1:f1></object>", r);
 
 		// Add namespace URIs to root, but don't auto-detect.
 		// Only xsi should be added to root.
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau'><p1:f1>1</p1:f1></object>", r);
 
 		// Manually set namespaces
-		s.setNamespaces(
+		s.namespaces(
 			NamespaceFactory.get("foo","http://foo"),
 			NamespaceFactory.get("bar","http://bar"),
 			NamespaceFactory.get("baz","http://baz")
 		);
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:foo='http://foo' xmlns:bar='http://bar' xmlns:baz='http://baz'><p1:f1>1</p1:f1></object>", r);
 
 		// Auto-detect namespaces.
-		s = new XmlSerializer.Sq().setAutoDetectNamespaces(true);
-		r = s.serialize(t);
+		s = new XmlSerializerBuilder().sq().autoDetectNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1></object>", r);
 		assertTrue(t.equals(p.parse(r, T9.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 
-		s.setAddNamespaceUrisToRoot(true);
-		r = s.serialize(t);
+		s.addNamespaceUrisToRoot(true);
+		r = s.build().serialize(t);
 		assertEquals("<object><f1>1</f1></object>", r);
-		validateXml(t, s);
+		validateXml(t, s.build());
 
-		s.setEnableNamespaces(true);
-		r = s.serialize(t);
+		s.ns();
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:p1='http://p1'><p1:f1>1</p1:f1></object>", r);
 		assertTrue(t.equals(p.parse(r, T9.class)));
-		validateXml(t, s);
+		validateXml(t, s.build());
 	}
 
 	//====================================================================================================
@@ -982,7 +984,7 @@ public class XmlTest {
 	//====================================================================================================
 	@Test
 	public void testXmlAttrs() throws Exception {
-		XmlSerializer s = new XmlSerializer.Sq();
+		XmlSerializerBuilder s = new XmlSerializerBuilder().sq();
 		XmlParser p = XmlParser.DEFAULT;
 		String r;
 
@@ -990,17 +992,17 @@ public class XmlTest {
 		t.f1 = new URL("http://xf1");
 		t.f2 = "xf2";
 		t.f3 = "xf3";
-		r = s.serialize(t);
+		r = s.build().serialize(t);
 		assertEquals("<object f1='http://xf1' f2='xf2' x3='xf3'/>", r);
 		t = p.parse(r, Q.class);
 		assertEquals("http://xf1", t.f1.toString());
 		assertEquals("xf2", t.f2);
 		assertEquals("xf3", t.f3);
 
-		s.setEnableNamespaces(true).setAddNamespaceUrisToRoot(true).setAutoDetectNamespaces(true);
-		r = s.serialize(t);
+		s.ns().addNamespaceUrisToRoot(true).autoDetectNamespaces(true);
+		r = s.build().serialize(t);
 		assertEquals("<object xmlns='http://www.apache.org/2013/Juneau' xmlns:ns='http://ns' xmlns:nsf1='http://nsf1' xmlns:nsf3='http://nsf3' nsf1:f1='http://xf1' ns:f2='xf2' nsf3:x3='xf3'/>", r);
-		validateXml(t, s);
+		validateXml(t, s.build());
 
 		t = p.parse(r, Q.class);
 		assertEquals("http://xf1", t.f1.toString());

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core/.gitignore
----------------------------------------------------------------------
diff --git a/juneau-core/.gitignore b/juneau-core/.gitignore
index ac0418c..1401e35 100644
--- a/juneau-core/.gitignore
+++ b/juneau-core/.gitignore
@@ -2,3 +2,4 @@
 /.DS_Store
 /.settings/
 /.classpath
+/TODO.txt

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core/src/main/java/org/apache/juneau/.DS_Store
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/.DS_Store b/juneau-core/src/main/java/org/apache/juneau/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/juneau-core/src/main/java/org/apache/juneau/.DS_Store differ

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanContext.java b/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
index 5c5d836..2a2f75a 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
@@ -43,9 +43,9 @@ import org.apache.juneau.transform.*;
  * All serializer and parser contexts extend from this context.
  *
  * <h5 class='topic'>Bean Contexts</h5>
- * Bean contexts are created through the {@link ContextFactory#getContext(Class)} method.
+ * Bean contexts are created through the {@link PropertyStore#getContext(Class)} method.
  * These context objects are read-only, reusable, and thread-safe.
- * The {@link ContextFactory} class will typically cache copies of <code>Context</code> objects based on
+ * The {@link PropertyStore} class will typically cache copies of <code>Context</code> objects based on
  * 	the current settings on the factory.
  * <p>
  * Each bean context maintains a cache of {@link ClassMeta} objects that describe information about classes encountered.
@@ -74,20 +74,20 @@ import org.apache.juneau.transform.*;
  * <p>
  * Some settings (e.g. {@link BeanContext#BEAN_beanMapPutReturnsOldValue}) change the runtime behavior of bean maps.
  * <p>
- * Settings are specified using the {@link ContextFactory#setProperty(String, Object)} method and related convenience methods.
+ * Settings are specified using the {@link PropertyStore#setProperty(String, Object)} method and related convenience methods.
  *
  * <h5 class='section'>Example:</h5>
  * <p class='bcode'>
  * 	<jc>// Construct a context from scratch.</jc>
- * 	BeanContext beanContext = ContextFactory.<jsm>create</jsm>()
- * 		.setProperty(BeanContext.<jsf>BEAN_beansRequireDefaultConstructor</jsf>, <jk>true</jk>)
- * 		.addNotBeanClasses(Foo.<jk>class</jk>)
+ * 	BeanContext beanContext = PropertyStore.<jsm>create</jsm>()
+ * 		.property(BeanContext.<jsf>BEAN_beansRequireDefaultConstructor</jsf>, <jk>true</jk>)
+ * 		.notBeanClasses(Foo.<jk>class</jk>)
  * 		.getBeanContext();
  *
- * 	<jc>// Clone an existing context factory.</jc>
- * 	BeanContext beanContext = ContextFactory.<jsm>create</jsm>(otherConfig)
- * 		.setProperty(BeanContext.<jsf>BEAN_beansRequireDefaultConstructor</jsf>, <jk>true</jk>)
- * 		.addNotBeanClasses(Foo.<jk>class</jk>)
+ * 	<jc>// Clone an existing property store.</jc>
+ * 	BeanContext beanContext = PropertyStore.<jsm>create</jsm>(otherConfig)
+ * 		.property(BeanContext.<jsf>BEAN_beansRequireDefaultConstructor</jsf>, <jk>true</jk>)
+ * 		.notBeanClasses(Foo.<jk>class</jk>)
  * 		.getBeanContext();
  * </p>
  *
@@ -761,7 +761,7 @@ public class BeanContext extends Context {
 	};
 
 
-	static final void loadDefaults(ContextFactory config) {
+	static final void loadDefaults(PropertyStore config) {
 		config.setProperty(BEAN_notBeanPackages, DEFAULT_NOTBEAN_PACKAGES);
 		config.setProperty(BEAN_notBeanClasses, DEFAULT_NOTBEAN_CLASSES);
 	}
@@ -775,10 +775,10 @@ public class BeanContext extends Context {
 	private static final ConcurrentHashMap<Integer,Map<Class,ClassMeta>> cmCacheCache = new ConcurrentHashMap<Integer,Map<Class,ClassMeta>>();
 
 	/** Default config.  All default settings. */
-	public static final BeanContext DEFAULT = ContextFactory.create().getContext(BeanContext.class);
+	public static final BeanContext DEFAULT = PropertyStore.create().getContext(BeanContext.class);
 
 	/** Default config.  All default settings except sort bean properties. */
-	public static final BeanContext DEFAULT_SORTED = ContextFactory.create().setProperty(BEAN_sortProperties, true).getContext(BeanContext.class);
+	public static final BeanContext DEFAULT_SORTED = PropertyStore.create().setProperty(BEAN_sortProperties, true).getContext(BeanContext.class);
 
 	final boolean
 		beansRequireDefaultConstructor,
@@ -829,17 +829,17 @@ public class BeanContext extends Context {
 	/**
 	 * Constructor.
 	 * <p>
-	 * Typically only called from {@link ContextFactory#getContext(Class)} or {@link ContextFactory#getBeanContext()}.
+	 * Typically only called from {@link PropertyStore#getContext(Class)} or {@link PropertyStore#getBeanContext()}.
 	 *
-	 * @param cf The factory that created this context.
+	 * @param ps The property store that created this context.
 	 */
-	public BeanContext(ContextFactory cf) {
-		super(cf);
+	public BeanContext(PropertyStore ps) {
+		super(ps);
 
-		ContextFactory.PropertyMap pm = cf.getPropertyMap("BeanContext");
+		PropertyStore.PropertyMap pm = ps.getPropertyMap("BeanContext");
 		hashCode = pm.hashCode();
-		classLoader = cf.classLoader;
-		defaultParser = cf.defaultParser;
+		classLoader = ps.classLoader;
+		defaultParser = ps.defaultParser;
 
 		beansRequireDefaultConstructor = pm.get(BEAN_beansRequireDefaultConstructor, boolean.class, false);
 		beansRequireSerializable = pm.get(BEAN_beansRequireSerializable, boolean.class, false);
@@ -855,7 +855,7 @@ public class BeanContext extends Context {
 		useJavaBeanIntrospector = pm.get(BEAN_useJavaBeanIntrospector, boolean.class, false);
 		sortProperties = pm.get(BEAN_sortProperties, boolean.class, false);
 		beanTypePropertyName = pm.get(BEAN_beanTypePropertyName, String.class, "_type");
-		debug = cf.getProperty(BEAN_debug, boolean.class, false);
+		debug = ps.getProperty(BEAN_debug, boolean.class, false);
 
 		beanConstructorVisibility = pm.get(BEAN_beanConstructorVisibility, Visibility.class, PUBLIC);
 		beanClassVisibility = pm.get(BEAN_beanClassVisibility, Visibility.class, PUBLIC);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core/src/main/java/org/apache/juneau/BeanMap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanMap.java b/juneau-core/src/main/java/org/apache/juneau/BeanMap.java
index 009ce2f..ed57429 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanMap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanMap.java
@@ -176,7 +176,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T
 	 * 	Person p = <jk>new</jk> Person();
 	 *
 	 * 	<jc>// Create a bean context and add the ISO8601 date-time swap</jc>
-	 * 	BeanContext beanContext = <jk>new</jk> BeanContext().addPojoSwaps(DateSwap.ISO8601DT.<jk>class</jk>);
+	 * 	BeanContext beanContext = <jk>new</jk> BeanContext().pojoSwaps(DateSwap.ISO8601DT.<jk>class</jk>);
 	 *
 	 * 	<jc>// Wrap our bean in a bean map</jc>
 	 * 	BeanMap&lt;Person&gt; b = beanContext.forBean(p);
@@ -251,7 +251,7 @@ public class BeanMap<T> extends AbstractMap<String,Object> implements Delegate<T
 	 * 	p.setBirthDate(<jk>new</jk> Date(1, 2, 3, 4, 5, 6));
 	 *
 	 * 	<jc>// Create a bean context and add the ISO8601 date-time swap</jc>
-	 * 	BeanContext beanContext = <jk>new</jk> BeanContext().addPojoSwaps(DateSwap.ISO8601DT.<jk>class</jk>);
+	 * 	BeanContext beanContext = <jk>new</jk> BeanContext().pojoSwaps(DateSwap.ISO8601DT.<jk>class</jk>);
 	 *
 	 * 	<jc>// Wrap our bean in a bean map</jc>
 	 * 	BeanMap&lt;Person&gt; b = beanContext.forBean(p);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/95e832e1/juneau-core/src/main/java/org/apache/juneau/Context.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/Context.java b/juneau-core/src/main/java/org/apache/juneau/Context.java
index 6005ee9..d6912e7 100644
--- a/juneau-core/src/main/java/org/apache/juneau/Context.java
+++ b/juneau-core/src/main/java/org/apache/juneau/Context.java
@@ -19,14 +19,14 @@ import org.apache.juneau.serializer.*;
 /**
  * A reusable stateless thread-safe read-only configuration, typically used for creating one-time use {@link Session} objects.
  * <p>
- * Contexts are created through the {@link ContextFactory#getContext(Class)} method.
+ * Contexts are created through the {@link PropertyStore#getContext(Class)} method.
  * <p>
- * Subclasses MUST implement a constructor method that takes in a {@link ContextFactory} parameter.
+ * Subclasses MUST implement a constructor method that takes in a {@link PropertyStore} parameter.
  * Besides that restriction, a context object can do anything you desire.  However, it MUST
  * 	be thread-safe and all fields should be declared final to prevent modification.
  * It should NOT be used for storing temporary or state information.
  *
- * @see ContextFactory
+ * @see PropertyStore
  */
 public abstract class Context {
 
@@ -35,9 +35,9 @@ public abstract class Context {
 	 * <p>
 	 * Subclasses MUST implement the same constructor.
 	 *
-	 * @param configFactory The factory that created this config.
+	 * @param propertyStore The factory that created this config.
 	 */
-	public Context(ContextFactory configFactory) {}
+	public Context(PropertyStore propertyStore) {}
 
 	/**
 	 * Returns the properties defined on this bean context as a simple map for debugging purposes.


Mime
View raw message