Skip to content

Commit c967d89

Browse files
committed
update Java version
1 parent 611ca15 commit c967d89

File tree

10 files changed

+89
-89
lines changed

10 files changed

+89
-89
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private String NextJSONString() {
6464
case 't':
6565
this.sb.append('\t');
6666
break;
67-
case 'u': { // Unicode escape
67+
case 'u': { // Unicode escape
6868
c = 0;
6969
// Consists of 4 hex digits
7070
for (int i = 0; i < 4; ++i) {
@@ -124,7 +124,7 @@ private String NextJSONString() {
124124
}
125125
}
126126
break;
127-
case 0x22: // double quote
127+
case 0x22: // double quote
128128
return this.sb.toString();
129129
default: {
130130
// NOTE: Assumes the character reader

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

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ private static CBORObject ConstructIntegerValue(int v) {
149149
CBORObject.ConstructIntegerValue(0);
150150

151151
static final int CBORObjectTypeArray = 4;
152-
static final int CBORObjectTypeBigInteger = 1; // all other integers
152+
static final int CBORObjectTypeBigInteger = 1; // all other integers
153153
static final int CBORObjectTypeByteString = 2;
154154
static final int CBORObjectTypeDouble = 8;
155155
static final int CBORObjectTypeExtendedDecimal = 9;
156156
static final int CBORObjectTypeExtendedFloat = 11;
157157
static final int CBORObjectTypeExtendedRational = 12;
158-
static final int CBORObjectTypeInteger = 0; // -(2^63).. (2^63-1)
158+
static final int CBORObjectTypeInteger = 0; // -(2^63).. (2^63-1)
159159
static final int CBORObjectTypeMap = 5;
160160
static final int CBORObjectTypeSimpleValue = 6;
161161
static final int CBORObjectTypeSingle = 7;
@@ -190,21 +190,21 @@ null, new CBORExtendedFloat(), new CBORExtendedRational()
190190
// 0 means length varies. -1 means invalid.
191191
private static final int[] ValueExpectedLengths = { 1, 1, 1, 1, 1, 1,
192192
1, 1, 1,
193-
1, 1, 1, 1, 1, 1, 1, // major type 0
193+
1, 1, 1, 1, 1, 1, 1, // major type 0
194194
1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 9, -1, -1, -1, -1,
195-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // major type 1
195+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // major type 1
196196
1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 9, -1, -1, -1, -1,
197-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, // major type 2
197+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, // major type 2
198198
17, 18, 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, -1, -1, -1, 0,
199-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, // major type 3
199+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, // major type 3
200200
17, 18, 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, -1, -1, -1, 0,
201-
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // major type 4
201+
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // major type 4
202202
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0,
203-
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // major type 5
203+
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // major type 5
204204
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0,
205-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // major type 6
205+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // major type 6
206206
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1,
207-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // major type 7
207+
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // major type 7
208208
1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 9, -1, -1, -1, -1 };
209209

210210
private static final byte[] ValueFalseBytes = { 0x66, 0x61, 0x6c,
@@ -1718,7 +1718,7 @@ public static void Write(String str, OutputStream stream) throws java.io.IOExcep
17181718
throw new NullPointerException("stream");
17191719
}
17201720
if (str == null) {
1721-
stream.write(0xf6); // Write null instead of String
1721+
stream.write(0xf6); // Write null instead of String
17221722
} else {
17231723
// TODO: Maybe change to unstreamed String in 3.0
17241724
WriteStreamedString(str, stream);
@@ -1741,7 +1741,7 @@ public static void Write(
17411741
throw new NullPointerException("stream");
17421742
}
17431743
if (str == null) {
1744-
stream.write(0xf6); // Write null instead of String
1744+
stream.write(0xf6); // Write null instead of String
17451745
} else {
17461746
CBOREncodeOptions noIndef =
17471747
options.And(CBOREncodeOptions.NoIndefLengthStrings);
@@ -1818,13 +1818,13 @@ public static void Write(EFloat bignum, OutputStream stream) throws java.io.IOEx
18181818
Write(bignum.getMantissa(), stream);
18191819
} else {
18201820
if (!BigIntFits(exponent)) {
1821-
stream.write(0xd9); // tag 265
1821+
stream.write(0xd9); // tag 265
18221822
stream.write(0x01);
18231823
stream.write(0x09);
1824-
stream.write(0x82); // array, length 2
1824+
stream.write(0x82); // array, length 2
18251825
} else {
1826-
stream.write(0xc5); // tag 5
1827-
stream.write(0x82); // array, length 2
1826+
stream.write(0xc5); // tag 5
1827+
stream.write(0x82); // array, length 2
18281828
}
18291829
Write(bignum.getExponent(), stream);
18301830
Write(bignum.getMantissa(), stream);
@@ -1874,9 +1874,9 @@ public static void Write(ERational rational, OutputStream stream) throws java.io
18741874
Write(rational.getNumerator(), stream);
18751875
return;
18761876
}
1877-
stream.write(0xd8); // tag 30
1877+
stream.write(0xd8); // tag 30
18781878
stream.write(0x1e);
1879-
stream.write(0x82); // array, length 2
1879+
stream.write(0x82); // array, length 2
18801880
Write(rational.getNumerator(), stream);
18811881
Write(rational.getDenominator(), stream);
18821882
}
@@ -1942,13 +1942,13 @@ public static void Write(EDecimal bignum, OutputStream stream) throws java.io.IO
19421942
Write(bignum.getMantissa(), stream);
19431943
} else {
19441944
if (!BigIntFits(exponent)) {
1945-
stream.write(0xd9); // tag 264
1945+
stream.write(0xd9); // tag 264
19461946
stream.write(0x01);
19471947
stream.write(0x08);
1948-
stream.write(0x82); // array, length 2
1948+
stream.write(0x82); // array, length 2
19491949
} else {
1950-
stream.write(0xc4); // tag 4
1951-
stream.write(0x82); // array, length 2
1950+
stream.write(0xc4); // tag 4
1951+
stream.write(0x82); // array, length 2
19521952
}
19531953
Write(bignum.getExponent(), stream);
19541954
Write(bignum.getMantissa(), stream);
@@ -2087,7 +2087,7 @@ public static void Write(long value, OutputStream stream) throws java.io.IOExcep
20872087
WritePositiveInt64(0, value, stream);
20882088
} else {
20892089
++value;
2090-
value = -value; // Will never overflow
2090+
value = -value; // Will never overflow
20912091
WritePositiveInt64(1, value, stream);
20922092
}
20932093
}
@@ -2796,31 +2796,31 @@ public int compareTo(CBORObject other) {
27962796
int simpleValueA = -1;
27972797
int simpleValueB = -1;
27982798
if (typeA == CBORObjectTypeSimpleValue) {
2799-
if (((Integer)objA).intValue() == 20) { // false
2799+
if (((Integer)objA).intValue() == 20) { // false
28002800
simpleValueA = 2;
2801-
} else if (((Integer)objA).intValue() == 21) { // true
2801+
} else if (((Integer)objA).intValue() == 21) { // true
28022802
simpleValueA = 3;
2803-
} else if (((Integer)objA).intValue() == 22) { // null
2803+
} else if (((Integer)objA).intValue() == 22) { // null
28042804
simpleValueA = 1;
2805-
} else if (((Integer)objA).intValue() == 23) { // undefined
2805+
} else if (((Integer)objA).intValue() == 23) { // undefined
28062806
simpleValueA = 0;
28072807
}
28082808
}
28092809
if (typeB == CBORObjectTypeSimpleValue) {
2810-
if (((Integer)objB).intValue() == 20) { // false
2810+
if (((Integer)objB).intValue() == 20) { // false
28112811
simpleValueB = 2;
2812-
} else if (((Integer)objB).intValue() == 21) { // true
2812+
} else if (((Integer)objB).intValue() == 21) { // true
28132813
simpleValueB = 3;
2814-
} else if (((Integer)objB).intValue() == 22) { // null
2814+
} else if (((Integer)objB).intValue() == 22) { // null
28152815
simpleValueB = 1;
2816-
} else if (((Integer)objB).intValue() == 23) { // undefined
2816+
} else if (((Integer)objB).intValue() == 23) { // undefined
28172817
simpleValueB = 0;
28182818
}
28192819
}
28202820
int cmp = 0;
28212821
if (simpleValueA >= 0 || simpleValueB >= 0) {
28222822
if (simpleValueB < 0) {
2823-
return -1; // B is not true, false, null, or undefined, so A is less
2823+
return -1; // B is not true, false, null, or undefined, so A is less
28242824
}
28252825
if (simpleValueA < 0) {
28262826
return 1;
@@ -3122,7 +3122,7 @@ public byte[] EncodeToBytes(CBOREncodeOptions options) {
31223122
intBytes = GetPositiveInt64Bytes(0, value);
31233123
} else {
31243124
++value;
3125-
value = -value; // Will never overflow
3125+
value = -value; // Will never overflow
31263126
intBytes = GetPositiveInt64Bytes(1, value);
31273127
}
31283128
if (!tagged) {
@@ -4099,12 +4099,12 @@ static CBORObject GetFixedLengthObject(
40994099
default: throw new CBORException("Unexpected data encountered");
41004100
}
41014101
}
4102-
if (majortype == 2) { // short byte String
4102+
if (majortype == 2) { // short byte String
41034103
byte[] ret = new byte[firstbyte - 0x40];
41044104
System.arraycopy(data, 1, ret, 0, firstbyte - 0x40);
41054105
return new CBORObject(CBORObjectTypeByteString, ret);
41064106
}
4107-
if (majortype == 3) { // short text String
4107+
if (majortype == 3) { // short text String
41084108
StringBuilder ret = new StringBuilder(firstbyte - 0x60);
41094109
DataUtilities.ReadUtf8FromBytes(data, 1, firstbyte - 0x60, ret, false);
41104110
return new CBORObject(CBORObjectTypeTextString, ret.toString());

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public CBORObject ReadForFirstByte(
174174
// The following doesn't check for major types 0 and 1,
175175
// since all of them are fixed-length types and are
176176
// handled in the call to GetFixedLengthObject.
177-
if (type == 2) { // Byte String
177+
if (type == 2) { // Byte String
178178
if (additional == 31) {
179179
// Streaming byte String
180180
java.io.ByteArrayOutputStream ms = null;
@@ -193,7 +193,7 @@ public CBORObject ReadForFirstByte(
193193
throw new CBORException("Length" + ToUnsignedBigInteger(len) +
194194
" is bigger than supported ");
195195
}
196-
if (nextByte != 0x40) { // NOTE: 0x40 means the empty byte String
196+
if (nextByte != 0x40) { // NOTE: 0x40 means the empty byte String
197197
ReadByteData(this.stream, len, ms);
198198
}
199199
}
@@ -231,7 +231,7 @@ public CBORObject ReadForFirstByte(
231231
return cbor;
232232
}
233233
}
234-
if (type == 3) { // Text String
234+
if (type == 3) { // Text String
235235
if (additional == 31) {
236236
// Streaming text String
237237
StringBuilder builder = new StringBuilder();
@@ -246,7 +246,7 @@ public CBORObject ReadForFirstByte(
246246
throw new CBORException("Length" + ToUnsignedBigInteger(len) +
247247
" is bigger than supported");
248248
}
249-
if (nextByte != 0x60) { // NOTE: 0x60 means the empty String
249+
if (nextByte != 0x60) { // NOTE: 0x60 means the empty String
250250
if (PropertyMap.ExceedsKnownLength(this.stream, len)) {
251251
// TODO: Remove following line in version 3.0
252252
PropertyMap.SkipStreamToEnd(this.stream);
@@ -306,7 +306,7 @@ public CBORObject ReadForFirstByte(
306306
return cbor;
307307
}
308308
}
309-
if (type == 4) { // Array
309+
if (type == 4) { // Array
310310
CBORObject cbor = CBORObject.NewArray();
311311
if (this.addSharedRef) {
312312
this.sharedRefs.AddObject(cbor);
@@ -362,7 +362,7 @@ public CBORObject ReadForFirstByte(
362362
--this.depth;
363363
return cbor;
364364
}
365-
if (type == 5) { // Map, type 5
365+
if (type == 5) { // Map, type 5
366366
CBORObject cbor = CBORObject.NewMap();
367367
if (this.addSharedRef) {
368368
this.sharedRefs.AddObject(cbor);
@@ -420,7 +420,7 @@ public CBORObject ReadForFirstByte(
420420
}
421421
return cbor;
422422
}
423-
if (type == 6) { // Tagged item
423+
if (type == 6) { // Tagged item
424424
ICBORTag taginfo = null;
425425
boolean haveFirstByte = false;
426426
int newFirstByte = -1;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public static EInteger BigIntegerFromDouble(double dbl) {
214214
if (floatExponent == 2047) {
215215
throw new ArithmeticException("Value is infinity or NaN");
216216
}
217-
value1 &= 0xfffff; // Mask out the exponent and sign
217+
value1 &= 0xfffff; // Mask out the exponent and sign
218218
if (floatExponent == 0) {
219219
++floatExponent;
220220
} else {

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ MutableNumber Multiply(int multiplicand) {
7676
int y0 = multiplicand;
7777
x0 &= 65535;
7878
x1 = (x1 >> 16) & 65535;
79-
int temp = (x0 * y0); // a * c
79+
int temp = (x0 * y0); // a * c
8080
result1 = (temp >> 16) & 65535;
8181
result0 = temp & 65535;
8282
result2 = 0;
83-
temp = (x1 * y0); // b * c
83+
temp = (x1 * y0); // b * c
8484
result2 += (temp >> 16) & 65535;
8585
result1 += temp & 65535;
8686
result2 += (result1 >> 16) & 65535;
@@ -109,22 +109,22 @@ MutableNumber Multiply(int multiplicand) {
109109
y0 &= 65535;
110110
x1 = (x1 >> 16) & 65535;
111111
y1 = (y1 >> 16) & 65535;
112-
int temp = (x0 * y0); // a * c
112+
int temp = (x0 * y0); // a * c
113113
result1 = (temp >> 16) & 65535;
114114
result0 = temp & 65535;
115-
temp = (x0 * y1); // a * d
115+
temp = (x0 * y1); // a * d
116116
result2 = (temp >> 16) & 65535;
117117
result1 += temp & 65535;
118118
result2 += (result1 >> 16) & 65535;
119119
result1 &= 65535;
120-
temp = (x1 * y0); // b * c
120+
temp = (x1 * y0); // b * c
121121
result2 += (temp >> 16) & 65535;
122122
result1 += temp & 65535;
123123
result2 += (result1 >> 16) & 65535;
124124
result1 &= 65535;
125125
result3 = (result2 >> 16) & 65535;
126126
result2 &= 65535;
127-
temp = (x1 * y1); // b * d
127+
temp = (x1 * y1); // b * d
128128
result3 += (temp >> 16) & 65535;
129129
result2 += temp & 65535;
130130
result3 += (result2 >> 16) & 65535;
@@ -302,9 +302,9 @@ MutableNumber Add(int augend) {
302302
}
303303
}
304304

305-
private int smallValue; // if integerMode is 0
306-
private MutableNumber mnum; // if integerMode is 1
307-
private EInteger largeValue; // if integerMode is 2
305+
private int smallValue; // if integerMode is 0
306+
private MutableNumber mnum; // if integerMode is 1
307+
private EInteger largeValue; // if integerMode is 2
308308
private int integerMode;
309309

310310
FastInteger2(int value) {

0 commit comments

Comments
 (0)