commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1130749 - in /commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline: CaseTransform.java CompoundTransform.java Pipeline.java SubstituteTransform.java Transform.java
Date Thu, 02 Jun 2011 19:18:21 GMT
Author: simonetripodi
Date: Thu Jun  2 19:18:20 2011
New Revision: 1130749

URL: http://svn.apache.org/viewvc?rev=1130749&view=rev
Log:
code reformatted

Modified:
    commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/CaseTransform.java
    commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/CompoundTransform.java
    commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/Pipeline.java
    commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/SubstituteTransform.java
    commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/Transform.java

Modified: commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/CaseTransform.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/CaseTransform.java?rev=1130749&r1=1130748&r2=1130749&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/CaseTransform.java
(original)
+++ commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/CaseTransform.java
Thu Jun  2 19:18:20 2011
@@ -26,21 +26,26 @@ package org.apache.commons.digester3.exa
  * there is no need to define any custom addRules method to use this
  * as a Digester plugin class.
  */
+public class CaseTransform
+    implements Transform
+{
 
-public class CaseTransform implements Transform {
     private boolean toLower = true;
-    
-    public void setCase(String caseType) {
-        if (caseType.equalsIgnoreCase("upper"))
+
+    public void setCase( String caseType )
+    {
+        if ( caseType.equalsIgnoreCase( "upper" ) )
             toLower = false;
-        else 
+        else
             toLower = true;
     }
-    
-    public String transform(String s) {
-        if (toLower)
+
+    public String transform( String s )
+    {
+        if ( toLower )
             return s.toLowerCase();
         else
             return s.toUpperCase();
     }
+
 }

Modified: commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/CompoundTransform.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/CompoundTransform.java?rev=1130749&r1=1130748&r2=1130749&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/CompoundTransform.java
(original)
+++ commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/CompoundTransform.java
Thu Jun  2 19:18:20 2011
@@ -31,25 +31,32 @@ import org.apache.commons.digester3.plug
  * This demonstrates that a plugged-in class can itself define plugin-points 
  * for user-defined classes if it wishes.
  */
+public class CompoundTransform
+    implements Transform
+{
 
-public class CompoundTransform implements Transform {
     private LinkedList transforms = new LinkedList();
-    
-    public void addTransform(Transform transform) {
-        transforms.add(transform);
+
+    public void addTransform( Transform transform )
+    {
+        transforms.add( transform );
     }
-    
-    public String transform(String s) {
-        for(Iterator i = transforms.iterator(); i.hasNext(); ) {
+
+    public String transform( String s )
+    {
+        for ( Iterator i = transforms.iterator(); i.hasNext(); )
+        {
             Transform t = (Transform) i.next();
-            s = t.transform(s);
+            s = t.transform( s );
         }
         return s;
     }
-    
-    public static void addRules(Digester d, String patternPrefix) {
-        PluginCreateRule pcr = new PluginCreateRule(Transform.class);
-        d.addRule(patternPrefix+"/subtransform", pcr);
-        d.addSetNext(patternPrefix+"/subtransform", "addTransform");
+
+    public static void addRules( Digester d, String patternPrefix )
+    {
+        PluginCreateRule pcr = new PluginCreateRule( Transform.class );
+        d.addRule( patternPrefix + "/subtransform", pcr );
+        d.addSetNext( patternPrefix + "/subtransform", "addTransform" );
     }
+
 }

Modified: commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/Pipeline.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/Pipeline.java?rev=1130749&r1=1130748&r2=1130749&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/Pipeline.java
(original)
+++ commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/Pipeline.java
Thu Jun  2 19:18:20 2011
@@ -40,90 +40,103 @@ import java.io.*;
  * any manner the Digester supports, without changing a line of this
  * application.
  */
- 
-public class Pipeline {
-    
+public class Pipeline
+{
+
     private String source;
+
     private String dest;
+
     private Transform transformer;
 
-    public static void main(String[] args) {
-        if (args.length != 1) {
-            System.err.println("usage: pipeline config-file");
-            System.exit(-1);
+    public static void main( String[] args )
+    {
+        if ( args.length != 1 )
+        {
+            System.err.println( "usage: pipeline config-file" );
+            System.exit( -1 );
         }
         String configFile = args[0];
-        
+
         Digester digester = new Digester();
         PluginRules rc = new PluginRules();
-        digester.setRules(rc);
-        
-        digester.addObjectCreate("pipeline", Pipeline.class);
-        
-        digester.addCallMethod("pipeline/source", "setSource", 1);
-        digester.addCallParam("pipeline/source", 0, "file");
-        
-        PluginCreateRule pcr = new PluginCreateRule(Transform.class);
-        digester.addRule("pipeline/transform", pcr);
-        digester.addSetNext("pipeline/transform", "setTransform");
-        
-        digester.addCallMethod("pipeline/destination", "setDest", 1);
-        digester.addCallParam("pipeline/destination", 0, "file");
-        
+        digester.setRules( rc );
+
+        digester.addObjectCreate( "pipeline", Pipeline.class );
+
+        digester.addCallMethod( "pipeline/source", "setSource", 1 );
+        digester.addCallParam( "pipeline/source", 0, "file" );
+
+        PluginCreateRule pcr = new PluginCreateRule( Transform.class );
+        digester.addRule( "pipeline/transform", pcr );
+        digester.addSetNext( "pipeline/transform", "setTransform" );
+
+        digester.addCallMethod( "pipeline/destination", "setDest", 1 );
+        digester.addCallParam( "pipeline/destination", 0, "file" );
+
         Pipeline pipeline = null;
-        try {
-            pipeline = (Pipeline) digester.parse(configFile);
-        }
-        catch(Exception e) {
-            System.err.println("oops exception occurred during parse.");
+        try
+        {
+            pipeline = (Pipeline) digester.parse( configFile );
+        }
+        catch ( Exception e )
+        {
+            System.err.println( "oops exception occurred during parse." );
             e.printStackTrace();
-            System.exit(-1);
+            System.exit( -1 );
         }
-        
-        try {
+
+        try
+        {
             pipeline.execute();
         }
-        catch (Exception e) {
-            System.err.println("oops exception occurred during pipeline execution.");
+        catch ( Exception e )
+        {
+            System.err.println( "oops exception occurred during pipeline execution." );
             e.printStackTrace();
-            System.exit(-1);
+            System.exit( -1 );
         }
     }
-    
-    public void setSource(String source) {
+
+    public void setSource( String source )
+    {
         this.source = source;
     }
-    
-    public void setDest(String dest) {
+
+    public void setDest( String dest )
+    {
         this.dest = dest;
     }
-    
-    public void setTransform(Transform transformer) {
+
+    public void setTransform( Transform transformer )
+    {
         this.transformer = transformer;
     }
-    
-    private void execute() throws IOException {
-        FileReader inRaw = new FileReader(source);
-        FileWriter out = new FileWriter(dest);
-
-        BufferedReader in = new BufferedReader(inRaw);
-        
-        while(true) {
+
+    private void execute()
+        throws IOException
+    {
+        FileReader inRaw = new FileReader( source );
+        FileWriter out = new FileWriter( dest );
+
+        BufferedReader in = new BufferedReader( inRaw );
+
+        while ( true )
+        {
             String inStr = in.readLine();
-            if (inStr==null) 
+            if ( inStr == null )
                 break;
-            
-            String outStr = transformer.transform(inStr);
-            out.write(outStr);
-            out.write('\n');
+
+            String outStr = transformer.transform( inStr );
+            out.write( outStr );
+            out.write( '\n' );
         }
-        
-        
+
         inRaw.close();
         out.close();
-        
-        System.out.println(
-            "Contents of file " + source + " have been transformed, and"
-            + " written to file " + dest + ".");
+
+        System.out.println( "Contents of file " + source + " have been transformed, and"
+ " written to file " + dest
+            + "." );
     }
+
 }

Modified: commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/SubstituteTransform.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/SubstituteTransform.java?rev=1130749&r1=1130748&r2=1130749&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/SubstituteTransform.java
(original)
+++ commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/SubstituteTransform.java
Thu Jun  2 19:18:20 2011
@@ -29,33 +29,42 @@ import org.apache.commons.digester3.Dige
  * rules though; for example they can be defined in a separate
  * SubstituteTransformRuleInfo class.
  */
- 
-public class SubstituteTransform implements Transform {
+public class SubstituteTransform
+    implements Transform
+{
+
     private String from;
+
     private String to;
-    
-    public void setFrom(String from) {
+
+    public void setFrom( String from )
+    {
         this.from = from;
     }
-    
-    public void setTo(String to) {
+
+    public void setTo( String to )
+    {
         this.to = to;
     }
-    
-    public String transform(String s) {
-        StringBuilder buf = new StringBuilder(s);
-        while (true) {
-            int idx = buf.indexOf(from);
-            if (idx == -1)
+
+    public String transform( String s )
+    {
+        StringBuilder buf = new StringBuilder( s );
+        while ( true )
+        {
+            int idx = buf.indexOf( from );
+            if ( idx == -1 )
                 break;
-            
-            StringBuilder buf2 = buf.replace(idx, idx+from.length(), to);
+
+            StringBuilder buf2 = buf.replace( idx, idx + from.length(), to );
         }
         return buf.toString();
     }
-    
-    public static void addRules(Digester d, String patternPrefix) {
-        d.addCallMethod(patternPrefix+"/from", "setFrom", 0);
-        d.addCallMethod(patternPrefix+"/to", "setTo", 0);
+
+    public static void addRules( Digester d, String patternPrefix )
+    {
+        d.addCallMethod( patternPrefix + "/from", "setFrom", 0 );
+        d.addCallMethod( patternPrefix + "/to", "setTo", 0 );
     }
+
 }

Modified: commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/Transform.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/Transform.java?rev=1130749&r1=1130748&r2=1130749&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/Transform.java
(original)
+++ commons/sandbox/digester3/trunk/src/examples/plugins/pipeline/src/main/java/org/apache/commons/digester3/examples/plugins/pipeline/Transform.java
Thu Jun  2 19:18:20 2011
@@ -15,13 +15,15 @@ package org.apache.commons.digester3.exa
  * 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.
- */ 
+ */
 
 /**
- * An interface that any user class must implement if it wishes to be
- * plugged in at the "transform" tag of a pipeline configuration file.
+ * An interface that any user class must implement if it wishes to be plugged in at the "transform"
tag of a pipeline
+ * configuration file.
  */
+public interface Transform
+{
+
+    String transform( String s );
 
-public interface Transform {
-    String transform(String s);
 }



Mime
View raw message