@@ -19,11 +19,18 @@ public final class NumberInput
19
19
final static String MAX_LONG_STR = String .valueOf (Long .MAX_VALUE );
20
20
21
21
/**
22
- * Fast method for parsing integers that are known to fit into
22
+ * Fast method for parsing unsigned integers that are known to fit into
23
23
* regular 32-bit signed int type. This means that length is
24
- * between 1 and 9 digits (inclusive)
24
+ * between 1 and 9 digits (inclusive) and there is no sign character.
25
25
*<p>
26
- * Note: public to let unit tests call it
26
+ * Note: public to let unit tests call it; not meant to be used by any
27
+ * code outside this package.
28
+ *
29
+ * @param ch Buffer that contains integer value to decode
30
+ * @param off Offset of the first digit character in buffer
31
+ * @param len Length of the number to decode (in characters)
32
+ *
33
+ * @return Decoded {@code int} value
27
34
*/
28
35
public static int parseInt (char [] ch , int off , int len )
29
36
{
@@ -52,7 +59,16 @@ public static int parseInt(char[] ch, int off, int len)
52
59
53
60
/**
54
61
* Helper method to (more) efficiently parse integer numbers from
55
- * String values.
62
+ * String values. Input String must be simple Java integer value.
63
+ * No range checks are made to verify that the value fits in 32-bit Java {@code int}:
64
+ * caller is expected to only calls this in cases where this can be guaranteed
65
+ * (basically: number of digits does not exceed 9)
66
+ *<p>
67
+ * NOTE: semantics differ significantly from {@link #parseInt(char[], int, int)}.
68
+ *
69
+ * @param s String that contains integer value to decode
70
+ *
71
+ * @return Decoded {@code int} value
56
72
*/
57
73
public static int parseInt (String s )
58
74
{
@@ -115,6 +131,13 @@ public static long parseLong(char[] ch, int off, int len)
115
131
return val + (long ) parseInt (ch , off +len1 , 9 );
116
132
}
117
133
134
+ /**
135
+ * Similar to {@link #parseInt(String)} but for {@code long} values.
136
+ *
137
+ * @param s String that contains {@code long} value to decode
138
+ *
139
+ * @return Decoded {@code long} value
140
+ */
118
141
public static long parseLong (String s )
119
142
{
120
143
// Ok, now; as the very first thing, let's just optimize case of "fake longs";
@@ -133,8 +156,14 @@ public static long parseLong(String s)
133
156
* Note that input String must NOT contain leading minus sign (even
134
157
* if 'negative' is set to true).
135
158
*
159
+ * @param ch Buffer that contains long value to check
160
+ * @param off Offset of the first digit character in buffer
161
+ * @param len Length of the number to decode (in characters)
136
162
* @param negative Whether original number had a minus sign (which is
137
163
* NOT passed to this method) or not
164
+ *
165
+ * @return {@code True} if specified String representation is within Java
166
+ * {@code long} range; {@code false} if not.
138
167
*/
139
168
public static boolean inLongRange (char [] ch , int off , int len ,
140
169
boolean negative )
@@ -157,8 +186,12 @@ public static boolean inLongRange(char[] ch, int off, int len,
157
186
* Similar to {@link #inLongRange(char[],int,int,boolean)}, but
158
187
* with String argument
159
188
*
189
+ * @param s String that contains {@code long} value to check
160
190
* @param negative Whether original number had a minus sign (which is
161
191
* NOT passed to this method) or not
192
+ *
193
+ * @return {@code True} if specified String representation is within Java
194
+ * {@code long} range; {@code false} if not.
162
195
*/
163
196
public static boolean inLongRange (String s , boolean negative )
164
197
{
0 commit comments