Skip to content

Commit 9e619ab

Browse files
committed
add more methods to ExtendedDecimal and ExtendedFloat
1 parent d9e9763 commit 9e619ab

25 files changed

+797
-199
lines changed

src/main/java/com/upokecenter/cbor/Base64.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static void ToBase64(
126126
}
127127
if (count < 0) {
128128
throw new IllegalArgumentException("count (" + count + ") is less than " +
129-
"0 ");
129+
"0 ");
130130
}
131131
if (count > data.length) {
132132
throw new IllegalArgumentException(
@@ -142,7 +142,7 @@ private static void ToBase64(
142142
str.append(alphabet.charAt((data[i] >> 2) & 63));
143143
str.append(alphabet.charAt(((data[i] & 3) << 4) + ((data[i + 1] >> 4) & 15)));
144144
str.append(alphabet.charAt(((data[i + 1] & 15) << 2) + ((data[i + 2] >> 6) &
145-
3)));
145+
3)));
146146
str.append(alphabet.charAt(data[i + 2] & 63));
147147
}
148148
int lenmod3 = count % 3;
@@ -151,7 +151,7 @@ private static void ToBase64(
151151
str.append(alphabet.charAt((data[i] >> 2) & 63));
152152
if (lenmod3 == 2) {
153153
str.append(alphabet.charAt(((data[i] & 3) << 4) + ((data[i + 1] >> 4) &
154-
15)));
154+
15)));
155155
str.append(alphabet.charAt((data[i + 1] & 15) << 2));
156156
if (padding) {
157157
str.append("=");
@@ -177,19 +177,19 @@ private static void WriteBase64(
177177
}
178178
if (offset < 0) {
179179
throw new IllegalArgumentException("offset (" + offset + ") is less than " +
180-
"0 ");
180+
"0 ");
181181
}
182182
if (offset > data.length) {
183183
throw new IllegalArgumentException("offset (" + offset + ") is more than " +
184-
data.length);
184+
data.length);
185185
}
186186
if (count < 0) {
187187
throw new IllegalArgumentException("count (" + count + ") is less than " +
188-
"0 ");
188+
"0 ");
189189
}
190190
if (count > data.length) {
191191
throw new IllegalArgumentException("count (" + count + ") is more than " +
192-
data.length);
192+
data.length);
193193
}
194194
if (data.length - offset < count) {
195195
throw new IllegalArgumentException("data's length minus " + offset + " (" +

src/main/java/com/upokecenter/cbor/CBORDataUtilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public static CBORObject ParseJSONNumber(
219219
return null;
220220
}
221221
if ((newScale == null && newScaleInt == 0) || (newScale != null &&
222-
newScale.signum() == 0)) {
222+
newScale.signum() == 0)) {
223223
// No fractional part
224224
if (mant != null && mant.CanFitInInt32()) {
225225
mantInt = mant.AsInt32();

src/main/java/com/upokecenter/cbor/CBORJson.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ static String NextJSONString(CharacterReader reader, int quote) {
8080
c <<= 4;
8181
c |= ch + 10 - 'a';
8282
} else {
83-
throw
84-
reader.NewError("Invalid Unicode escaped character"
85-
);
83+
throw reader.NewError("Invalid Unicode escaped character");
8684
}
8785
}
8886
break;
@@ -594,8 +592,7 @@ static void WriteJSONToInternal(
594592
for (Map.Entry<CBORObject, CBORObject> entry : objMap.entrySet()) {
595593
CBORObject key = entry.getKey();
596594
CBORObject value = entry.getValue();
597-
String str = (key.getItemType() ==
598-
CBORObject.CBORObjectTypeTextString) ?
595+
String str = (key.getItemType() == CBORObject.CBORObjectTypeTextString) ?
599596
((String)key.getThisItem()) : key.ToJSONString();
600597
stringMap.put(str, value);
601598
}

src/main/java/com/upokecenter/cbor/CBORObject.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* returns an empty array and the Type property, or "getType()" in Java,
6262
* returns TextString). This is because the natural ordering of these
6363
* instances is consistent with the Equals method.</p> <p><b>Thread
64-
* Safety:</b> </p> <p>CBOR objects that are numbers, "simple values" ,
64+
* Safety:</b> </p> <p>CBOR objects that are numbers, "simple values",
6565
* and text strings are immutable (their values can't be changed), so
6666
* they are inherently safe for use by multiple threads.</p> <p>CBOR
6767
* objects that are arrays, maps, and byte strings are mutable, but this
@@ -258,7 +258,7 @@ public static void AddTagHandler(BigInteger bigintTag, ICBORTag handler) {
258258
}
259259
if (bigintTag.signum() < 0) {
260260
throw new IllegalArgumentException("bigintTag.signum() (" +
261-
bigintTag.signum() + ") is less than " + "0");
261+
bigintTag.signum() + ") is less than 0");
262262
}
263263
if (bigintTag.bitLength() > 64) {
264264
throw new IllegalArgumentException("bigintTag.bitLength (" +
@@ -1372,7 +1372,7 @@ public byte[] GetByteString() {
13721372
public boolean HasTag(int tagValue) {
13731373
if (tagValue < 0) {
13741374
throw new IllegalArgumentException("tagValue (" + tagValue +
1375-
") is less than " + "0");
1375+
") is less than 0");
13761376
}
13771377
CBORObject obj = this;
13781378
while (true) {
@@ -3320,7 +3320,7 @@ public static CBORObject NewMap() {
33203320
public static CBORObject FromSimpleValue(int simpleValue) {
33213321
if (simpleValue < 0) {
33223322
throw new IllegalArgumentException("simpleValue (" + simpleValue +
3323-
") is less than " + "0");
3323+
") is less than 0");
33243324
}
33253325
if (simpleValue > 255) {
33263326
throw new IllegalArgumentException("simpleValue (" + simpleValue +
@@ -3767,7 +3767,7 @@ public static CBORObject FromObjectAndTag(
37673767
}
37683768
if (bigintTag.signum() < 0) {
37693769
throw new IllegalArgumentException("bigintTag's sign (" + bigintTag.signum() +
3770-
") is less than " + "0");
3770+
") is less than 0");
37713771
}
37723772
if (bigintTag.compareTo(UInt64MaxValue) > 0) {
37733773
throw new IllegalArgumentException(
@@ -3858,7 +3858,7 @@ public static CBORObject FromObjectAndTag(
38583858
int smallTag) {
38593859
if (smallTag < 0) {
38603860
throw new IllegalArgumentException("smallTag (" + smallTag +
3861-
") is less than " + "0");
3861+
") is less than 0");
38623862
}
38633863
ICBORTag tagconv = FindTagConverter(smallTag);
38643864
CBORObject c = FromObject(valueObValue);

src/main/java/com/upokecenter/cbor/CBORTypeFilter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public CBORTypeFilter WithArrayExactLength(
179179
}
180180
if (arrayLength < 0) {
181181
throw new IllegalArgumentException("arrayLength (" + arrayLength +
182-
") is less than " + "0");
182+
") is less than 0");
183183
}
184184
if (arrayLength < elements.length) {
185185
throw new IllegalArgumentException("arrayLength (" + arrayLength +
@@ -218,7 +218,7 @@ public CBORTypeFilter WithArrayMinLength(
218218
}
219219
if (arrayLength < 0) {
220220
throw new IllegalArgumentException("arrayLength (" + arrayLength +
221-
") is less than " + "0");
221+
") is less than 0");
222222
}
223223
if (arrayLength < elements.length) {
224224
throw new IllegalArgumentException("arrayLength (" + arrayLength +
@@ -243,7 +243,7 @@ public CBORTypeFilter WithArrayAnyLength() {
243243
}
244244
if (this.arrayLength < 0) {
245245
throw new IllegalArgumentException("this.arrayLength (" + this.arrayLength +
246-
") is less than " + "0");
246+
") is less than 0");
247247
}
248248
if (this.arrayLength < this.elements.length) {
249249
throw new IllegalArgumentException("this.arrayLength (" + this.arrayLength +
@@ -381,7 +381,7 @@ public boolean TagAllowed(BigInteger bigTag) {
381381
public boolean ArrayIndexAllowed(int index) {
382382
return (this.types & (1 << 4)) != 0 && index >= 0 && (this.anyArrayLength ||
383383
((this.arrayMinLength || index < this.arrayLength) && index >=
384-
0));
384+
0));
385385
}
386386

387387
/**

src/main/java/com/upokecenter/cbor/SharedRefs.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public CBORObject GetObject(long smallIndex) {
2828
}
2929
if (smallIndex > Integer.MAX_VALUE) {
3030
throw new CBORException("Index " + smallIndex +
31-
" is bigger than supported ");
31+
" is bigger than supported ");
3232
}
3333
int index = (int)smallIndex;
3434
if (index >= this.sharedObjects.size()) {
@@ -43,7 +43,7 @@ public CBORObject GetObject(BigInteger bigIndex) {
4343
}
4444
if (!bigIndex.canFitInInt()) {
4545
throw new CBORException("Index " + bigIndex +
46-
" is bigger than supported ");
46+
" is bigger than supported ");
4747
}
4848
int index = bigIndex.intValue();
4949
if (index >= this.sharedObjects.size()) {

src/main/java/com/upokecenter/cbor/StringOutput.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ public void WriteCodePoint(int codePoint) throws java.io.IOException {
8585
throw new IllegalArgumentException("ch is a surrogate");
8686
}
8787
this.outputStream.write((byte)(0xe0 | ((codePoint >> 12) &
88-
0x0f)));
88+
0x0f)));
8989
this.outputStream.write((byte)(0x80 | ((codePoint >> 6) & 0x3f)));
9090
this.outputStream.write((byte)(0x80 | (codePoint & 0x3f)));
9191
} else {
9292
this.outputStream.write((byte)(0xf0 | ((codePoint >> 18) &
93-
0x08)));
93+
0x08)));
9494
this.outputStream.write((byte)(0x80 | ((codePoint >> 12) &
95-
0x3f)));
95+
0x3f)));
9696
this.outputStream.write((byte)(0x80 | ((codePoint >> 6) & 0x3f)));
9797
this.outputStream.write((byte)(0x80 | (codePoint & 0x3f)));
9898
}
@@ -105,7 +105,7 @@ public void WriteCodePoint(int codePoint) throws java.io.IOException {
105105
}
106106
} else if (codePoint <= 0x10ffff) {
107107
this.builder.append((char)((((codePoint - 0x10000) >> 10) &
108-
0x3ff) + 0xd800));
108+
0x3ff) + 0xd800));
109109
this.builder.append((char)(((codePoint - 0x10000) & 0x3ff) + 0xdc00));
110110
}
111111
}

src/main/java/com/upokecenter/util/BigInteger.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3122,7 +3122,7 @@ public BigInteger PowBigIntVar(BigInteger power) {
31223122
int sign = power.signum();
31233123
if (sign < 0) {
31243124
throw new IllegalArgumentException(
3125-
"sign (" + sign + ") is less than " + "0");
3125+
"sign (" + sign + ") is less than 0");
31263126
}
31273127
BigInteger thisVar = this;
31283128
if (sign == 0) {
@@ -3158,7 +3158,7 @@ public BigInteger PowBigIntVar(BigInteger power) {
31583158
public BigInteger pow(int powerSmall) {
31593159
if (powerSmall < 0) {
31603160
throw new IllegalArgumentException("powerSmall (" + powerSmall +
3161-
") is less than " + "0");
3161+
") is less than 0");
31623162
}
31633163
BigInteger thisVar = this;
31643164
if (powerSmall == 0) {
@@ -3911,7 +3911,7 @@ public static BigInteger fromRadixSubstring(
39113911
}
39123912
if (endIndex < 0) {
39133913
throw new IllegalArgumentException("endIndex (" + endIndex +
3914-
") is less than " + "0");
3914+
") is less than 0");
39153915
}
39163916
if (endIndex > str.length()) {
39173917
throw new IllegalArgumentException("endIndex (" + endIndex +

src/main/java/com/upokecenter/util/BitShiftAccumulator.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public FastInteger GetDigitLength() {
4343
public void ShiftToDigits(FastInteger bits) {
4444
if (bits.signum() < 0) {
4545
throw new IllegalArgumentException("bits's sign (" + bits.signum() +
46-
") is less than " + "0");
46+
") is less than 0");
4747
}
4848
if (bits.CanFitInInt32()) {
4949
this.ShiftToDigitsInt(bits.AsInt32());
@@ -89,7 +89,7 @@ public BitShiftAccumulator (
8989
int olderDiscarded) {
9090
if (bigint.signum() < 0) {
9191
throw new IllegalArgumentException("bigint's sign (" + bigint.signum() +
92-
") is less than " + "0");
92+
") is less than 0");
9393
}
9494
if (bigint.canFitInInt()) {
9595
this.isSmall = true;
@@ -105,7 +105,7 @@ public BitShiftAccumulator (
105105
public static BitShiftAccumulator FromInt32(int smallNumber) {
106106
if (smallNumber < 0) {
107107
throw new IllegalArgumentException("smallNumber (" + smallNumber +
108-
") is less than " + "0");
108+
") is less than 0");
109109
}
110110
BitShiftAccumulator bsa = new BitShiftAccumulator(BigInteger.ZERO, 0, 0);
111111
bsa.shiftedSmall = smallNumber;
@@ -210,7 +210,7 @@ private FastInteger CalcKnownBitLength() {
210210
if (kb == 0) {
211211
++kb;
212212
}
213-
// System.out.println("{0:X8} kbl=" + (kb));
213+
// System.out.println("{0:X8} kbl=" + kb);
214214
return new FastInteger(kb);
215215
}
216216
return new FastInteger(this.shiftedBigInt.signum() == 0 ? 1 :
@@ -341,7 +341,7 @@ private void ShiftRightSmall(int bits) {
341341
*/
342342
public void ShiftToDigitsInt(int bits) {
343343
if (bits < 0) {
344-
throw new IllegalArgumentException("bits (" + bits + ") is less than " + "0");
344+
throw new IllegalArgumentException("bits (" + bits + ") is less than 0");
345345
}
346346
if (this.isSmall) {
347347
this.ShiftSmallToBits(bits);

src/main/java/com/upokecenter/util/DataUtilities.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static String GetUtf8String(
7474
}
7575
if (bytesCount < 0) {
7676
throw new IllegalArgumentException("bytesCount (" + bytesCount +
77-
") is less than " + "0");
77+
") is less than 0");
7878
}
7979
if (bytesCount > bytes.length) {
8080
throw new IllegalArgumentException("bytesCount (" + bytesCount +
@@ -609,7 +609,7 @@ public static int ReadUtf8FromBytes(
609609
}
610610
if (bytesCount < 0) {
611611
throw new IllegalArgumentException("bytesCount (" + bytesCount +
612-
") is less than " + "0");
612+
") is less than 0");
613613
}
614614
if (bytesCount > data.length) {
615615
throw new IllegalArgumentException("bytesCount (" + bytesCount +

0 commit comments

Comments
 (0)