Repository: incubator-juneau
Updated Branches:
  refs/heads/master e1c60b101 -> eac396dba


Make _class property configurable through new BEAN_typePropertyName
setting.

Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/eac396db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/eac396db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/eac396db

Branch: refs/heads/master
Commit: eac396dbab5228de52e8debe526470886baec225
Parents: e1c60b1
Author: jamesbognar <[email protected]>
Authored: Wed Sep 7 21:30:16 2016 -0400
Committer: jamesbognar <[email protected]>
Committed: Wed Sep 7 21:30:16 2016 -0400

----------------------------------------------------------------------
 .../java/org/apache/juneau/BeanContext.java     | 17 +++++
 .../main/java/org/apache/juneau/BeanMeta.java   |  8 +-
 .../main/java/org/apache/juneau/ObjectMap.java  | 38 +++++-----
 .../java/org/apache/juneau/TypeDictionary.java  |  2 +-
 .../java/org/apache/juneau/annotation/Bean.java |  9 +--
 .../java/org/apache/juneau/html/HtmlParser.java |  8 +-
 .../org/apache/juneau/html/HtmlSerializer.java  |  7 +-
 .../java/org/apache/juneau/json/JsonParser.java | 12 +--
 .../org/apache/juneau/json/JsonSerializer.java  |  5 +-
 .../apache/juneau/msgpack/MsgPackParser.java    |  6 +-
 .../juneau/msgpack/MsgPackSerializer.java       |  6 +-
 .../java/org/apache/juneau/parser/Parser.java   |  5 +-
 .../juneau/serializer/SerializerContext.java    |  4 +-
 .../juneau/serializer/SerializerSession.java    |  2 +-
 .../juneau/transforms/CalendarMapSwap.java      |  4 +-
 .../apache/juneau/urlencoding/UonParser.java    | 20 ++---
 .../juneau/urlencoding/UonSerializer.java       |  5 +-
 .../juneau/urlencoding/UrlEncodingParser.java   | 12 +--
 .../urlencoding/UrlEncodingSerializer.java      |  2 +-
 .../java/org/apache/juneau/xml/XmlParser.java   |  4 +-
 .../apache/juneau/xml/XmlSchemaSerializer.java  |  3 +-
 .../org/apache/juneau/xml/XmlSerializer.java    |  2 +-
 .../java/org/apache/juneau/BeanMapTest.java     | 80 ++++++++++----------
 .../java/org/apache/juneau/json/JsonTest.java   |  2 +-
 .../org/apache/juneau/utils/PojoRestTest.java   |  4 +-
 25 files changed, 147 insertions(+), 120 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/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 7067840..d90936f 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
