You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/05/15 19:25:46 UTC

svn commit: r775244 - in /incubator/pivot/trunk: build.xml wtk/src/pivot/wtkx/BindProcessor.java wtk/src/pivot/wtkx/Bindable.java wtk/src/pivot/wtkx/WTKXSerializer.java

Author: tvolkert
Date: Fri May 15 17:25:46 2009
New Revision: 775244

URL: http://svn.apache.org/viewvc?rev=775244&view=rev
Log:
Removed WTKX compilation code.  It had some deal-breaker problems.  Most notably, the WTKX may refer to classes that have not yet been compiled, meaning that we were unable to introspect on those classes (which was required to perform WTKX compilation).  We'll re-introduce this feature as a WTKXCompiler class later.

Modified:
    incubator/pivot/trunk/build.xml
    incubator/pivot/trunk/wtk/src/pivot/wtkx/BindProcessor.java
    incubator/pivot/trunk/wtk/src/pivot/wtkx/Bindable.java
    incubator/pivot/trunk/wtk/src/pivot/wtkx/WTKXSerializer.java

Modified: incubator/pivot/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/build.xml?rev=775244&r1=775243&r2=775244&view=diff
==============================================================================
--- incubator/pivot/trunk/build.xml (original)
+++ incubator/pivot/trunk/build.xml Fri May 15 17:25:46 2009
@@ -36,7 +36,6 @@
     <property name="compiler.debug" value="false"/>
     <property name="compiler.target" value="1.5"/>
     <property name="compiler.encoding" value="UTF-8"/>
-    <property name="compiler.compileWTKX" value="false"/>
 
     <!-- Dynamic properties -->
     <tstamp/>
@@ -471,7 +470,7 @@
             target="${compiler.target}"
             encoding="${compiler.encoding}"
             failonerror="true">
-            <compilerarg line="-Xlint -processor pivot.wtkx.BindProcessor -Acompile=${compiler.compileWTKX}"/>
+            <compilerarg line="-Xlint -processor pivot.wtkx.BindProcessor"/>
             <classpath>
                 <pathelement location="core/${folder.bin}"/>
                 <pathelement location="web/${folder.bin}"/>
@@ -513,7 +512,7 @@
             target="${compiler.target}"
             encoding="${compiler.encoding}"
             failonerror="true">
-            <compilerarg line="-Xlint -processor pivot.wtkx.BindProcessor -Acompile=${compiler.compileWTKX}"/>
+            <compilerarg line="-Xlint -processor pivot.wtkx.BindProcessor"/>
             <classpath>
                 <pathelement location="core/${folder.bin}"/>
                 <pathelement location="web/${folder.bin}"/>

Modified: incubator/pivot/trunk/wtk/src/pivot/wtkx/BindProcessor.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtkx/BindProcessor.java?rev=775244&r1=775243&r2=775244&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtkx/BindProcessor.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtkx/BindProcessor.java Fri May 15 17:25:46 2009
@@ -61,40 +61,16 @@
  * <b>Note</b>: this class utilizes classes specific to Sun's <tt>javac</tt>
  * implementation, and as such, it will only work with a Sun <tt>javac</tt>
  * compiler.
- * <h3>Options:</h3>
- * As an optimization, this processor supports a <tt>compile</tt> option. When
- * this option is set to <tt>true</tt>, the WTKX will be compiled into the
- * class and loaded via compiled code (as opposed to loaded at runtime using
- * {@link WTKXSerializer}). If unspecified, the WTKX loading will be done at
- * runtime.
- * <p>
- * There are some considerations when using the <tt>compile=true</tt>
- * option. Namely:
- * <ol>
- *   <li>
- *     WTKX URL resolution syntax (<tt>"&#64;relative/path.png"</tt>)
- *     will load relative URLs relative to the <tt>Bindable</tt>
- *     subclass (as opposed to relative to the WTKX file, which is
- *     normally the case). It is therefore recommended that when this
- *     option is used, your WTKX file should live in the same directory
- *     as your <tt>Bindable</tt> subclass to eliminate any ambiguity.
- *   </li>
- *   <li>
- *     This option may render the WTKX file superfluous at runtime since its
- *     contents are compiled directly into the class. In such cases, callers
- *     may choose to exclude the WTKX file from their JAR file.
- *   </li>
- * </ol>
  * <h3>Usage:</h3>
  * To use this annotation processor at the command line, pass the following
  * options to <tt>javac</tt>:
  * <pre>
