You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/05/15 16:12:31 UTC
svn commit: r1103383 - in
/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder:
ByRuleProviderBuilder.java LinkedRuleBuilder.java
Author: simonetripodi
Date: Sun May 15 14:12:31 2011
New Revision: 1103383
URL: http://svn.apache.org/viewvc?rev=1103383&view=rev
Log:
restored the ByRuleProviderBuilder class
ByRuleProviderBuilder plugged in the Digester EDSL
Added:
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleProviderBuilder.java (with props)
Modified:
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/LinkedRuleBuilder.java
Added: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleProviderBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleProviderBuilder.java?rev=1103383&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleProviderBuilder.java (added)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleProviderBuilder.java Sun May 15 14:12:31 2011
@@ -0,0 +1,50 @@
+/* $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 org.apache.commons.digester3.Rule;
+
+/**
+ * Builder chained when invoking
+ * {@link LinkedRuleBuilder#addRuleCreatedBy(org.apache.commons.digester3.binder.RuleProvider)}.
+ *
+ * @since 3.0
+ */
+public final class ByRuleProviderBuilder<R extends Rule>
+ extends AbstractBackToLinkedRuleBuilder<R>
+{
+
+ private final RuleProvider<R> provider;
+
+ ByRuleProviderBuilder( String keyPattern, String namespaceURI, RulesBinder mainBinder,
+ LinkedRuleBuilder mainBuilder, RuleProvider<R> provider )
+ {
+ super( keyPattern, namespaceURI, mainBinder, mainBuilder );
+ this.provider = provider;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected R createRule()
+ {
+ return provider.get();
+ }
+
+}
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleProviderBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleProviderBuilder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleProviderBuilder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=1103383&r1=1103382&r2=1103383&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 14:12:31 2011
@@ -92,6 +92,23 @@ public final class LinkedRuleBuilder
}
/**
+ * Add a custom user rule in the specified pattern built by the given provider.
+ *
+ * @param <R>
+ * @param provider
+ * @return
+ */
+ public <R extends Rule> ByRuleProviderBuilder<R> addRuleCreatedBy(RuleProvider<R> provider)
+ {
+ if ( provider == null )
+ {
+ mainBinder.addError( "{ forPattern( \"%s\" ).addRuleCreatedBy() } null rule provider not valid", keyPattern );
+ }
+
+ return addProvider( new ByRuleProviderBuilder<R>( keyPattern, namespaceURI, mainBinder, this, provider ) );
+ }
+
+ /**
* Sets the namespace URI for the current rule pattern.
*
* @param namespaceURI the namespace URI associated to the rule pattern.