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

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@788243 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2009-06-25 03:54:03 +00:00
parent a027b12acf
commit a11f380774
1 changed files with 11 additions and 0 deletions

View File

@ -103,6 +103,17 @@ public final void translate(CharSequence input, Writer out) throws IOException {
} }
} }
/**
* 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 * <p>Returns an upper case hexadecimal <code>String</code> for the given
* character.</p> * character.</p>