- *     -processor pivot.wtkx.BindProcessor [-Acompile=&lt;boolean&gt;]
+ *     -processor pivot.wtkx.BindProcessor
  * </pre>
  * To use this annotation processor with Ant, add the following line to your
  * Ant <tt>javac</tt> task:
  * <pre>
- *     &lt;compilerarg line="-processor pivot.wtkx.BindProcessor [-Acompile=&lt;boolean&gt;]"/&gt;
+ *     &lt;compilerarg line="-processor pivot.wtkx.BindProcessor"/&gt;
  * </pre>
  *
  * @author tvolkert
@@ -102,7 +78,6 @@
  * @see Bindable.Bind
  */
 @SupportedAnnotationTypes("pivot.wtkx.*")
-@SupportedOptions("compile")
 @SupportedSourceVersion(SourceVersion.RELEASE_6)
 public class BindProcessor extends AbstractProcessor {
     /**
@@ -298,14 +273,7 @@
                     for (String loadFieldName : loadGroups) {
                         AnnotationDossier.LoadGroup loadGroup = loadGroups.get(loadFieldName);
                         JCVariableDecl loadField = loadGroup.loadField;
-                        JCAnnotation loadAnnotation = getLoadAnnotation(loadField);
-                        Boolean compilable = getAnnotationProperty(loadAnnotation, "compilable");
-
-                        if (compile && compilable != Boolean.FALSE) {
-                            processCompiledLoad(buf, classDeclaration, loadField, loadGroup.bindFields);
-                        } else {
-                            processRuntimeLoad(buf, classDeclaration, loadField, loadGroup.bindFields);
-                        }
+                        processLoad(buf, classDeclaration, loadField, loadGroup.bindFields);
                     }
                 }
 
@@ -370,126 +338,6 @@
 
         /**
          * Processes an <tt>@Load</tt> field and associated <tt>@Bind</tt>
-         * fields into compiled code.
-         *
-         * @param buf
-         * The buffer into which to write the source code
-         *
-         * @param classDeclaration
-         * The AST node of the class that contains the <tt>@Load</tt> field
-         *
-         * @param loadField
-         * The AST node with the <tt>@Load</tt> annotation
-         *
-         * @param bindFields
-         * List of AST nodes with the <tt>@Bind</tt> annotations that are
-         * associated with the load field
-         */
-        private void processCompiledLoad(StringBuilder buf, JCClassDecl classDeclaration,
-            JCVariableDecl loadField, ArrayList<JCVariableDecl> bindFields) {
-            FileObject sourceFile = null;
-
-            if (classDeclaration.sym != null) {
-                sourceFile = classDeclaration.sym.sourcefile;
-            }
-
-            if (sourceFile != null) {
-                String loadFieldName = loadField.name.toString();
-
-                try {
-                    JavaFileManager fileManager = context.get(JavaFileManager.class);
-
-                    // Get annotation properties
-                    JCAnnotation loadAnnotation = getLoadAnnotation(loadField);
-                    String resourceName = getAnnotationProperty(loadAnnotation, "resourceName");
-
-                    InputStream inputStream;
-                    if (resourceName.startsWith("/")) {
-                        // Absolute URL uses ClassLoader
-                        ClassLoader classLoader = fileManager.getClassLoader
-                            (StandardLocation.SOURCE_PATH);
-                        URL resourceLocation = classLoader.getResource(resourceName.substring(1));
-                        inputStream = new BufferedInputStream(resourceLocation.openStream());
-                    } else {
-                        // Relative URL uses JavaFileManager
-                        String packageName = classDeclaration.sym.packge().toString();
-                        FileObject resourceFile = fileManager.getFileForInput
-                            (StandardLocation.SOURCE_PATH, packageName, resourceName);
-                        inputStream = resourceFile.openInputStream();
-                    }
-
-                    try {
-                        // TODO Handle resources
-                        WTKXSerializer wtkxSerializer = new WTKXSerializer();
-                        String blockCode = wtkxSerializer.readSource(inputStream);
-
-                        // Open local scope for variable name protection
-                        buf.append("{");
-
-                        // Add interpreted code
-                        buf.append(blockCode);
-
-                        // Public and protected fields get kept for subclasses
-                        if ((loadField.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0) {
-                            buf.append(String.format
-                                ("namedObjectDictionaries.put(\"%s\", _namedObjects);",
-                                loadFieldName));
-                        }
-
-                        // Bind @Load member
-                        buf.append(String.format
-                            ("%s = (%s)_result;", loadFieldName, loadField.vartype.toString()));
-
-                        // Bind @Bind members
-                        for (JCVariableDecl bindField : bindFields) {
-                            String bindFieldName = bindField.name.toString();
-                            JCAnnotation bindAnnotation = getBindAnnotation(bindField);
-
-                            String id = getAnnotationProperty(bindAnnotation, "id");
-                            if (id == null) {
-                                // The bind name defaults to the field name
-                                id = bindFieldName;
-                            }
-
-                            buf.append(String.format
-                                ("_result = _namedObjects.get(\"%s\");", id));
-                            buf.append
-                                ("if (_result == null) ");
-                            buf.append(String.format
-                                ("throw new pivot.wtkx.BindException(\"Element not found: %s.\");", id));
-                            buf.append(String.format
-                                ("%s = (%s)_result;", bindFieldName, bindField.vartype.toString()));
-                        }
-
-                        // Close local scope
-                        buf.append("}");
-                    } finally {
-                        inputStream.close();
-                    }
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                    processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
-                        "Error trying to load field " + classDeclaration.name.toString() + "." +
-                        loadFieldName + ": " + ex.toString());
-                }
-            } else {
-                if (classDeclaration.name.isEmpty()) {
-                    // NOTE: Anonymous inner classes do not have an associated
-                    // symbol, so their source file cannot be determined, and
-                    // we cannot compile their annotations. This bug has been
-                    // filed to Sun
-                    processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
-                        "WTKX compilation of anonymous classes is not supported.");
-                } else {
-                    processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
-                        "Unable to determine source file location for class: " +
-                        classDeclaration.name.toString());
-                }
-            }
-        }
-
-        /**
-         * Processes an <tt>@Load</tt> field and associated <tt>@Bind</tt>
          * fields into runtime code.
          *
          * @param buf
@@ -505,7 +353,7 @@
          * List of AST nodes with the <tt>@Bind</tt> annotations that are
          * associated with the load field
          */
