Author: simonetripodi
Date: Sun May 15 17:42:29 2011
New Revision: 1103476

URL: http://svn.apache.org/viewvc?rev=1103476&view=rev
Log:
restored the SetPropertyBuilder class
SetPropertyBuilder plugged in the Digester EDSL

Added:
    
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertyBuilder.java
   (with props)
Modified:
    
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/LinkedRuleBuilder.java

Modified: 
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/LinkedRuleBuilder.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/LinkedRuleBuilder.java?rev=1103476&r1=1103475&r2=1103476&view=diff
==============================================================================
--- 
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/LinkedRuleBuilder.java
 (original)
+++ 
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/LinkedRuleBuilder.java
 Sun May 15 17:42:29 2011
@@ -169,6 +169,22 @@ public final class LinkedRuleBuilder
     }
 
     /**
+     * Sets an individual property on the object at the top of the stack, 
based on attributes with specified names.
+     *
+     * @param attributePropertyName Name of the attribute that will contain 
the name of the property to be set
+     */
+    public SetPropertyBuilder setProperty( String attributePropertyName )
+    {
+        if ( attributePropertyName == null || attributePropertyName.length() 
== 0 )
+        {
+            mainBinder.addError( "{ forPattern( \"%s\" ).setProperty( String 
)} empty 'attributePropertyName' not allowed",
+                                 keyPattern );
+        }
+
+        return addProvider( new SetPropertyBuilder( keyPattern, namespaceURI, 
mainBinder, this, attributePropertyName ) );
+    }
+
+    /**
      * Add a custom user rule in the specified pattern built by the given 
provider.
      *
      * @param <R>

Added: 
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertyBuilder.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertyBuilder.java?rev=1103476&view=auto
==============================================================================
--- 
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertyBuilder.java
 (added)
+++ 
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertyBuilder.java
 Sun May 15 17:42:29 2011
@@ -0,0 +1,68 @@
+/* $Id$
+ *
+ * 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
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester3.binder;
+
+import static java.lang.String.format;
+
+import org.apache.commons.digester3.SetPropertyRule;
+
+/**
+ * Builder chained when invoking {@link LinkedRuleBuilder#setProperty(String)}.
+ *
+ * @since 3.0
+ */
+public final class SetPropertyBuilder
+    extends AbstractBackToLinkedRuleBuilder<SetPropertyRule>
+{
+
+    private final String attributePropertyName;
+
+    private String valueAttributeName;
+
+    SetPropertyBuilder( String keyPattern, String namespaceURI, RulesBinder 
mainBinder, LinkedRuleBuilder mainBuilder,
+                        String attributePropertyName )
+    {
+        super( keyPattern, namespaceURI, mainBinder, mainBuilder );
+        this.attributePropertyName = attributePropertyName;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public SetPropertyBuilder extractingValueFromAttribute( String 
valueAttributeName )
+    {
+        if ( attributePropertyName == null || attributePropertyName.length() 
== 0 )
+        {
+            reportError( format( 
"setProperty(\"%s\").extractingValueFromAttribute(String)}", 
attributePropertyName ),
+                         "empty 'valueAttributeName' not allowed" );
+        }
+
+        this.valueAttributeName = valueAttributeName;
+        return this;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected SetPropertyRule createRule()
+    {
+        return new SetPropertyRule( attributePropertyName, valueAttributeName 
);
+    }
+
+}

Propchange: 
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertyBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertyBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: 
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertyBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to