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

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 84ee1a3b6 Minor refactoring.
84ee1a3b6 is described below

commit 84ee1a3b66a68ef74f5fe5d9d0e930f911e1ca6d
Author: JamesBognar <[email protected]>
AuthorDate: Fri Jul 1 14:35:58 2022 -0400

    Minor refactoring.
---
 .../org/apache/juneau/internal/StringUtils.java    | 33 +++++++---------------
 .../org/apache/juneau/json/JsonParserSession.java  |  2 +-
 .../org/apache/juneau/parser/ParserReader.java     | 20 +++++++++++++
 3 files changed, 31 insertions(+), 24 deletions(-)

diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
index df372a537..86d2d16a3 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
@@ -33,7 +33,6 @@ import java.util.zip.*;
 import javax.xml.bind.*;
 
 import org.apache.juneau.*;
-import org.apache.juneau.parser.*;
 import org.apache.juneau.parser.ParseException;
 import org.apache.juneau.reflect.*;
 
@@ -83,28 +82,6 @@ public final class StringUtils {
                        base64m2[base64m1[i]] = (byte)i;
        }
 
-       /**
-        * Reads a numeric string from the specified reader.
-        *
-        * @param r The reader to read form.
-        * @return The parsed number string.
-        * @throws IOException Thrown by underlying stream.
-        */
-       public static String parseNumberString(ParserReader r) throws 
IOException {
-               r.mark();
-               int c = 0;
-               while (true) {
-                       c = r.read();
-                       if (c == -1)
-                               break;
-                       if (! numberChars.contains((char)c)) {
-                               r.unread();
-                               break;
-                       }
-               }
-               return r.getMarked();
-       }
-
        /**
         * Parses a number from the specified string.
         *
@@ -2858,4 +2835,14 @@ public final class StringUtils {
                        return join((Collection<?>)o, ", ");
                return o.toString();
        }
+
+       /**
+        * Returns <jk>true</jk> if the specified character is a valid number 
character.
+        *
+        * @param c The character to check.
+        * @return <jk>true</jk> if the specified character is a valid number 
character.
+        */
+       public static boolean isNumberChar(char c) {
+               return numberChars.contains(c);
+       }
 }
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
index 9229dd07a..227fcd064 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java
@@ -396,7 +396,7 @@ public final class JsonParserSession extends 
ReaderParserSession {
                int c = r.peek();
                if (c == '\'' || c == '"')
                        return parseNumber(r, parseString(r), type);
-               return parseNumber(r, parseNumberString(r), type);
+               return parseNumber(r, r.parseNumberString(), type);
        }
 
        private Number parseNumber(ParserReader r, String s, Class<? extends 
Number> type) throws ParseException {
diff --git 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserReader.java
 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserReader.java
index 4f8ac59de..d2dd920ac 100644
--- 
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserReader.java
+++ 
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserReader.java
@@ -396,6 +396,26 @@ public class ParserReader extends Reader implements 
Positionable {
        public final ParserReader replace(char c) throws IOException {
                return replace(c, 1);
        }
+       /**
+        * Reads a numeric string from the specified reader.
+        *
+        * @return The parsed number string.
+        * @throws IOException Thrown by underlying stream.
+        */
+       public String parseNumberString() throws IOException {
+               mark();
+               int c = 0;
+               while (true) {
+                       c = read();
+                       if (c == -1)
+                               break;
+                       if (! StringUtils.isNumberChar((char)c)) {
+                               unread();
+                               break;
+                       }
+               }
+               return getMarked();
+       }
 
        /**
         * Subclasses can override this method to provide additional filtering.

Reply via email to