commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r1090522 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/ site/xdoc/article3_0.xml
Date Sat, 09 Apr 2011 04:30:13 GMT
Author: bayard
Date: Sat Apr  9 04:30:12 2011
New Revision: 1090522

Fixing documentation post translate move to Range API


Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/
Sat Apr  9 04:30:12 2011
@@ -502,7 +502,7 @@ public class StringEscapeUtils {
      * <p>Note that unicode characters greater than 0x7f are as of 3.0, no longer 
      *    escaped. If you still wish this functionality, you can achieve it 
      *    via the following: 
-     * {@code StringEscapeUtils.ESCAPE_XML.with( UnicodeEscaper.above(0x7f) );}</p>
+     * {@code StringEscapeUtils.ESCAPE_XML.with( new UnicodeEscaper(Range.between(0x7f, Integer.MAX_VALUE))
      * @param input  the {@code String} to escape, may be null
      * @return a new escaped {@code String}, {@code null} if null string input

Modified: commons/proper/lang/trunk/src/site/xdoc/article3_0.xml
--- commons/proper/lang/trunk/src/site/xdoc/article3_0.xml (original)
+++ commons/proper/lang/trunk/src/site/xdoc/article3_0.xml Sat Apr  9 04:30:12 2011
@@ -142,11 +142,16 @@ available in the <a href="userguide.html
 <p>Here we see that <code>ESCAPE_XML</code> is a '<code>CharSequenceTranslator</code>',
which in turn is made up of two lookup translators based on the basic XML escapes and another
to escape apostrophes. This shows one way to combine translators. Another can be shown by
looking at the example to achieve the old XML escaping functionality (escaping non-ASCII):
-          StringEscapeUtils.ESCAPE_XML.with( UnicodeEscaper.above(0x7f) );
+          StringEscapeUtils.ESCAPE_XML.with( new UnicodeEscaper(Range.between(0x7f, Integer.MAX_VALUE)
) );
 <p>That takes the standard Commons Lang provided escape functionality, and adds on
another translation layer. Another JIRA requested option was to also escape non-printable
ASCII, this is now achievable with a modification of the above: </p>
-          StringEscapeUtils.ESCAPE_XML.with( UnicodeEscaper.outsideOf(32, 0x7f) );
+          StringEscapeUtils.ESCAPE_XML.with(
+              new AggregateTranslator(
+                  new UnicodeEscaper(Range.between(0, 31)),
+                  new UnicodeEscaper(Range.between(0x80, Integer.MAX_VALUE))
+              )
+          )
 <p>You can also implement your own translators (be they for escaping, unescaping or
some aspect of your own). See the <code>CharSequenceTranslator</code> and its
<code>CodePointTranslator</code> helper subclass for details - primarily a case
of implementing the translate(CharSequence, int, Writer);int method. </p>

View raw message