-        private void processRuntimeLoad(StringBuilder buf, JCClassDecl classDeclaration,
+        private void processLoad(StringBuilder buf, JCClassDecl classDeclaration,
             JCVariableDecl loadField, ArrayList<JCVariableDecl> bindFields) {
             String loadFieldName = loadField.name.toString();
 
@@ -654,7 +502,6 @@
     private Parser.Factory parserFactory;
 
     private BindInjector bindInjector = new BindInjector();
-    private boolean compile = false;
 
     @Override
     public synchronized void init(ProcessingEnvironment processingEnvironment) {
@@ -664,11 +511,6 @@
         context = ((JavacProcessingEnvironment)processingEnvironment).getContext();
         scannerFactory = Scanner.Factory.instance(context);
         parserFactory = Parser.Factory.instance(context);
-
-        String compileOption = processingEnvironment.getOptions().get("compile");
-        if (compileOption != null) {
-            compile = Boolean.parseBoolean(compileOption);
-        }
     }
 
     @Override

Modified: incubator/pivot/trunk/wtk/src/pivot/wtkx/Bindable.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtkx/Bindable.java?rev=775244&r1=775243&r2=775244&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtkx/Bindable.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtkx/Bindable.java Fri May 15 17:25:46 2009
@@ -73,7 +73,7 @@
  * }
  * </pre>
  * <h3>Binding implementations:</h3>
- * WTKX binding can be performed using one of three methods. It is important
+ * WTKX binding can be performed using one of two methods. It is important
  * for callers to understand these methods so that they may decide which is
  * appropriate for them. The methods are as follows:
  * <ol>
@@ -101,18 +101,6 @@
  *     development and deploy using the annotation processor.
  *     <br/><br/>
  *   </li>
- *   <li>
- *     <b>Compiled</b>
- *     <br/><br/>
- *     As a performance optimization, <tt>BindProcessor</tt> supports a
- *     <tt>compile=true</tt> option. This option will cause the WTKX to be
- *     compiled into the class and loaded via compiled code. This method is
- *     suitable for callers who are comfortable with the dependency implied by
- *     the annotation processor (outlined above) and comfortable with the
- *     specifics of the <tt>compile=true</tt> option. See the
- *     <tt>BindProcessor</tt> class for more details.
- *     <br/><br/>
- *   </li>
  * </ol>
  *
  * @author gbrown
@@ -155,13 +143,6 @@
          * default locale will be used.
          */
         public String locale() default "\0";
-
-        /**
-         * Indicates whether the WTKX resource is a compilable resource. Set
-         * this to <tt>false</tt> if your WTKX is dynamically generated at
-         * runtime. Defaults to <tt>true</tt>.
-         */
-        public boolean compilable() default true;
     }
 
     /**

Modified: incubator/pivot/trunk/wtk/src/pivot/wtkx/WTKXSerializer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtkx/WTKXSerializer.java?rev=775244&r1=775243&r2=775244&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtkx/WTKXSerializer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtkx/WTKXSerializer.java Fri May 15 17:25:46 2009
@@ -67,20 +67,12 @@
         public final List<Attribute> attributes;
 
         public Object value;
-        public int ref;
-
-        public static int counter = -1;
 
         public Element(Element parent, Type type, List<Attribute> attributes, Object value) {
-            this(parent, type, attributes, value, -1);
-        }
-
-        public Element(Element parent, Type type, List<Attribute> attributes, Object value, int ref) {
             this.parent = parent;
             this.type = type;
             this.attributes = attributes;
             this.value = value;
-            this.ref = ref;
         }
     }
 
@@ -555,10 +547,6 @@
                                     throw new SerializationException("Root node must represent a typed object.");
                                 }
 
-                                if (element.type != Element.Type.INSTANCE) {
-                                    throw new SerializationException("Property elements must apply to typed objects.");
-                                }
-
                                 BeanDictionary propertyDictionary = new BeanDictionary(element.value);
 
                                 if (propertyDictionary.isReadOnly(localName)) {
@@ -728,301 +716,6 @@
     }
 
     /**
-     * Interprets an object from a WTKX input stream.
-     *
-     * @param inputStream
-     * The data stream from which the WTKX will be read
-     *
-     * @return
-     * The Java source code that represents the WTKX
-     */
-    public String readSource(InputStream inputStream) throws IOException,
-        SerializationException {
-        if (inputStream == null) {
-            throw new IllegalArgumentException("inputStream is null.");
-        }
-
-        StringBuilder buf = new StringBuilder();
-        buf.append("Object _result = null;");
-        buf.append("pivot.collections.Dictionary<String, Object> _namedObjects = " +
-            "new pivot.collections.HashMap<String, Object>();");
-
-        // Parse the XML stream
-        Element element = null;
-        try {
-            XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(inputStream);
-
-            while (reader.hasNext()) {
-                int event = reader.next();
-
-                switch (event) {
-                case XMLStreamConstants.CHARACTERS: {
-                    // TODO
-                    break;
-                }
-
-                case XMLStreamConstants.START_ELEMENT: {
-                    String namespaceURI = reader.getNamespaceURI();
-                    String prefix = reader.getPrefix();
-                    String localName = reader.getLocalName();
-
-                    String id = null;
-
-                    if (prefix != null
-                        && prefix.equals(WTKX_PREFIX)) {
-                        if (element == null) {
-                            throw new SerializationException(prefix + ":" + localName
-                                + " is not a valid root element.");
-                        }
-
-                        if (localName.equals(INCLUDE_TAG)) {
-                            // TODO
-                            throw new SerializationException(prefix + ":" + localName
-                                + " compilation is not yet implemented.");
-                        } else if (localName.equals(SCRIPT_TAG)) {
-                            throw new SerializationException(prefix + ":" + localName
-                                + " tags may not be compiled.");
-                        } else {
-                            throw new SerializationException(prefix + ":" + localName
-                                + " is not a valid tag.");
-                        }
-                    } else {
-                        ArrayList<Attribute> attributes = new ArrayList<Attribute>();
-
-                        for (int i = 0, n = reader.getAttributeCount(); i < n; i++) {
-                            String attributeNamespaceURI = reader.getAttributeNamespace(i);
-                            if (attributeNamespaceURI == null) {
-                                attributeNamespaceURI = reader.getNamespaceURI("");
-                            }
-
-                            String attributePrefix = reader.getAttributePrefix(i);
-                            String attributeLocalName = reader.getAttributeLocalName(i);
-                            String attributeValue = reader.getAttributeValue(i);
-
-                            if (attributePrefix != null
-                                && attributePrefix.equals(WTKX_PREFIX)) {
-                                if (attributeLocalName.equals(ID_ATTRIBUTE)) {
-                                    id = attributeValue;
-                                }
-                            } else {
-                                attributes.add(new Attribute(attributeNamespaceURI,
-                                    attributePrefix, attributeLocalName, attributeValue));
-                            }
-                        }
-
-                        if (Character.isUpperCase(localName.charAt(0))) {
-                            // The element represents a typed object
-                            if (namespaceURI == null) {
-                                throw new SerializationException("No XML namespace specified for "
-                                    + localName + " tag.");
-                            }
-
-                            String className = namespaceURI + "." + localName;
-                            buf.append(String.format
-                                ("%s _%d = new %s();", className, ++Element.counter, className));
-
-                            try {
-                                className = namespaceURI + "." + localName.replace('.', '$');
-                                Class<?> type = Class.forName(className, false, getClass().getClassLoader());
-                                element = new Element(element, Element.Type.INSTANCE,
-                                    attributes, type, Element.counter);
-                            } catch(Exception exception) {
-                                throw new SerializationException(exception);
-                            }
-                        } else {
-                            // The element represents a property
-                            if (element == null) {
-                                throw new SerializationException("Root node must represent a typed object.");
-                            }
-
-                            if (element.type != Element.Type.INSTANCE) {
-                                throw new SerializationException("Property elements must apply to typed objects.");
-                            }
-
-                            Class<?> type = (Class<?>)element.value;
-
-                            if (BeanDictionary.isReadOnly(type, localName)) {
-                                Class<?> valueType = BeanDictionary.getType(type, localName);
-                                Method getterMethod = BeanDictionary.getGetterMethod(type, localName);
-
-                                // Instantiate the property so we have a reference to it
-                                buf.append(String.format
-                                    ("%s _%d = _%d.%s();", valueType.getName().replace('$', '.'), ++Element.counter,
-                                    element.ref, getterMethod.getName()));
-                                buf.append(String.format
-                                    ("assert (_%d != null) : \"Read-only properties cannot be null.\";",
-                                    Element.counter));
-
-                                element = new Element(element, Element.Type.READ_ONLY_PROPERTY,
-                                    attributes, valueType, Element.counter);
-                            } else {
-                                if (attributes.getLength() > 0) {
-                                    throw new SerializationException
-                                        ("Writable property elements cannot have attributes.");
-                                }
-
-                                element = new Element(element, Element.Type.WRITABLE_PROPERTY,
-                                    null, null, -1);
-                            }
-                        }
-                    }
-
-                    switch (element.type) {
-                    case INCLUDE:
-                    case INSTANCE: {
-                        // If the element's parent is a sequence or a listener list, add
-                        // the element value to it
-                        if (element.parent != null) {
-                            Class<?> parentType = (Class<?>)element.parent.value;
-
-                            if (parentType != null
-                                && (Sequence.class.isAssignableFrom(parentType)
-                                || ListenerList.class.isAssignableFrom(parentType))) {
-                                buf.append(String.format("_%d.add(_%d);",
-                                    element.parent.ref, element.ref));
-                            }
-                        }
-
-                        // If an ID was specified, add the value to the named object map
-                        if (id != null) {
-                            if (id.length() == 0) {
-                                throw new IllegalArgumentException(WTKX_PREFIX + ":" + ID_ATTRIBUTE
-                                    + " must not be null.");
-                            }
-
-                            buf.append(String.format("_namedObjects.put(\"%s\", _%d);", id, element.ref));
-                        }
-
-                        break;
-                    }
-                    }
-
-                    break;
-                }
-
-                case XMLStreamConstants.END_ELEMENT: {
-                    String localName = reader.getLocalName();
-
-                    switch (element.type) {
-                    case WRITABLE_PROPERTY: {
-                        Class<?> type = (Class<?>)element.value;
-                        Class<?> parentType = (Class<?>)element.parent.value;
-                        Method setterMethod = BeanDictionary.getSetterMethod(parentType, localName, type);
-
-                        buf.append(String.format("_%d.%s(_%d);",
-                            element.parent.ref, setterMethod.getName(), element.ref));
-
-                        break;
-                    }
-
-                    case SCRIPT: {
-                        break;
-                    }
-
-                    default: {
-                        Class<?> type = (Class<?>)element.value;
-
-                        if (type != null && Dictionary.class.isAssignableFrom(type)) {
-                            // The element is an untyped object
-                            for (Attribute attribute : element.attributes) {
-                                if (Character.isUpperCase(attribute.localName.charAt(0))) {
-                                    throw new SerializationException
-                                        ("Static setters are only supported for typed instances.");
-                                }
-
-                                // Resolve and apply the attribute
-                                buf.append(String.format("_%d.put(\"%s\", %s);", element.ref,
-                                    attribute.localName, resolveSource(attribute.value, null)));
-                            }
-                        } else {
-                            // The element represents a typed object; apply the attributes
-                            for (Attribute attribute : element.attributes) {
-                                Class<?> attributeType = BeanDictionary.getType(type, attribute.localName);
-
-                                if (Character.isUpperCase(attribute.localName.charAt(0))) {
-                                    // The property represents an attached value
-                                    String propertyName = attribute.localName.substring
-                                        (attribute.localName.lastIndexOf(".") + 1);
-                                    propertyName = Character.toUpperCase(propertyName.charAt(0)) +
-                                        propertyName.substring(1);
-                                    String setterMethodName = BeanDictionary.SET_PREFIX + propertyName;
-
-                                    String propertyClassName = attribute.namespaceURI + "."
-                                        + attribute.localName.substring(0, attribute.localName.length()
-                                        - (propertyName.length() + 1));
-
-                                    buf.append(String.format("%s.%s(_%d, %s);", propertyClassName,
-                                        setterMethodName, element.ref, resolveSource(attribute.value, attributeType)));
-                                } else {
-                                    if (attributeType != null
-                                        && ListenerList.class.isAssignableFrom(attributeType)) {
-                                        // The property represents a listener list
-                                        /*
-                                        ListenerList<Object> listenerList = (ListenerList<Object>)valueDictionary.get(attribute.localName);
-
-                                        // The attribute value is a comma-separated list of listener IDs
-                                        String[] listenerIDs = attribute.value.split(",");
-
-                                        for (int i = 0, n = listenerIDs.length; i < n; i++) {
-                                            String listenerID = listenerIDs[i].trim();
-
-                                            if (listenerID.length() > 0) {
-                                                listenerID = listenerID.substring(1);
-
-                                                if (listenerID.length() > 0) {
-                                                    listenerList.add(namedObjectDictionary.get(listenerID));
-                                                }
-                                            }
-                                        }
-                                        */
-                                    } else {
-                                        String key = Character.toUpperCase(attribute.localName.charAt(0)) +
-                                            attribute.localName.substring(1);
-                                        String setterMethodName = BeanDictionary.SET_PREFIX + key;
-
-                                        buf.append(String.format("_%d.%s(%s);", element.ref,
-                                            setterMethodName, resolveSource(attribute.value, attributeType)));
-                                    }
-                                }
-                            }
-                        }
-
-                        // If the parent element is a writable property, set this as its value; it
-                        // will be applied later in the parent's closing tag
-                        if (element.parent != null
-                            && element.parent.type == Element.Type.WRITABLE_PROPERTY) {
-                            element.parent.value = element.value;
-                            element.parent.ref = element.ref;
-                        }
-                    }
-                    }
-
-                    // If this is the top of the stack, return this element's value;
-                    // otherwise, move up the stack
-                    if (element.parent == null) {
-                        buf.append(String.format("_result = _%d;", element.ref));
-                    } else {
-                        element = element.parent;
-                    }
-
-                    break;
-                }
-                }
-            }
-
-            reader.close();
-        } catch(XMLStreamException exception) {
-            throw new SerializationException(exception);
-        }
-
-        // Clear the location so the previous value won't be re-used in a
-        // subsequent call to this method
-        location = null;
-
-        return buf.toString();
-    }
-
-    /**
      * Retrieves a included serializer by its ID.
      *
      * @param id
@@ -1203,106 +896,6 @@
         return resolvedValue;
     }
 
-    private String resolveSource(String attributeValue, Class<?> propertyType)
-        throws MalformedURLException {
-        String result = null;
-
-        if (propertyType == Boolean.class
-            || propertyType == Boolean.TYPE) {
-            result = String.valueOf(Boolean.parseBoolean(attributeValue));
-        } else if (propertyType == Character.class
-            || propertyType == Character.TYPE) {
-            if (attributeValue.length() > 0) {
-                result = String.format("'%c'", attributeValue.charAt(0));
-            }
-        } else if (propertyType == Byte.class
-            || propertyType == Byte.TYPE) {
-            try {
-                result = String.format("(byte)%d", Byte.parseByte(attributeValue));
-            } catch(NumberFormatException exception) {
-                result = String.format("\"%s\"", attributeValue);
-            }
-        } else if (propertyType == Short.class
-            || propertyType == Short.TYPE) {
-            try {
-                result = String.format("(short)%d", Short.parseShort(attributeValue));
-            } catch(NumberFormatException exception) {
-                result = String.format("\"%s\"", attributeValue);
-            }
-        } else if (propertyType == Integer.class
-            || propertyType == Integer.TYPE) {
-            try {
-                result = String.format("(int)%d", Integer.parseInt(attributeValue));
-            } catch(NumberFormatException exception) {
-                result = String.format("\"%s\"", attributeValue);
-            }
-        } else if (propertyType == Long.class
-            || propertyType == Long.TYPE) {
-            try {
-                result = String.format("(long)%d", Long.parseLong(attributeValue));
-            } catch(NumberFormatException exception) {
-                result = String.format("\"%s\"", attributeValue);
-            }
-        } else if (propertyType == Float.class
-            || propertyType == Float.TYPE) {
-            try {
-                result = String.format("(float)%f", Float.parseFloat(attributeValue));
-            } catch(NumberFormatException exception) {
-                result = String.format("\"%s\"", attributeValue);
-            }
-        } else if (propertyType == Double.class
-            || propertyType == Double.TYPE) {
-            try {
-                result = String.format("(double)%f", Double.parseDouble(attributeValue));
-            } catch(NumberFormatException exception) {
-                result = String.format("\"%s\"", attributeValue);
-            }
-        } else {
-            if (attributeValue.length() > 0) {
-                if (attributeValue.charAt(0) == URL_PREFIX) {
-                    if (attributeValue.length() > 1) {
-                        if (attributeValue.charAt(1) == URL_PREFIX) {
-                            result = String.format("\"%s\"", attributeValue.substring(1));
-                        } else {
-                            result = String.format("getClass().getResource(\"%s\")", attributeValue.substring(1));
-                        }
-                    }
-                } else if (attributeValue.charAt(0) == RESOURCE_KEY_PREFIX) {
-                    if (attributeValue.length() > 1) {
-                        if (attributeValue.charAt(1) == RESOURCE_KEY_PREFIX) {
-                            result = String.format("\"%s\"", attributeValue.substring(1));
-                        } else {
-                            // TODO
-                            result = String.format("\"%s\"", attributeValue);
-                        }
-                    }
-                } else if (attributeValue.charAt(0) == OBJECT_REFERENCE_PREFIX) {
-                    if (attributeValue.length() > 1) {
-                        if (attributeValue.charAt(1) == OBJECT_REFERENCE_PREFIX) {
-                            result = String.format("\"%s\"", attributeValue.substring(1));
-                        } else {
-                            String className = propertyType == null ?
-                                "Object" : propertyType.getName();
-                            result = String.format("(%s)_namedObjects.get(\"%s\")",
-                                className, attributeValue.substring(1));
-                        }
-                    }
-                } else {
-                    result = String.format("\"%s\"", attributeValue);
-                }
-            } else {
-                result = "\"\"";
-            }
-        }
-
-        if (result == null) {
-            // Fall-through case
-            result = "null";
-        }
-
-        return result;
-    }
-
     /**
      * Invokes a static property setter.
      *