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/24 22:14:47 UTC
svn commit: r1127258 - in
/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder:
ByRuleBuilder.java LinkedRuleBuilder.java
Author: simonetripodi
Date: Tue May 24 20:14:47 2011
New Revision: 1127258
URL: http://svn.apache.org/viewvc?rev=1127258&view=rev
Log:
restored the ByRuleBuilder class
Added:
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleBuilder.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/ByRuleBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleBuilder.java?rev=1127258&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleBuilder.java (added)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleBuilder.java Tue May 24 20:14:47 2011
@@ -0,0 +1,48 @@
+/* $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 LinkedRuleBuilderImpl#addRule(Rule)}.
+ *
+ * @param <R>
+ */
+public final class ByRuleBuilder<R extends Rule>
+ extends AbstractBackToLinkedRuleBuilder<R>
+{
+
+ private final R rule;
+
+ ByRuleBuilder( String keyPattern, String namespaceURI, RulesBinder mainBinder, LinkedRuleBuilder mainBuilder, R rule )
+ {
+ super( keyPattern, namespaceURI, mainBinder, mainBuilder );
+ this.rule = rule;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected R createRule()
+ {
+ return rule;
+ }
+
+}
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleBuilder.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/binder/ByRuleBuilder.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=1127258&r1=1127257&r2=1127258&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 Tue May 24 20:14:47 2011
@@ -247,6 +247,26 @@ public final class LinkedRuleBuilder
}
/**
+ * Add a custom user rule in the specified pattern.
+ *
+ * <b>WARNING</b> keep away from this method as much as you can, since there's the risk
+ * same input {@link Rule} instance is plugged to more than one Digester.
+ *
+ * @param <R>
+ * @param rule
+ * @return
+ */
+ public <R extends Rule> ByRuleBuilder<R> addRule( R rule )
+ {
+ if ( rule == null )
+ {
+ mainBinder.addError( "{ forPattern( \"%s\" ).addRule( R ) } NULL rule not valid", keyPattern );
+ }
+
+ return this.addProvider( new ByRuleBuilder<R>( keyPattern, namespaceURI, mainBinder, this, rule ) );
+ }
+
+ /**
* Add a custom user rule in the specified pattern built by the given provider.
*
* @param <R>