@@ -462,6 +462,11 @@ public class BeanContext extends Context {
        public static final String BEAN_typeDictionary_remove = 
"BeanContext.typeDictionary.list.remove";
 
        /**
+        * The name to use for the type property used to represent a bean type. 
 ({@link String}, default=<js>"_type"</js>).
+        */
+       public static final String BEAN_typePropertyName = 
"BeanContext.typePropertyName";
+
+       /**
         * Specifies the default parser to use when converting 
<code>Strings</code> to POJOs in the {@link BeanContext#convertToType(Object, 
Class)} method (<code>Class</code>).
         */
        public static final String BEAN_defaultParser = 
"BeanContext.defaultParser";
@@ -553,6 +558,8 @@ public class BeanContext extends Context {
        // Optional default parser set by setDefaultParser().
        final ReaderParser defaultParser;
 
+       final String typePropertyName;
+
        // Holds pending ClassMetas (created, but not yet initialized).
        final Deque<ClassMeta> pendingClassMetas = new LinkedList<ClassMeta>();
 
@@ -586,6 +593,7 @@ public class BeanContext extends Context {
                ignoreInvocationExceptionsOnSetters = 
pm.get(BEAN_ignoreInvocationExceptionsOnSetters, boolean.class, false);
                useJavaBeanIntrospector = pm.get(BEAN_useJavaBeanIntrospector, 
boolean.class, false);
                sortProperties = pm.get(BEAN_sortProperties, boolean.class, 
false);
+               typePropertyName = pm.get(BEAN_typePropertyName, String.class, 
"_type");
 
                beanConstructorVisibility = 
pm.get(BEAN_beanConstructorVisibility, Visibility.class, PUBLIC);
                beanClassVisibility = pm.get(BEAN_beanClassVisibility, 
Visibility.class, PUBLIC);
@@ -1475,6 +1483,15 @@ public class BeanContext extends Context {
        }
 
        /**
+        * Returns the type property name as defined by {@link 
BeanContext#BEAN_typePropertyName}.
+        *
+        * @return The type property name.  Never <jk>null</jk>.
+        */
+       public final String getTypePropertyName() {
+               return typePropertyName;
+       }
+
+       /**
         * Returns the type dictionary defined in this bean context defined by 
{@link BeanContext#BEAN_typeDictionary}.
         *
         * @return The type dictionary defined in this bean context.  Never 
<jk>null</jk>.

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java 
b/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java
index 41a8e88..395c323 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanMeta.java
@@ -2,7 +2,7 @@
 // * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
 // * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
 // * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              * 
+// * with the License.  You may obtain a copy of the License at                
                                              *
 // *                                                                           
                                              *
 // *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
 // *                                                                           
                                              *
@@ -94,7 +94,7 @@ public class BeanMeta<T> {
 
        // Other fields
        final BeanPropertyMeta subTypeIdProperty;                           // 
The property indentified as the sub type differentiator property (identified by 
@Bean.subTypeProperty annotation).
-       private final BeanPropertyMeta classProperty;                       // 
"_class" mock bean property.
+       private final BeanPropertyMeta classProperty;                       // 
"_type" mock bean property.
 
        final String notABeanReason;
 
@@ -123,7 +123,7 @@ public class BeanMeta<T> {
                this.constructorArgs = b.constructorArgs;
                this.extMeta = b.extMeta;
                this.subTypeIdProperty = b.subTypeIdProperty;
-               this.classProperty = new BeanPropertyMeta(this, "_class", 
ctx.string());
+               this.classProperty = new BeanPropertyMeta(this, 
ctx.getTypePropertyName(), ctx.string());
        }
 
 
@@ -438,7 +438,7 @@ public class BeanMeta<T> {
        }
 
        /**
-        * Returns a mock bean property that resolves to the name 
<js>"_class"</js> and whose value always resolves
+        * Returns a mock bean property that resolves to the name 
<js>"_type"</js> and whose value always resolves
         *      to the class name of the bean.
         *
         * @return The class name property.

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/ObjectMap.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/ObjectMap.java 
b/juneau-core/src/main/java/org/apache/juneau/ObjectMap.java
index 5162895..ce047c7 100644
--- a/juneau-core/src/main/java/org/apache/juneau/ObjectMap.java
+++ b/juneau-core/src/main/java/org/apache/juneau/ObjectMap.java
@@ -1063,7 +1063,7 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
        }
 
        /**
-        * Converts this map into the class type specified by the 
<js>"_class"</js> entry value.
+        * Converts this map into the class type specified by the 
<js>"_type"</js> entry value.
         * <p>
         *      This method can be used to convert <code>ObjectMap</code> 
objects to a variety of POJO types.
         *
@@ -1075,7 +1075,7 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
         *              </p>
         *              <p class='bcode'>
         *      {
-        *              _class: <js>'com.ibm.sample.addressBook.Person'</js>,
+        *              _type: <js>'com.ibm.sample.addressBook.Person'</js>,
         *              name: <js>'John Smith'</js>,
         *              ...
         *      }
@@ -1086,13 +1086,13 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
         *              <p class='bcode'>
         *      <jc>// Generic TreeMap (String keys, Object values)</jc>
         *      {
-        *              _class: <js>'java.util.TreeMap'</js>,
+        *              _type: <js>'java.util.TreeMap'</js>,
         *              name: <js>'John Smith'</js>,
         *              ...
         *      }
         *      <jc>// TreeMap where values are forced to be strings.</jc>
         *      {
-        *              _class: 
<js>'java.util.TreeMap&lt;java.lang.String,java.lang.String&gt;'</js>,
+        *              _type: 
<js>'java.util.TreeMap&lt;java.lang.String,java.lang.String&gt;'</js>,
         *              name: <js>'John Smith'</js>,
         *              ...
         *      }
@@ -1103,12 +1103,12 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
         *              <p class='bcode'>
         *      <jc>// LinkedList of strings</jc>
         *      {
-        *              _class: <js>'java.util.LinkedList'</js>,
+        *              _type: <js>'java.util.LinkedList'</js>,
         *              items: [ <js>'John Smith'</js>, ... ]
         *      }
         *      <jc>// LinkedList of beans</jc>
         *      {
-        *              _class: 
<js>'java.util.LinkedList&lt;com.ibm.sample.addressBook.Person&gt;'</js>,
+        *              _type: 
<js>'java.util.LinkedList&lt;com.ibm.sample.addressBook.Person&gt;'</js>,
         *              items: [ { name: <js>'John Smith'</js>, ... }, ... ]
         *      }
         *              </p>
@@ -1118,12 +1118,12 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
         *              <p class='bcode'>
         *      <jc>// Array of strings</jc>
         *      {
-        *              _class: <js>'java.lang.String[]'</js>,
+        *              _type: <js>'java.lang.String[]'</js>,
         *              items: [ <js>'John Smith'</js>, ... ]
         *      }
         *      <jc>// Array of beans</jc>
         *      {
-        *              _class: <js>'com.ibm.sample.addressBook.Person[]'</js>,
+        *              _type: <js>'com.ibm.sample.addressBook.Person[]'</js>,
         *              items: [ { name: <js>'John Smith'</js>, ... }, ... ]
         *      }
         *              </p>
@@ -1133,7 +1133,7 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
         *                      For example, if the bean context has a {@link 
CalendarSwap} associated with it, it can convert a string value to a calendar.
         *              <p class='bcode'>
         *      {
-        *              _class: <js>'java.util.GregorianCalendar'</js>,
+        *              _type: <js>'java.util.GregorianCalendar'</js>,
         *              value: <js>'2001-07-04T15:30:45-05:00'</js>
         *      }
         *              </p>
@@ -1158,11 +1158,11 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
         *
         * @param typeDictionary
         *      The class lexicon to resolve the name.  Can be <jk>null</jk>.
-        * @return The new Java object of type specified by the 
<js>"_class"</js> entry value, or this
+        * @return The new Java object of type specified by the 
<js>"_type"</js> entry value, or this
         *      same object if entry does not exist.
         */
        public Object cast(TypeDictionary typeDictionary) {
-               String c = (String)get("_class");
+               String c = (String)get(beanContext.getTypePropertyName());
                if (c == null) {
                        if (containsKey("_value"))
                                return get("_value");
@@ -1181,18 +1181,18 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
         * <p>
         * The rules are the same as those specified in {@link #cast()}.
         * <p>
-        * If this map contains a <js>"_class"</js> entry, it must be the same 
as or a subclass
+        * If this map contains a <js>"_type"</js> entry, it must be the same 
as or a subclass
         *      of the <code>type</code>.
         *
         * @param <T> The class type to convert this map object to.
         * @param type The class type to convert this map object to.
         * @return The new object.
-        * @throws ClassCastException If the <js>"_class"</js> entry is present 
and not assignable
+        * @throws ClassCastException If the <js>"_type"</js> entry is present 
and not assignable
         *      from <code>type</code>
         */
        @SuppressWarnings("unchecked")
        public <T> T cast(Class<T> type) {
-               ClassMeta<?> c1 = 
beanContext.getClassMetaFromString((String)get("_class"));
+               ClassMeta<?> c1 = 
beanContext.getClassMetaFromString((String)get(beanContext.getTypePropertyName()));
                ClassMeta<?> c2 = beanContext.getClassMeta(type);
                ClassMeta<?> c = narrowClassMeta(c1, c2);
                return (T)cast2(c);
@@ -1204,18 +1204,18 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
         * @param <T> The class type to convert this map object to.
         * @param cm The class type to convert this map object to.
         * @return The new object.
-        * @throws ClassCastException If the <js>"_class"</js> entry is present 
and not assignable
+        * @throws ClassCastException If the <js>"_type"</js> entry is present 
and not assignable
         *      from <code>type</code>
         */
        @SuppressWarnings({"unchecked"})
        public <T> T cast(ClassMeta<T> cm) {
-               ClassMeta<?> c1 = 
beanContext.getClassMetaFromString((String)get("_class"));
+               ClassMeta<?> c1 = 
beanContext.getClassMetaFromString((String)get(beanContext.getTypePropertyName()));
                ClassMeta<?> c = narrowClassMeta(c1, cm);
                return (T)cast2(c);
        }
 
        /*
-        * Combines the class specified by a "_class" attribute with the 
ClassMeta
+        * Combines the class specified by a "_type" attribute with the 
ClassMeta
         * passed in through the cast(ClassMeta) method.
         * The rule is that child classes superceed parent classes, and c2 
superceeds c1
         * if one isn't the parent of another.
@@ -1262,7 +1262,7 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
                                for (Map.Entry<String,Object> e : entrySet()) {
                                        Object k = e.getKey();
                                        Object v = e.getValue();
-                                       if (! k.equals("_class")) {
+                                       if (! 
k.equals(beanContext.getTypePropertyName())) {
 
                                                // Attempt to recursively cast 
child maps.
                                                if (v instanceof ObjectMap)
@@ -1283,7 +1283,7 @@ public class ObjectMap extends 
LinkedHashMap<String,Object> {
                                for (Map.Entry<String,Object> e : entrySet()) {
                                        String k = e.getKey();
                                        Object v = e.getValue();
-                                       if (! k.equals("_class")) {
+                                       if (! 
k.equals(beanContext.getTypePropertyName())) {
 
                                                // Attempt to recursively cast 
child maps.
                                                if (v instanceof ObjectMap)

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/TypeDictionary.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/TypeDictionary.java 
b/juneau-core/src/main/java/org/apache/juneau/TypeDictionary.java
index 0107267..45488ad 100644
--- a/juneau-core/src/main/java/org/apache/juneau/TypeDictionary.java
+++ b/juneau-core/src/main/java/org/apache/juneau/TypeDictionary.java
@@ -31,7 +31,7 @@ import org.apache.juneau.internal.*;
  * <p>
  * The dictionary is used by the framework in the following ways:
  * <ul>
- *     <li>If a class type cannot be inferred through reflection during 
parsing, then a helper <js>"_class"</js> is added to the serialized output
+ *     <li>If a class type cannot be inferred through reflection during 
parsing, then a helper <js>"_type"</js> is added to the serialized output
  *             using the name defined for that class in this dictionary.  This 
helps determine the real class at parse time.
  *     <li>The dictionary name is used as element names when serialized to XML.
  * </ul>

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/annotation/Bean.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/annotation/Bean.java 
b/juneau-core/src/main/java/org/apache/juneau/annotation/Bean.java
index f2859f1..e914e6c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/annotation/Bean.java
+++ b/juneau-core/src/main/java/org/apache/juneau/annotation/Bean.java
@@ -204,21 +204,20 @@ public @interface Bean {
         *      <jc>// Abstract superclass</jc>
         *      <ja>@Bean</ja>(
         *              subTypeProperty=<js>"subType"</js>,
-        *              subTypes={
-        *                      <ja>@BeanSubType</ja>(type=A1.<jk>class</jk>, 
id=<js>"A1"</js>),
-        *                      <ja>@BeanSubType</ja>(type=A2.<jk>class</jk>, 
id=<js>"A2"</js>)
-        *              }
+        *              subTypes={A1.class, A2.class}
         *      )
         *      <jk>public class</jk> A {
         *              <jk>public</jk> String <jf>f0</jf> = <js>"f0"</js>;
         *      }
         *
         *      <jc>// Subclass 1</jc>
+        *      <ja>@Bean</ja>(typeName=<js>"A1"</js>)
         *      <jk>public class</jk> A1 <jk>extends</jk> A {
         *              <jk>public</jk> String <jf>f1</jf>;
         *      }
         *
         *      <jc>// Subclass 2</jc>
+        *      <ja>@Bean</ja>(typeName=<js>"A2"</js>)
         *      <jk>public class</jk> A2 <jk>extends</jk> A {
         *              <jk>public</jk> String <jf>f2</jf>;
         *      }
@@ -242,7 +241,7 @@ public @interface Bean {
         * <p>
         *      This annotation is an alternative to using the {@link 
BeanFilter} class with an implemented {@link BeanFilter#getSubTypeProperty()} 
method.
         */
-       String subTypeProperty() default "_class";
+       String subTypeProperty() default "_subtype";
 
        /**
         * Used in conjunction with {@link #subTypeProperty()} to set up bean 
subtypes.

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java 
b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
index 4fefe0e..0611830 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
@@ -2,7 +2,7 @@
 // * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
 // * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
 // * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              * 
+// * with the License.  You may obtain a copy of the License at                
                                              *
 // *                                                                           
                                              *
 // *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
 // *                                                                           
                                              *
@@ -115,7 +115,7 @@ public final class HtmlParser extends ReaderParser {
                        if (tag == TABLE) {
                                Map<String,String> attrs = getAttributes(event);
                                tableType = attrs.get("type");
-                               String c = attrs.get("_class");
+                               String c = attrs.get(bc.getTypePropertyName());
                                if (c != null)
                                        sType = eType = 
(ClassMeta<T>)bc.getClassMetaFromString(c);
                        }
@@ -348,7 +348,7 @@ public final class HtmlParser extends ReaderParser {
                                }
                                l.add(m == null ? null : (E)m.getBean());
                        } else {
-                               String c = getAttributes(event).get("_class");
+                               String c = 
getAttributes(event).get(bc.getTypePropertyName());
                                Map m = (Map)(elementType.isMap() && 
elementType.canCreateNewInstance(l) ? elementType.newInstance(l) : new 
ObjectMap(bc));
                                for (int i = 0; i < keys.size(); i++) {
                                        tag = nextTag(r, TD, NULL);
@@ -368,7 +368,7 @@ public final class HtmlParser extends ReaderParser {
                                }
                                if (m != null && c != null) {
                                        ObjectMap m2 = (m instanceof ObjectMap 
? (ObjectMap)m : new ObjectMap(m).setBeanContext(session.getBeanContext()));
-                                       m2.put("_class", c);
+                                       m2.put(bc.getTypePropertyName(), c);
                                        l.add((E)m2.cast());
                                } else {
                                        l.add((E)m);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java 
b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
index 4cfaf89..394b10e 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializer.java
@@ -321,6 +321,7 @@ public class HtmlSerializer extends XmlSerializer {
 
        private void serializeBeanMap(HtmlSerializerSession session, HtmlWriter 
out, BeanMap<?> m, String classAttr, BeanPropertyMeta ppMeta) throws Exception {
                int i = session.getIndent();
+               BeanContext bc = session.getBeanContext();
 
                Object o = m.getBean();
 
@@ -335,7 +336,7 @@ public class HtmlSerializer extends XmlSerializer {
 
                out.oTag(i, "table").attr("type", "object");
                if (classAttr != null)
-                       out.attr("_class", classAttr);
+                       out.attr(bc.getTypePropertyName(), classAttr);
                out.append('>').nl();
                if (! 
(m.getClassMeta().getExtendedMeta(HtmlClassMeta.class).isNoTableHeaders() || 
(ppMeta != null && 
ppMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).isNoTableHeaders()))) {
                        out.sTag(i+1, "tr").nl();
@@ -400,7 +401,7 @@ public class HtmlSerializer extends XmlSerializer {
 
                        out.oTag(i, "table").attr("type", "array");
                        if (classAttr != null)
-                               out.attr("_class", classAttr);
+                               out.attr(bc.getTypePropertyName(), classAttr);
                        out.append('>').nl();
                        out.sTag(i+1, "tr").nl();
                        for (String key : th)
@@ -417,7 +418,7 @@ public class HtmlSerializer extends XmlSerializer {
                                }
 
                                if (cm != null && session.isAddClassAttrs() && 
elementType.getInnerClass() != o.getClass())
-                                       out.oTag(i+1, "tr").attr("_class", 
o.getClass().getName()).append('>').nl();
+                                       out.oTag(i+1, 
"tr").attr(bc.getTypePropertyName(), o.getClass().getName()).append('>').nl();
                                else
                                        out.sTag(i+1, "tr").nl();
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java 
b/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java
index 5859825..b4c4570 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java
@@ -2,7 +2,7 @@
 // * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
 // * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
 // * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              * 
+// * with the License.  You may obtain a copy of the License at                
                                              *
 // *                                                                           
                                              *
 // *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
 // *                                                                           
                                              *
@@ -51,7 +51,7 @@ import org.apache.juneau.transform.*;
  *     This parser handles the following input, and automatically returns the 
corresponding Java class.
  *     <ul class='spaced-list'>
  *             <li> JSON objects (<js>"{...}"</js>) are converted to {@link 
ObjectMap ObjectMaps}.  <br>
- *                             Note:  If a 
<code><xa>_class</xa>=<xs>'xxx'</xs></code> attribute is specified on the 
object, then an attempt is made to convert the object
+ *                             Note:  If a 
<code><xa>_type</xa>=<xs>'xxx'</xs></code> attribute is specified on the 
object, then an attempt is made to convert the object
  *                             to an instance of the specified Java bean 
class.  See the classProperty setting on the {@link ContextFactory} for more 
information
  *                             about parsing beans from JSON.
  *             <li> JSON arrays (<js>"[...]"</js>) are converted to {@link 
ObjectList ObjectLists}.
@@ -65,7 +65,7 @@ import org.apache.juneau.transform.*;
  * <p>
  *     Input can be any of the following:<br>
  *     <ul class='spaced-list'>
- *             <li> <js>"{...}"</js> - Converted to a {@link ObjectMap} or an 
instance of a Java bean if a <xa>_class</xa> attribute is present.
+ *             <li> <js>"{...}"</js> - Converted to a {@link ObjectMap} or an 
instance of a Java bean if a <xa>_type</xa> attribute is present.
  *             <li> <js>"[...]"</js> - Converted to a {@link ObjectList}.
  *             <li> <js>"123..."</js> - Converted to a {@link Number} (either 
{@link Integer}, {@link Long}, {@link Float}, or {@link Double}).
  *             <li> <js>"true"</js>/<js>"false"</js> - Converted to a {@link 
Boolean}.
@@ -188,7 +188,7 @@ public final class JsonParser extends ReaderParser {
                } else if (c == '{') {
                        Map m = new ObjectMap(bc);
                        parseIntoMap2(session, r, m, sType.getKeyType(), 
sType.getValueType());
-                       if (m.containsKey("_class"))
+                       if (m.containsKey(bc.getTypePropertyName()))
                                o = ((ObjectMap)m).cast();
                        else
                                throw new ParseException(session, "Class 
''{0}'' could not be instantiated.  Reason: ''{1}''", 
sType.getInnerClass().getName(), sType.getNotABeanReason());
@@ -425,6 +425,8 @@ public final class JsonParser extends ReaderParser {
 
        private <T> BeanMap<T> parseIntoBeanMap2(JsonParserSession session, 
ParserReader r, BeanMap<T> m) throws Exception {
 
+               BeanContext bc = session.getBeanContext();
+
                int S0=0; // Looking for outer {
                int S1=1; // Looking for attrName start.
                int S3=3; // Found attrName end, looking for :.
@@ -459,7 +461,7 @@ public final class JsonParser extends ReaderParser {
                                if (c == '/') {
                                        skipCommentsAndSpace(session, 
r.unread());
                                } else if (! Character.isWhitespace(c)) {
-                                       if (! currAttr.equals("_class")) {
+                                       if (! 
currAttr.equals(bc.getTypePropertyName())) {
                                                BeanPropertyMeta pMeta = 
m.getPropertyMeta(currAttr);
                                                
session.setCurrentProperty(pMeta);
                                                if (pMeta == null) {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java 
b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
index 0493780..4f9b5c9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java
@@ -171,7 +171,7 @@ public class JsonSerializer extends WriterSerializer {
                if (eType == null)
                        eType = object();
 
-               boolean addClassAttr;           // Add "_class" attribute to 
element?
+               boolean addClassAttr;           // Add "_type" attribute to 
element?
                ClassMeta<?> aType;                     // The actual type
                ClassMeta<?> sType;                     // The serialized type
 
@@ -279,9 +279,10 @@ public class JsonSerializer extends WriterSerializer {
 
        @SuppressWarnings({ "rawtypes" })
        private SerializerWriter serializeCollectionMap(JsonSerializerSession 
session, JsonWriter out, Collection o, ClassMeta<?> type) throws Exception {
+               BeanContext bc = session.getBeanContext();
                int i = session.getIndent();
                out.append('{');
-               
out.cr(i).attr("_class").append(':').s().q().append(type.getInnerClass().getName()).q().append(',').s();
+               
out.cr(i).attr(bc.getTypePropertyName()).append(':').s().q().append(type.getInnerClass().getName()).q().append(',').s();
                out.cr(i).attr("items").append(':').s();
                session.indent++;
                serializeCollection(session, out, o, type);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java 
b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
index 81b2547..e366567 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
@@ -2,7 +2,7 @@
 // * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
 // * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
 // * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              * 
+// * with the License.  You may obtain a copy of the License at                
                                              *
 // *                                                                           
                                              *
 // *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
 // *                                                                           
                                              *
@@ -121,7 +121,7 @@ public final class MsgPackParser extends InputStreamParser {
                                                String pName = 
parseAnything(session, string(), is, m.getBean(false));
                                                BeanPropertyMeta bpm = 
m.getPropertyMeta(pName);
                                                if (bpm == null) {
-                                                       if 
(pName.equals("_class"))
+                                                       if 
(pName.equals(bc.getTypePropertyName()))
                                                                
parseAnything(session, bc.string(), is, null);
                                                        else
                                                                
onUnknownProperty(session, pName, m, 0, is.getPosition());
@@ -172,7 +172,7 @@ public final class MsgPackParser extends InputStreamParser {
                                ObjectMap m = new ObjectMap(bc);
                                for (int i = 0; i < length; i++)
                                        m.put(parseAnything(session, string(), 
is, outer), parseAnything(session, object(), is, m));
-                               if (m.containsKey("_class"))
+                               if (m.containsKey(bc.getTypePropertyName()))
                                        o = m.cast();
                                else
                                        throw new ParseException(session, 
"Class ''{0}'' could not be instantiated.  Reason: ''{1}''", 
sType.getInnerClass().getName(), sType.getNotABeanReason());

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java 
b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
index b60b992..681b883 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializer.java
@@ -61,7 +61,7 @@ public class MsgPackSerializer extends OutputStreamSerializer 
{
                if (eType == null)
                        eType = object();
 
-               boolean addClassAttr;           // Add "_class" attribute to 
element?
+               boolean addClassAttr;           // Add "_type" attribute to 
element?
                ClassMeta<?> aType;                     // The actual type
                ClassMeta<?> sType;                     // The serialized type
 
@@ -152,9 +152,9 @@ public class MsgPackSerializer extends 
OutputStreamSerializer {
 
        @SuppressWarnings({ "rawtypes" })
        private void serializeCollectionMap(MsgPackSerializerSession session, 
MsgPackOutputStream out, Collection o, ClassMeta<?> type) throws Exception {
-
+               BeanContext bc = session.getBeanContext();
                out.startMap(2);
-               serializeAnything(session, out, "_class", null, null, null);
+               serializeAnything(session, out, bc.getTypePropertyName(), null, 
null, null);
                serializeAnything(session, out, type.getInnerClass().getName(), 
null, null, null);
                serializeAnything(session, out, "items", null, null, null);
                serializeCollection(session, out, o, type);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java 
b/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
index c3c6b30..5c5e2f2 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/Parser.java
@@ -2,7 +2,7 @@
 // * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
 // * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
 // * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              * 
+// * with the License.  You may obtain a copy of the License at                
                                              *
 // *                                                                           
                                              *
 // *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
 // *                                                                           
                                              *
@@ -650,7 +650,8 @@ public abstract class Parser extends CoreApi {
         * @param <T> The class type of the bean map that doesn't have the 
expected property.
         */
        protected <T> void onUnknownProperty(ParserSession session, String 
propertyName, BeanMap<T> beanMap, int line, int col) throws ParseException {
-               if (propertyName.equals("uri") || propertyName.equals("type") 
|| propertyName.equals("_class"))
+               BeanContext bc = session.getBeanContext();
+               if (propertyName.equals("uri") || propertyName.equals("type") 
|| propertyName.equals(bc.getTypePropertyName()))
                        return;
                if (! session.getBeanContext().isIgnoreUnknownBeanProperties())
                        throw new ParseException(session, "Unknown property 
''{0}'' encountered while trying to parse into class ''{1}''", propertyName, 
beanMap.getClassMeta());

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java 
b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
index 6144d35..0608d4c 100644
--- 
a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
+++ 
b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
@@ -2,7 +2,7 @@
 // * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
 // * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
 // * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              * 
+// * with the License.  You may obtain a copy of the License at                
                                              *
 // *                                                                           
                                              *
 // *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
 // *                                                                           
                                              *
@@ -90,7 +90,7 @@ public class SerializerContext extends Context {
        /**
         * Add class attributes to output ({@link Boolean}, 
default=<jk>false</jk>).
         * <p>
-        * If <jk>true</jk>, then <js>"_class"</js> attributes will be added to 
beans if their type cannot be inferred through reflection.
+        * If <jk>true</jk>, then <js>"_type"</js> attributes will be added to 
beans if their type cannot be inferred through reflection.
         * This is used to recreate the correct objects during parsing if the 
object types cannot be inferred.
         * For example, when serializing a {@code Map<String,Object>} field, 
where the bean class cannot be determined from the value type.
         */

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java 
b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
index ce423cc..ede6331 100644
--- 
a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
+++ 
b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
@@ -742,7 +742,7 @@ public class SerializerSession extends Session {
        }
 
        /**
-        * Create a "_class" property that represents the name of the bean.
+        * Create a "_type" property that represents the name of the bean.
         *
         * @param m
         *      The bean map to create a class property on.

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java 
b/juneau-core/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java
index 50f2452..d223ef5 100644
--- 
a/juneau-core/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java
+++ 
b/juneau-core/src/main/java/org/apache/juneau/transforms/CalendarMapSwap.java
@@ -2,7 +2,7 @@
 // * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
 // * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
 // * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              * 
+// * with the License.  You may obtain a copy of the License at                
                                              *
 // *                                                                           
                                              *
 // *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
 // *                                                                           
                                              *
@@ -19,7 +19,7 @@ import org.apache.juneau.parser.*;
 import org.apache.juneau.transform.*;
 
 /**
- * Transforms {@link Calendar Calendars} to {@link Map Maps} of the format 
<code>{_class:String,value:long}</code>.
+ * Transforms {@link Calendar Calendars} to {@link Map Maps} of the format 
<code>{time:long,timeZone:string}</code>.
  *
  * @author James Bognar ([email protected])
  */

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParser.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParser.java 
b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParser.java
index 6dcb026..4e85745 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParser.java
@@ -2,7 +2,7 @@
 // * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
 // * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
 // * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              * 
+// * with the License.  You may obtain a copy of the License at                
                                              *
 // *                                                                           
                                              *
 // *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
 // *                                                                           
                                              *
@@ -145,8 +145,8 @@ public class UonParser extends ReaderParser {
                        if (flag == 'o') {
                                ObjectMap m = new ObjectMap(bc);
                                parseIntoMap(session, r, m, string(), object());
-                               // Handle case where it's a collection, but 
serialized as a map with a _class or _value key.
-                               if (m.containsKey("_class") || 
m.containsKey("_value"))
+                               // Handle case where it's a collection, but 
serialized as a map with a _type or _value key.
+                               if (m.containsKey(bc.getTypePropertyName()) || 
m.containsKey("_value"))
                                        o = m.cast();
                                // Handle case where it's a collection, but 
only a single value was specified.
                                else {
@@ -176,8 +176,8 @@ public class UonParser extends ReaderParser {
                        if (flag == 'o') {
                                ObjectMap m = new ObjectMap(bc);
                                parseIntoMap(session, r, m, string(), object());
-                               // Handle case where it's an array, but 
serialized as a map with a _class or _value key.
-                               if (m.containsKey("_class") || 
m.containsKey("_value"))
+                               // Handle case where it's an array, but 
serialized as a map with a _type or _value key.
+                               if (m.containsKey(bc.getTypePropertyName()) || 
m.containsKey("_value"))
                                        o = m.cast();
                                // Handle case where it's an array, but only a 
single value was specified.
                                else {
@@ -190,10 +190,10 @@ public class UonParser extends ReaderParser {
                                o = bc.toArray(sType, l);
                        }
                } else if (flag == 'o') {
-                       // It could be a non-bean with _class attribute.
+                       // It could be a non-bean with _type attribute.
                        ObjectMap m = new ObjectMap(bc);
                        parseIntoMap(session, r, m, string(), object());
-                       if (m.containsKey("_class"))
+                       if (m.containsKey(bc.getTypePropertyName()))
                                o = m.cast();
                        else
                                throw new ParseException(session, "Class 
''{0}'' could not be instantiated.  Reason: ''{1}''", 
sType.getInnerClass().getName(), sType.getNotABeanReason());
@@ -375,6 +375,8 @@ public class UonParser extends ReaderParser {
 
        private <T> BeanMap<T> parseIntoBeanMap(UonParserSession session, 
ParserReader r, BeanMap<T> m) throws Exception {
 
+               BeanContext bc = session.getBeanContext();
+
                int c = r.read();
                if (c == -1 || c == NUL || c == AMP)
                        return null;
@@ -419,7 +421,7 @@ public class UonParser extends ReaderParser {
                                        }
                                } else if (state == S3) {
                                        if (c == -1 || c == ',' || c == ')' || 
c == AMP) {
-                                               if (! 
currAttr.equals("_class")) {
+                                               if (! 
currAttr.equals(bc.getTypePropertyName())) {
                                                        BeanPropertyMeta pMeta 
= m.getPropertyMeta(currAttr);
                                                        if (pMeta == null) {
                                                                if 
(m.getMeta().isSubTyped()) {
@@ -436,7 +438,7 @@ public class UonParser extends ReaderParser {
                                                        return m;
                                                state = S1;
                                        } else {
-                                               if (! 
currAttr.equals("_class")) {
+                                               if (! 
currAttr.equals(bc.getTypePropertyName())) {
                                                        BeanPropertyMeta pMeta 
= m.getPropertyMeta(currAttr);
                                                        if (pMeta == null) {
                                                                if 
(m.getMeta().isSubTyped()) {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializer.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializer.java 
b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializer.java
index cb64be7..6edfb93 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializer.java
@@ -257,7 +257,7 @@ public class UonSerializer extends WriterSerializer {
                if (eType == null)
                        eType = object();
 
-               boolean addClassAttr;           // Add "_class" attribute to 
element?
+               boolean addClassAttr;           // Add "_type" attribute to 
element?
                ClassMeta<?> aType;                     // The actual type
                ClassMeta<?> sType;                     // The serialized type
 
@@ -351,9 +351,10 @@ public class UonSerializer extends WriterSerializer {
 
        @SuppressWarnings({ "rawtypes" })
        private SerializerWriter serializeCollectionMap(UonSerializerSession 
session, UonWriter out, Collection o, ClassMeta<?> type) throws Exception {
+               BeanContext bc = session.getBeanContext();
                int i = session.getIndent();
                out.startFlag('o').nl();
-               out.append(i, "_class=").appendObject(type, false, false, 
false).append(',').nl();
+               out.append(i, 
bc.getTypePropertyName()).append("=").appendObject(type, false, false, 
false).append(',').nl();
                out.append(i, "items=");
                session.indent++;
                serializeCollection(session, out, o, type);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
 
b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
index 285604d..c873567 100644
--- 
a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
+++ 
b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParser.java
@@ -2,7 +2,7 @@
 // * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
 // * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
 // * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              * 
+// * with the License.  You may obtain a copy of the License at                
                                              *
 // *                                                                           
                                              *
 // *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
 // *                                                                           
                                              *
@@ -99,11 +99,11 @@ public class UrlEncodingParser extends UonParser {
                        m = parseIntoBeanMap(session, r, m);
                        o = m == null ? null : m.getBean();
                } else {
-                       // It could be a non-bean with _class attribute.
+                       // It could be a non-bean with _type attribute.
                        ObjectMap m = new ObjectMap(bc);
                        ClassMeta<Object> valueType = object();
                        parseIntoMap(session, r, m, string(), valueType);
-                       if (m.containsKey("_class"))
+                       if (m.containsKey(bc.getTypePropertyName()))
                                o = m.cast();
                        else if (m.containsKey("_value"))
                                o = 
session.getBeanContext().convertToType(m.get("_value"), sType);
@@ -220,6 +220,8 @@ public class UrlEncodingParser extends UonParser {
 
        private <T> BeanMap<T> parseIntoBeanMap(UrlEncodingParserSession 
session, ParserReader r, BeanMap<T> m) throws Exception {
 
+               BeanContext bc = session.getBeanContext();
+
                int c = r.peek();
                if (c == -1)
                        return m;
@@ -258,7 +260,7 @@ public class UrlEncodingParser extends UonParser {
                                        }
                                } else if (state == S3) {
                                        if (c == -1 || c == '\u0001') {
-                                               if (! 
currAttr.equals("_class")) {
+                                               if (! 
currAttr.equals(bc.getTypePropertyName())) {
                                                        BeanPropertyMeta pMeta 
= m.getPropertyMeta(currAttr);
                                                        if (pMeta == null) {
                                                                if 
(m.getMeta().isSubTyped()) {
@@ -280,7 +282,7 @@ public class UrlEncodingParser extends UonParser {
                                                        return m;
                                                state = S1;
                                        } else {
-                                               if (! 
currAttr.equals("_class")) {
+                                               if (! 
currAttr.equals(bc.getTypePropertyName())) {
                                                        BeanPropertyMeta pMeta 
= m.getPropertyMeta(currAttr);
                                                        if (pMeta == null) {
                                                                if 
(m.getMeta().isSubTyped()) {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
 
b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
index 949863a..3d809c0 100644
--- 
a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
+++ 
b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java
@@ -228,7 +228,7 @@ public class UrlEncodingSerializer extends UonSerializer {
        private SerializerWriter serializeAnything(UrlEncodingSerializerSession 
session, UonWriter out, Object o) throws Exception {
                BeanContext bc = session.getBeanContext();
 
-               boolean addClassAttr;           // Add "_class" attribute to 
element?
+               boolean addClassAttr;           // Add "_type" attribute to 
element?
                ClassMeta<?> aType;                     // The actual type
                ClassMeta<?> sType;                     // The serialized type
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java 
b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
index d8e1e82..0ecc293 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java
@@ -2,7 +2,7 @@
 // * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
 // * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
 // * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              * 
+// * with the License.  You may obtain a copy of the License at                
                                              *
 // *                                                                           
                                              *
 // *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
 // *                                                                           
                                              *
@@ -86,7 +86,7 @@ public class XmlParser extends ReaderParser {
                                jsonType = getJsonType(elementName);
                }
                if (! sType.canCreateNewInstance(outer)) {
-                       String c = r.getAttributeValue(null, "_class");
+                       String c = r.getAttributeValue(null, 
bc.getTypePropertyName());
                        if (c != null) {
                                sType = eType = 
(ClassMeta<T>)bc.getClassMetaFromString(c);
                        }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java 
b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
index b3c311b..4b176fa 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSchemaSerializer.java
@@ -333,6 +333,7 @@ public class XmlSchemaSerializer extends XmlSerializer {
                        int i = session.getIndent() + 1;
 
                        cm = cm.getSerializedClassMeta();
+                       BeanContext bc = cm.getBeanContext();
 
                        w.oTag(i, "complexType")
                                .attr("name", name);
@@ -501,7 +502,7 @@ public class XmlSchemaSerializer extends XmlSerializer {
 
                                if (session.isAddClassAttrs()) {
                                        w.oTag(i+1, "attribute")
-                                               .attr("name", "_class")
+                                               .attr("name", 
bc.getTypePropertyName())
                                                .attr("type", "string")
                                                .ceTag().nl();
                                }

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java 
b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
index a381b41..bbcc052 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
@@ -430,7 +430,7 @@ public class XmlSerializer extends WriterSerializer {
                        if (elementName != null && session.isAddJsonTypeAttrs() 
&& (session.isAddJsonStringTypeAttrs() || ! ts.equals("string")))
                                out.attr(dns, "type", ts);
                        if (classAttr != null)
-                               out.attr(dns, "_class", classAttr);
+                               out.attr(dns, bc.getTypePropertyName(), 
classAttr);
                        if (o == null) {
                                if (! isNullTag)
                                        out.attr(xsi, "nil", "true");

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/test/java/org/apache/juneau/BeanMapTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/test/java/org/apache/juneau/BeanMapTest.java 
b/juneau-core/src/test/java/org/apache/juneau/BeanMapTest.java
index 6f1ebfc..df431d5 100755
--- a/juneau-core/src/test/java/org/apache/juneau/BeanMapTest.java
+++ b/juneau-core/src/test/java/org/apache/juneau/BeanMapTest.java
@@ -458,22 +458,22 @@ public class BeanMapTest {
                assertEquals("default", t.b.s);
 
                JsonParser p = new 
JsonParser().setClassLoader(BeanMapTest.class.getClassLoader());
-               m.put("lb1", new 
ObjectList("[{_class:'"+D2.class.getName()+"',s:'foobar'}]", p));
+               m.put("lb1", new 
ObjectList("[{_type:'"+D2.class.getName()+"',s:'foobar'}]", p));
                assertEquals(ObjectList.class.getName(), 
t.lb1.getClass().getName());
                assertEquals(D2.class.getName(), 
t.lb1.get(0).getClass().getName());
                assertEquals("foobar", (t.lb1.get(0)).s);
 
-               m.put("lb2", new 
ObjectList("[{_class:'"+D2.class.getName()+"',s:'foobar'}]", p));
+               m.put("lb2", new 
ObjectList("[{_type:'"+D2.class.getName()+"',s:'foobar'}]", p));
                assertEquals(ArrayList.class.getName(), 
t.lb2.getClass().getName());
                assertEquals(D2.class.getName(), 
t.lb2.get(0).getClass().getName());
                assertEquals("foobar", (t.lb2.get(0)).s);
 
-               m.put("ab1", new 
ObjectList("[{_class:'"+D2.class.getName()+"',s:'foobar'}]", p));
+               m.put("ab1", new 
ObjectList("[{_type:'"+D2.class.getName()+"',s:'foobar'}]", p));
                assertEquals("[L"+D2.class.getName()+";", 
t.ab1.getClass().getName());
                assertEquals(D2.class.getName(), t.ab1[0].getClass().getName());
                assertEquals("foobar", t.ab1[0].s);
 
-               m.put("ab2", new 
ObjectList("[{_class:'"+D2.class.getName()+"',s:'foobar'}]", p));
+               m.put("ab2", new 
ObjectList("[{_type:'"+D2.class.getName()+"',s:'foobar'}]", p));
                assertEquals("[L"+D2.class.getName()+";", 
t.ab2.getClass().getName());
                assertEquals(D2.class.getName(), t.ab2[0].getClass().getName());
                assertEquals("foobar", t.ab2[0].s);
@@ -644,7 +644,7 @@ public class BeanMapTest {
 
                // Create instance directly from JSON.
                JsonParser p = new 
JsonParser().setClassLoader(BeanMapTest.class.getClassLoader());
-               t7 = 
(H)p.parse("{_class:'"+H.class.getName()+"',enum1:'THREE',enum2:'ONE'}", 
Object.class);
+               t7 = 
(H)p.parse("{_type:'"+H.class.getName()+"',enum1:'THREE',enum2:'ONE'}", 
Object.class);
                assertEquals("{enum1:'THREE',enum2:'ONE'}", 
serializer.serialize(t7));
                assertEquals(HEnum.THREE, t7.enum1);
                assertEquals(HEnum.ONE, t7.getEnum2());
@@ -1117,9 +1117,9 @@ public class BeanMapTest {
        public void testCastWithNormalBean() throws Exception {
                BeanContext bc = getBeanContext();
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap(bc);
-               m.put("_class", R2.class.getName());
+               m.put("_type", R2.class.getName());
                m.put("f1", 1);
                m.put("f2", "2");
 
@@ -1134,7 +1134,7 @@ public class BeanMapTest {
                assertEquals(1, t.f1);
                assertEquals(2, t.f2);
 
-               // Without _class
+               // Without _type
                m = new ObjectMap(bc);
                m.put("f1", 1);
                m.put("f2", "2");
@@ -1168,10 +1168,10 @@ public class BeanMapTest {
        public void testCastWithNestedBean() throws Exception {
                BeanContext bc = getBeanContext();
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap(bc);
-               m.put("_class", S.class.getName());
-               m.put("f1", new ObjectMap(bc).append("_class", 
R1.class.getName()).append("f1", 1));
+               m.put("_type", S.class.getName());
+               m.put("f1", new ObjectMap(bc).append("_type", 
R1.class.getName()).append("f1", 1));
 
                S t = (S)m.cast();
                assertEquals(1, t.f1.f1);
@@ -1182,9 +1182,9 @@ public class BeanMapTest {
                t = m.cast(bc.getClassMeta(S.class));
                assertEquals(1, t.f1.f1);
 
-               // Without _class
+               // Without _type
                m = new ObjectMap(bc);
-               m.put("f1", new ObjectMap(bc).append("_class", 
R1.class.getName()).append("f1", 1));
+               m.put("f1", new ObjectMap(bc).append("_type", 
R1.class.getName()).append("f1", 1));
 
                m = (ObjectMap)m.cast();
                assertEquals(1, t.f1.f1);
@@ -1208,9 +1208,9 @@ public class BeanMapTest {
                BeanContext bc = BeanContext.DEFAULT;
                Map m2;
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap();
-               m.put("_class", TreeMap.class.getName());
+               m.put("_type", TreeMap.class.getName());
                m.put("1", "ONE");
 
                m2 = (Map)m.cast();
@@ -1246,7 +1246,7 @@ public class BeanMapTest {
                assertTrue(e.getValue() instanceof TEnum);
                assertEquals(TEnum.ONE, m2.get(1));
 
-               // Without _class
+               // Without _type
                m = new ObjectMap();
                m.put("1", "ONE");
 
@@ -1288,9 +1288,9 @@ public class BeanMapTest {
        public void testCastToLinkedList() throws Exception {
                BeanContext bc = BeanContext.DEFAULT;
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap();
-               m.put("_class", LinkedList.class.getName());
+               m.put("_type", LinkedList.class.getName());
                m.put("items", new ObjectList().append("1").append("2"));
 
                List l = (List)m.cast();
@@ -1309,7 +1309,7 @@ public class BeanMapTest {
                assertTrue(l instanceof ArrayList);
                assertEquals("1", l.get(0));
 
-               // Without _class
+               // Without _type
                m = new ObjectMap();
                m.put("items", new ObjectList().append("1").append("2"));
 
@@ -1342,9 +1342,9 @@ public class BeanMapTest {
        public void testToLinkedListInteger() throws Exception {
                BeanContext bc = BeanContext.DEFAULT;
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap();
-               m.put("_class", LinkedList.class.getName() + 
"<java.lang.Integer>");
+               m.put("_type", LinkedList.class.getName() + 
"<java.lang.Integer>");
                m.put("items", new ObjectList().append("1").append("2"));
 
                List l = (List)m.cast();
@@ -1372,7 +1372,7 @@ public class BeanMapTest {
                assertTrue(l.get(0) instanceof String);
                assertEquals("1", l.get(0));
 
-               // Without _class
+               // Without _type
                m = new ObjectMap();
                m.put("items", new ObjectList().append("1").append("2"));
 
@@ -1405,9 +1405,9 @@ public class BeanMapTest {
        public void testCastToLinkedListBean() throws Exception {
                BeanContext bc = getBeanContext();
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap(bc);
-               m.put("_class", LinkedList.class.getName() + 
"<"+R1.class.getName()+">");
+               m.put("_type", LinkedList.class.getName() + 
"<"+R1.class.getName()+">");
                m.put("items", new ObjectList(bc).append("{f1:1}"));
 
                List l = (List)m.cast();
@@ -1440,7 +1440,7 @@ public class BeanMapTest {
                assertTrue(l.get(0) instanceof HashMap);
                assertEquals(1, ((Map)l.get(0)).get("f1"));
 
-               // Without _class
+               // Without _type
                m = new ObjectMap(bc);
                m.put("items", new ObjectList(bc).append("{f1:1}"));
 
@@ -1487,9 +1487,9 @@ public class BeanMapTest {
        public void testCastToLinkedListUsingSwap() throws Exception {
                BeanContext bc = 
ContextFactory.create().addPojoSwaps(CalendarSwap.ISO8601DTZ.class).getBeanContext();
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap(bc);
-               m.put("_class", LinkedList.class.getName() + 
"<"+Calendar.class.getName()+">");
+               m.put("_type", LinkedList.class.getName() + 
"<"+Calendar.class.getName()+">");
                m.put("items", new ObjectList().append("2001-07-04T15:30:45Z"));
 
                List l = (List)m.cast();
@@ -1519,7 +1519,7 @@ public class BeanMapTest {
                assertTrue(l.get(0) instanceof String);
                assertEquals("2001-07-04T15:30:45Z", l.get(0));
 
-               // Without _class
+               // Without _type
                m = new ObjectMap().setBeanContext(bc);
                m.put("items", new ObjectList().append("2001-07-04T15:30:45Z"));
 
@@ -1550,9 +1550,9 @@ public class BeanMapTest {
        public void testCastToStringArray() throws Exception {
                BeanContext bc = BeanContext.DEFAULT;
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap();
-               m.put("_class", String[].class.getName());
+               m.put("_type", String[].class.getName());
                m.put("items", new ObjectList().append("1").append("2"));
 
                String[] l = (String[])m.cast();
@@ -1576,7 +1576,7 @@ public class BeanMapTest {
                l3 = m.cast(bc.getClassMeta(int[].class));
                assertEquals("1", l2[0].toString());
 
-               // Without _class
+               // Without _type
                m = new ObjectMap();
                m.put("items", new ObjectList().append("1").append("2"));
 
@@ -1597,9 +1597,9 @@ public class BeanMapTest {
        public void testCastToIntArray() throws Exception {
                BeanContext bc = BeanContext.DEFAULT;
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap();
-               m.put("_class", int[].class.getName());
+               m.put("_type", int[].class.getName());
                m.put("items", new ObjectList().append("1").append("2"));
 
                int[] l = (int[])m.cast();
@@ -1619,7 +1619,7 @@ public class BeanMapTest {
                l2 = m.cast(bc.getClassMeta(long[].class));
                assertEquals(1, l2[0]);
 
-               // Without _class
+               // Without _type
                m = new ObjectMap();
                m.put("items", new ObjectList().append("1").append("2"));
 
@@ -1643,9 +1643,9 @@ public class BeanMapTest {
        public void testCastToString2dArray() throws Exception {
                BeanContext bc = BeanContext.DEFAULT;
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap();
-               m.put("_class", String[][].class.getName());
+               m.put("_type", String[][].class.getName());
                m.put("items", new ObjectList().append(new 
ObjectList().append("1")).append(new ObjectList().append("2")));
 
                String[][] l = (String[][])m.cast();
@@ -1658,7 +1658,7 @@ public class BeanMapTest {
                l = m.cast(bc.getClassMeta(String[][].class));
                assertEquals("2", l[1][0]);
 
-               // Without _class
+               // Without _type
                m = new ObjectMap();
                m.put("items", new ObjectList().append(new 
ObjectList().append("1")).append(new ObjectList().append("2")));
 
@@ -1676,9 +1676,9 @@ public class BeanMapTest {
        public void testCastToInt2dArray() throws Exception {
                BeanContext bc = BeanContext.DEFAULT;
 
-               // With _class
+               // With _type
                ObjectMap m = new ObjectMap();
-               m.put("_class", int[][].class.getName());
+               m.put("_type", int[][].class.getName());
                m.put("items", new ObjectList().append(new 
ObjectList().append("1")).append(new ObjectList().append("2")));
 
                int[][] l = (int[][])m.cast();
@@ -1691,7 +1691,7 @@ public class BeanMapTest {
                l = m.cast(bc.getClassMeta(int[][].class));
                assertEquals(2, l[1][0]);
 
-               // Without _class
+               // Without _type
                m = new ObjectMap();
                m.put("items", new ObjectList().append(new 
ObjectList().append("1")).append(new ObjectList().append("2")));
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/test/java/org/apache/juneau/json/JsonTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/test/java/org/apache/juneau/json/JsonTest.java 
b/juneau-core/src/test/java/org/apache/juneau/json/JsonTest.java
index 6f29bfd..16742f6 100755
--- a/juneau-core/src/test/java/org/apache/juneau/json/JsonTest.java
+++ b/juneau-core/src/test/java/org/apache/juneau/json/JsonTest.java
@@ -281,7 +281,7 @@ public class JsonTest {
                JsonSerializer s = new 
JsonSerializer().setProperty(SERIALIZER_addClassAttrs, true);
                Map<String,Object> o = new HashMap<String,Object>();
                o.put("c", new C());
-               
assertEquals("{\"c\":{\"_class\":\"org.apache.juneau.json.JsonTest$C\",\"items\":[]}}",
 s.serialize(o));
+               
assertEquals("{\"c\":{\"_type\":\"org.apache.juneau.json.JsonTest$C\",\"items\":[]}}",
 s.serialize(o));
        }
 
        public static class C extends LinkedList<String> {

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/eac396db/juneau-core/src/test/java/org/apache/juneau/utils/PojoRestTest.java
----------------------------------------------------------------------
diff --git 
a/juneau-core/src/test/java/org/apache/juneau/utils/PojoRestTest.java 
b/juneau-core/src/test/java/org/apache/juneau/utils/PojoRestTest.java
index 16e88b4..24e891c 100755
--- a/juneau-core/src/test/java/org/apache/juneau/utils/PojoRestTest.java
+++ b/juneau-core/src/test/java/org/apache/juneau/utils/PojoRestTest.java
@@ -90,7 +90,7 @@ public class PojoRestTest {
 
                // Serialize it to JSON.
                String s = serializer.serialize(p);
-               String expectedValue = 
"{_class:'org.apache.juneau.utils.PojoRestTest$Person',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}]}";
+               String expectedValue = 
"{_type:'org.apache.juneau.utils.PojoRestTest$Person',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}]}";
                assertEquals(expectedValue, s);
 
                // Parse it back to Java objects.
@@ -101,7 +101,7 @@ public class PojoRestTest {
 
                // Parse it back into JSON again.
                s = serializer.serialize(p);
-               expectedValue = 
"{_class:'org.apache.juneau.utils.PojoRestTest$Person',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}]}";
+               expectedValue = 
"{_type:'org.apache.juneau.utils.PojoRestTest$Person',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}]}";
                assertEquals(expectedValue, s);
 
                // Try adding an address

Reply via email to