You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/06/02 12:16:28 UTC

(commons-text) branch master updated (7f73e3ac -> 1bba8e3b)

This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git


    from 7f73e3ac Javadoc
     new 4e421276 Reuse CharUtils.isOctal()
     new 1bba8e3b Reduce vertical whitespace

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/text/translate/OctalUnescaper.java      | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)


(commons-text) 01/02: Reuse CharUtils.isOctal()

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 4e421276f45c6c36cc9f045c792855770190809e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jun 2 08:15:53 2026 -0400

    Reuse CharUtils.isOctal()
---
 .../apache/commons/text/translate/OctalUnescaper.java  | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java b/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java
index 9d787267..a5c97a2c 100644
--- a/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java
+++ b/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java
@@ -19,6 +19,8 @@ package org.apache.commons.text.translate;
 import java.io.IOException;
 import java.io.Writer;
 
+import org.apache.commons.lang3.CharUtils;
+
 /**
  * Translate escaped octal Strings back to their octal values.
  *
@@ -38,16 +40,6 @@ public class OctalUnescaper extends CharSequenceTranslator {
         // empty
     }
 
-    /**
-     * Tests if the given char is an octal digit. Octal digits are the character representations of the digits 0 to 7.
-     *
-     * @param ch the char to check.
-     * @return true if the given char is the character representation of one of the digits from 0 to 7.
-     */
-    private boolean isOctalDigit(final char ch) {
-        return ch >= '0' && ch <= '7';
-    }
-
     /**
      * Tests if the given char is the character representation of one of the digit from 0 to 3.
      *
@@ -65,7 +57,7 @@ public class OctalUnescaper extends CharSequenceTranslator {
     public int translate(final CharSequence input, final int index, final Writer writer) throws IOException {
         final int remaining = input.length() - index - 1; // how many characters left, ignoring the first \
         final StringBuilder builder = new StringBuilder();
-        if (input.charAt(index) == '\\' && remaining > 0 && isOctalDigit(input.charAt(index + 1))) {
+        if (input.charAt(index) == '\\' && remaining > 0 && CharUtils.isOctal(input.charAt(index + 1))) {
             final int next = index + 1;
             final int next2 = index + 2;
             final int next3 = index + 3;
@@ -73,9 +65,9 @@ public class OctalUnescaper extends CharSequenceTranslator {
             // we know this is good as we checked it in the if block above
             builder.append(input.charAt(next));
 
-            if (remaining > 1 && isOctalDigit(input.charAt(next2))) {
+            if (remaining > 1 && CharUtils.isOctal(input.charAt(next2))) {
                 builder.append(input.charAt(next2));
-                if (remaining > 2 && isZeroToThree(input.charAt(next)) && isOctalDigit(input.charAt(next3))) {
+                if (remaining > 2 && isZeroToThree(input.charAt(next)) && CharUtils.isOctal(input.charAt(next3))) {
                     builder.append(input.charAt(next3));
                 }
             }


(commons-text) 02/02: Reduce vertical whitespace

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git

commit 1bba8e3b90a155afb4e26ac7a8a1483e33d85a57
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jun 2 08:16:22 2026 -0400

    Reduce vertical whitespace
---
 src/main/java/org/apache/commons/text/translate/OctalUnescaper.java | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java b/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java
index a5c97a2c..2d6ecde6 100644
--- a/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java
+++ b/src/main/java/org/apache/commons/text/translate/OctalUnescaper.java
@@ -61,17 +61,14 @@ public class OctalUnescaper extends CharSequenceTranslator {
             final int next = index + 1;
             final int next2 = index + 2;
             final int next3 = index + 3;
-
             // we know this is good as we checked it in the if block above
             builder.append(input.charAt(next));
-
             if (remaining > 1 && CharUtils.isOctal(input.charAt(next2))) {
                 builder.append(input.charAt(next2));
                 if (remaining > 2 && isZeroToThree(input.charAt(next)) && CharUtils.isOctal(input.charAt(next3))) {
                     builder.append(input.charAt(next3));
                 }
             }
-
             writer.write(Integer.parseInt(builder.toString(), 8));
             return 1 + builder.length();
         }