cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r125101 - cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding
Date Thu, 13 Jan 2005 20:48:25 GMT
Author: tim
Date: Thu Jan 13 12:48:22 2005
New Revision: 125101

URL: http://svn.apache.org/viewcvs?view=rev&rev=125101
Log:
Add support framework for tracking source locations for the forms bindings and add some comments.
Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBase.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBuilderBase.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java?view=diff&rev=125101&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java&r1=125100&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java&r2=125101
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/AbstractCustomBinding.java
Thu Jan 13 12:48:22 2005
@@ -27,9 +27,15 @@
     private Binding parent;
     private String id;
 
+    /**
+     * Sets parent binding.
+     */
     public void setParent(Binding binding) {
         this.parent = binding;
     }
+    /**
+     * Returns binding definition id.
+     */
     public String getId() {
         return this.id;
     }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBase.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBase.java?view=diff&rev=125101&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBase.java&r1=125100&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBase.java&r2=125101
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBase.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBase.java
Thu Jan 13 12:48:22 2005
@@ -65,6 +65,13 @@
     }
 
     /**
+     * Gets source location of this binding.
+     */
+    public String getLocation() {
+        return this.commonAtts.location;
+    }
+
+    /**
      * Sets parent binding.
      */
     public void setParent(Binding binding) {
@@ -94,8 +101,7 @@
                 }
                 classes.put(id, classBinding);
             } else {
-                // TODO: Improve message to include source location.
-                throw new RuntimeException("Class \"" + id + "\" not found.");
+                throw new RuntimeException("Class \"" + id + "\" not found (" + getLocation()
+ ")");
             }
         }
         return classBinding;
@@ -125,7 +131,7 @@
             } else {
                 containerId = "container \"" + containerId + "\"";
             }
-            throw new RuntimeException(getClass().getName() + ": Widget \"" +
+            throw new RuntimeException(getClass().getName() + " (" + getLocation() + "):
Widget \"" +
                     id + "\" does not exist in the " + containerId +
                     " (" + parent.getLocation() + ").");
         }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBuilderBase.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBuilderBase.java?view=diff&rev=125101&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBuilderBase.java&r1=125100&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBuilderBase.java&r2=125101
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBuilderBase.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBuilderBase.java
Thu Jan 13 12:48:22 2005
@@ -97,14 +97,15 @@
      */
     protected static CommonAttributes getCommonAttributes(Element bindingElm) throws BindingException
{
         try {
+            String location = DomHelper.getLocation(bindingElm);
             //TODO: should we eventually remove this?
             //throw an error if people are still using the old-style @read-only or @readonly
             if (DomHelper.getAttributeAsBoolean(bindingElm, "readonly", false)) {
-                throw new BindingException("Error in binding file " + DomHelper.getLocation(bindingElm)
+                throw new BindingException("Error in binding file " + location
                         + "\nThe usage of the attribute @readonly has been deprecated in
favour of @direction.");
             }
             if (DomHelper.getAttributeAsBoolean(bindingElm, "read-only", false)) {
-                throw new BindingException("Error in binding file " + DomHelper.getLocation(bindingElm)
+                throw new BindingException("Error in binding file " + location
                         + "\nThe usage of the attribute @read-only has been deprecated in
favour of @direction.");
             }
 
@@ -124,10 +125,10 @@
             // we (actually jxpath) doesn't support un-prefixed namespace-declarations:
             // so we decide to break on those above silently ignoring them
             if (nsDeclarationMap != null && nsDeclarationMap.values().contains(null))
-                throw new BindingException("Error in binding file " + DomHelper.getLocation(bindingElm)
+                throw new BindingException("Error in binding file " + location
                                 + "\nBinding doesn't support having namespace-declarations
without explicit prefixes.");
             
-            return new CommonAttributes(direction, leniency, nsDeclarationMap);
+            return new CommonAttributes(location, direction, leniency, nsDeclarationMap);
         } catch (BindingException e) {
             throw e;
         } catch (Exception e) {
@@ -141,6 +142,11 @@
       * actions of a given binding.
       */
      protected static class CommonAttributes{
+
+        /**
+         * Source location of this binding.
+         */
+        final String location;
         /**
          * Flag which controls whether a binding is active during loading.
          */
@@ -159,13 +165,14 @@
          */
         final Map nsDeclarations;
 
-        final static CommonAttributes DEFAULT = new CommonAttributes(true, true, null, null);
+        final static CommonAttributes DEFAULT = new CommonAttributes("location unknown",
true, true, null, null);
 
-        CommonAttributes(String direction, String leniency, Map nsDeclarations){
-            this(isLoadEnabled(direction), isSaveEnabled(direction), decideLeniency(leniency),
nsDeclarations);
+        CommonAttributes(String location, String direction, String leniency, Map nsDeclarations){
+            this(location, isLoadEnabled(direction), isSaveEnabled(direction), decideLeniency(leniency),
nsDeclarations);
         }
 
-        CommonAttributes(boolean loadEnabled, boolean saveEnabled, Boolean leniency, Map
nsDeclarations){
+        CommonAttributes(String location, boolean loadEnabled, boolean saveEnabled, Boolean
leniency, Map nsDeclarations){
+            this.location = location;
             this.loadEnabled = loadEnabled;
             this.saveEnabled = saveEnabled;
             this.leniency = leniency;
@@ -198,7 +205,7 @@
          * @return null if the leniency parameter is null or a String otherwise the allowed
values
          */
         private static Boolean decideLeniency(String leniency) {
-                return BooleanUtils.toBooleanObject(leniency);
+            return BooleanUtils.toBooleanObject(leniency);
         }
     }
 }

Mime
View raw message