commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r1090522 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/StringEscapeUtils.java 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

URL: http://svn.apache.org/viewvc?rev=1090522&view=rev
Log:
Fixing documentation post translate move to Range API

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
    commons/proper/lang/trunk/src/site/xdoc/article3_0.xml

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java?rev=1090522&r1=1090521&r2=1090522&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
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))
);}</p>
      *
      * @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
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/site/xdoc/article3_0.xml?rev=1090522&r1=1090521&r2=1090522&view=diff
==============================================================================
--- 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
 </pre>
 <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):
</p>
 <pre>
-          StringEscapeUtils.ESCAPE_XML.with( UnicodeEscaper.above(0x7f) );
+          StringEscapeUtils.ESCAPE_XML.with( new UnicodeEscaper(Range.between(0x7f, Integer.MAX_VALUE)
) );
 </pre>
 <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>
 <pre>
-          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))
+              )
+          )
 </pre>
 <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>
 </section>



Mime
View raw message