commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r788243 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java
Date Thu, 25 Jun 2009 03:54:04 GMT
Author: bayard
Date: Thu Jun 25 03:54:03 2009
New Revision: 788243

URL: http://svn.apache.org/viewvc?rev=788243&view=rev
Log:
Adding a method to chain translators together. I've gone back and forth on the name, currently
with() is my preference. So you could say:  BASIC_XML.with(HTML4_ENTITIES). cf LANG-505

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java?rev=788243&r1=788242&r2=788243&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/CharSequenceTranslator.java
Thu Jun 25 03:54:03 2009
@@ -104,6 +104,17 @@
     }
 
     /**
+     * Helper method to create a merger of this translator with another set of 
+     * translators. Useful in customizing the standard functionality.
+     */
+    public final CharSequenceTranslator with(CharSequenceTranslator... translators) {
+        CharSequenceTranslator[] newArray = new CharSequenceTranslator[translators.length
+ 1];
+        newArray[0] = this;
+        System.arraycopy(translators, 0, newArray, 1, translators.length);
+        return new AggregateTranslator(newArray);
+    }
+
+    /**
      * <p>Returns an upper case hexadecimal <code>String</code> for the
given
      * character.</p>
      *



Mime
View raw message