Skip to content

Commit bc80463

Browse files
committed
update Java version
1 parent 08de2d9 commit bc80463

File tree

7 files changed

+52
-78
lines changed

7 files changed

+52
-78
lines changed

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -413,15 +413,13 @@ public CBORObject DateTimeFieldsToCBORObject(EInteger bigYear, int[]
413413
CBORObject.FromFloatingPointBits(ef.ToDoubleBits(), 8)
414414
.WithTag(1) :
415415
CBORObject.FromFloatingPointBits(ef.ToDoubleBits(), 8);
416-
default:
417-
throw new CBORException("Too big or small to fit an" +
416+
default: throw new CBORException("Too big or small to fit an" +
418417
"\u0020integer" + "\u0020or floating-point number");
419418
}
420419
} catch (IllegalArgumentException ex) {
421420
throw new CBORException(ex.getMessage(), ex);
422421
}
423-
default:
424-
throw new CBORException("Internal error");
422+
default: throw new CBORException("Internal error");
425423
}
426424
} catch (IllegalArgumentException ex) {
427425
throw new CBORException(ex.getMessage(), ex);

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,7 @@ private CBORObject NextJSONValue(
448448
}
449449
return obj;
450450
}
451-
default:
452-
this.RaiseError("Value can't be parsed.");
451+
default: this.RaiseError("Value can't be parsed.");
453452
break;
454453
}
455454
return null;
@@ -637,8 +636,7 @@ private CBORObject ParseJSONObject(int depth) {
637636
break;
638637
case '}':
639638
return CBORObject.FromRaw(myHashMap);
640-
default:
641-
this.RaiseError ("Expected a ',' or '}'");
639+
default: this.RaiseError("Expected a ',' or '}'");
642640
break;
643641
}
644642
}
@@ -677,8 +675,7 @@ CBORObject ParseJSONArray(int depth) {
677675
break;
678676
case ']':
679677
return CBORObject.FromRaw(myArrayList);
680-
default:
681-
this.RaiseError ("Expected a ',' or ']'");
678+
default: this.RaiseError("Expected a ',' or ']'");
682679
break;
683680
}
684681
}

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,7 @@ private CBORObject ParseJSONObject(int depth) {
649649
break;
650650
case '}':
651651
return CBORObject.FromRaw(myHashMap);
652-
default:
653-
this.RaiseError ("Expected a ',' or '}'");
652+
default: this.RaiseError("Expected a ',' or '}'");
654653
break;
655654
}
656655
}
@@ -689,8 +688,7 @@ CBORObject ParseJSONArray(int depth) {
689688
break;
690689
case ']':
691690
return CBORObject.FromRaw(myArrayList);
692-
default:
693-
this.RaiseError ("Expected a ',' or ']'");
691+
default: this.RaiseError("Expected a ',' or ']'");
694692
break;
695693
}
696694
}

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,7 @@ private CBORObject ParseJSONObject(int depth) {
551551
break;
552552
case '}':
553553
return CBORObject.FromRaw(myHashMap);
554-
default:
555-
this.RaiseError ("Expected a ',' or '}'");
554+
default: this.RaiseError("Expected a ',' or '}'");
556555
break;
557556
}
558557
}
@@ -591,8 +590,7 @@ CBORObject ParseJSONArray(int depth) {
591590
break;
592591
case ']':
593592
return CBORObject.FromRaw(myArrayList);
594-
default:
595-
this.RaiseError ("Expected a ',' or ']'");
593+
default: this.RaiseError("Expected a ',' or ']'");
596594
break;
597595
}
598596
}

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ static void WriteJSONToInternal(
285285
str = sb.toString();
286286
break;
287287
}
288-
default:
289-
str = key.ToJSONString (options);
288+
default: str = key.ToJSONString(options);
290289
break;
291290
}
292291
if (stringMap.containsKey(str)) {

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ private static CBORNumber RationalToNumber(
259259
options >= 6,
260260
options == 5 || options == 7);
261261
break;
262-
default:
263-
return null; // "Invalid options");
262+
default: return null; // "Invalid options");
264263
}
265264
return CBORNumber.FromERational(erat);
266265
} else {
@@ -1637,8 +1636,7 @@ public int compareTo(CBORNumber other) {
16371636
(ERational)objB);
16381637
break;
16391638
}
1640-
default:
1641-
throw new IllegalStateException(
1639+
default: throw new IllegalStateException(
16421640
"Unexpected data type");
16431641
}
16441642
} else {

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

+40-54
Original file line numberDiff line numberDiff line change
@@ -1841,8 +1841,7 @@ private long CalcEncodedSize(int depth) {
18411841
return size + 1;
18421842
case SimpleValue:
18431843
return size + (cbor.getSimpleValue() >= 24 ? 2 : 1);
1844-
default:
1845-
throw new IllegalStateException();
1844+
default: throw new IllegalStateException();
18461845
}
18471846
}
18481847

@@ -2089,9 +2088,8 @@ public static CBORObject FromString(String strValue) {
20892088
"surrogate code point.");
20902089
}
20912090
return new CBORObject(
2092-
strValue.length() == utf8Length ? CBORObjectTypeTextStringAscii :
2093-
CBORObjectTypeTextString,
2094-
strValue);
2091+
strValue.length() == utf8Length ? CBORObjectTypeTextStringAscii : CBORObjectTypeTextString,
2092+
strValue);
20952093
}
20962094

20972095
/**
@@ -3688,8 +3686,7 @@ public static void Write(EInteger bigint, OutputStream stream) throws java.io.IO
36883686
stream.write((byte)((datatype << 5) | 27));
36893687
stream.write(bytes, 0, byteCount);
36903688
break;
3691-
default:
3692-
stream.write ((datatype == 0) ?
3689+
default: stream.write((datatype == 0) ?
36933690
(byte)0xc2 : (byte)0xc3);
36943691
WritePositiveInt(2, byteCount, stream);
36953692
stream.write(bytes, 0, byteCount);
@@ -4173,8 +4170,7 @@ public long AsInt64Value() {
41734170
EInteger ei = (EInteger)this.getThisItem();
41744171
return ei.ToInt64Checked();
41754172
}
4176-
default:
4177-
throw new IllegalStateException("Not an integer type");
4173+
default: throw new IllegalStateException("Not an integer type");
41784174
}
41794175
}
41804176

@@ -4194,8 +4190,7 @@ public boolean CanValueFitInInt64() {
41944190
EInteger ei = (EInteger)this.getThisItem();
41954191
return ei.CanFitInInt64();
41964192
}
4197-
default:
4198-
return false;
4193+
default: return false;
41994194
}
42004195
}
42014196

@@ -4237,8 +4232,7 @@ public EInteger AsEIntegerValue() {
42374232
return EInteger.FromInt64((((Long)this.getThisItem()).longValue()));
42384233
case CBORObjectTypeEInteger:
42394234
return (EInteger)this.getThisItem();
4240-
default:
4241-
throw new IllegalStateException("Not an integer type");
4235+
default: throw new IllegalStateException("Not an integer type");
42424236
}
42434237
}
42444238

@@ -4260,8 +4254,7 @@ public long AsDoubleBits() {
42604254
switch (this.getType()) {
42614255
case FloatingPoint:
42624256
return ((Long)this.getThisItem()).longValue();
4263-
default:
4264-
throw new IllegalStateException("Not a floating-point" +
4257+
default: throw new IllegalStateException("Not a floating-point" +
42654258
"\u0020type");
42664259
}
42674260
}
@@ -4278,8 +4271,7 @@ public double AsDoubleValue() {
42784271
switch (this.getType()) {
42794272
case FloatingPoint:
42804273
return CBORUtilities.Int64BitsToDouble((((Long)this.getThisItem()).longValue()));
4281-
default:
4282-
throw new IllegalStateException("Not a floating-point" +
4274+
default: throw new IllegalStateException("Not a floating-point" +
42834275
"\u0020type");
42844276
}
42854277
}
@@ -4512,8 +4504,7 @@ public int compareTo(CBORObject other) {
45124504
GetDoubleBytes(other.AsDoubleBits(), 0));
45134505
break;
45144506
}
4515-
default:
4516-
throw new IllegalStateException("Unexpected data " +
4507+
default: throw new IllegalStateException("Unexpected data " +
45174508
"type");
45184509
}
45194510
} else if ((typeB == CBORObjectTypeInteger && typeA ==
@@ -4628,11 +4619,11 @@ private static byte[] GetDoubleBytes64(long valueBits, int tagbyte) {
46284619
(byte)((valueBits >> 24) & 0xff), (byte)((valueBits >> 16) & 0xff),
46294620
(byte)((valueBits >> 8) & 0xff), (byte)(valueBits & 0xff),
46304621
} : new byte[] { (byte)0xfb, (byte)((valueBits >> 56) & 0xff),
4631-
(byte)((valueBits >> 48) & 0xff), (byte)((valueBits >> 40) & 0xff),
4632-
(byte)((valueBits >> 32) & 0xff), (byte)((valueBits >> 24) & 0xff),
4633-
(byte)((valueBits >> 16) & 0xff), (byte)((valueBits >> 8) & 0xff),
4634-
(byte)(valueBits & 0xff),
4635-
};
4622+
(byte)((valueBits >> 48) & 0xff), (byte)((valueBits >> 40) & 0xff),
4623+
(byte)((valueBits >> 32) & 0xff), (byte)((valueBits >> 24) & 0xff),
4624+
(byte)((valueBits >> 16) & 0xff), (byte)((valueBits >> 8) & 0xff),
4625+
(byte)(valueBits & 0xff),
4626+
};
46364627
}
46374628

46384629
private static byte[] GetDoubleBytes(long valueBits, int tagbyte) {
@@ -4641,18 +4632,18 @@ private static byte[] GetDoubleBytes(long valueBits, int tagbyte) {
46414632
return tagbyte != 0 ? new byte[] { (byte)tagbyte, (byte)0xf9,
46424633
(byte)((bits >> 8) & 0xff), (byte)(bits & 0xff),
46434634
} : new byte[] { (byte)0xf9, (byte)((bits >> 8) & 0xff),
4644-
(byte)(bits & 0xff),
4645-
};
4635+
(byte)(bits & 0xff),
4636+
};
46464637
}
46474638
if (CBORUtilities.DoubleRetainsSameValueInSingle(valueBits)) {
46484639
bits = CBORUtilities.DoubleToRoundedSinglePrecision(valueBits);
46494640
return tagbyte != 0 ? new byte[] { (byte)tagbyte, (byte)0xfa,
46504641
(byte)((bits >> 24) & 0xff), (byte)((bits >> 16) & 0xff),
46514642
(byte)((bits >> 8) & 0xff), (byte)(bits & 0xff),
46524643
} : new byte[] { (byte)0xfa, (byte)((bits >> 24) & 0xff),
4653-
(byte)((bits >> 16) & 0xff), (byte)((bits >> 8) & 0xff),
4654-
(byte)(bits & 0xff),
4655-
};
4644+
(byte)((bits >> 16) & 0xff), (byte)((bits >> 8) & 0xff),
4645+
(byte)(bits & 0xff),
4646+
};
46564647
}
46574648
return GetDoubleBytes64(valueBits, tagbyte);
46584649
}
@@ -4953,8 +4944,7 @@ public boolean equals(CBORObject other) {
49534944
(((this.itemValue) == null) ? ((otherValue.itemValue) == null) : (this.itemValue).equals(otherValue.itemValue));
49544945
case CBORObjectTypeDouble:
49554946
return this.AsDoubleBits() == otherValue.AsDoubleBits();
4956-
default:
4957-
return ((this.itemValue) == null) ? ((otherValue.itemValue) == null) : (this.itemValue).equals(otherValue.itemValue);
4947+
default: return ((this.itemValue) == null) ? ((otherValue.itemValue) == null) : (this.itemValue).equals(otherValue.itemValue);
49584948
}
49594949
}
49604950

@@ -5790,8 +5780,7 @@ public static CBORObject FromFloatingPointBits(
57905780
return new CBORObject(CBORObjectTypeDouble, value);
57915781
case 8:
57925782
return new CBORObject(CBORObjectTypeDouble, floatingBits);
5793-
default:
5794-
throw new IllegalArgumentException("byteCount");
5783+
default: throw new IllegalArgumentException("byteCount");
57955784
}
57965785
}
57975786

@@ -5951,8 +5940,7 @@ public static int WriteFloatingPointValue(
59515940
case 8:
59525941
bits = CBORUtilities.DoubleToInt64Bits(doubleVal);
59535942
return WriteFloatingPointBits(outputStream, bits, 8);
5954-
default:
5955-
throw new IllegalArgumentException("byteCount");
5943+
default: throw new IllegalArgumentException("byteCount");
59565944
}
59575945
}
59585946

@@ -5995,8 +5983,7 @@ public static int WriteFloatingPointValue(
59955983
bits = Float.floatToRawIntBits(singleVal);
59965984
longbits = CBORUtilities.SingleToDoublePrecision(bits);
59975985
return WriteFloatingPointBits(outputStream, longbits, 8);
5998-
default:
5999-
throw new IllegalArgumentException("byteCount");
5986+
default: throw new IllegalArgumentException("byteCount");
60005987
}
60015988
}
60025989

@@ -6522,8 +6509,7 @@ static CBORObject GetFixedLengthObject(
65226509
(int)uadditional);
65236510
}
65246511
throw new CBORException("Unexpected data encountered");
6525-
default:
6526-
throw new CBORException("Unexpected data encountered");
6512+
default: throw new CBORException("Unexpected data encountered");
65276513
}
65286514
}
65296515
if (majortype == 2) { // short byte String
@@ -6804,16 +6790,16 @@ private static byte[] GetPositiveInt64Bytes(int type, long value) {
68046790
return value < 24 ? new byte[] { (byte)((byte)value | (byte)(type << 5)) } :
68056791
value <= 0xffL ? new byte[] { (byte)(24 | (type << 5)), (byte)(value & 0xff),
68066792
} : value <= 0xffffL ? new byte[] { (byte)(25 | (type << 5)),
6807-
(byte)((value >> 8) & 0xff), (byte)(value & 0xff),
6808-
} : value <= 0xffffffffL ? new byte[] { (byte)(26 | (type << 5)),
6809-
(byte)((value >> 24) & 0xff), (byte)((value >> 16) & 0xff),
6810-
(byte)((value >> 8) & 0xff), (byte)(value & 0xff),
6811-
} : new byte[] { (byte)(27 | (type << 5)), (byte)((value >> 56) & 0xff),
6812-
(byte)((value >> 48) & 0xff), (byte)((value >> 40) & 0xff),
6813-
(byte)((value >> 32) & 0xff), (byte)((value >> 24) & 0xff),
6814-
(byte)((value >> 16) & 0xff), (byte)((value >> 8) & 0xff),
6815-
(byte)(value & 0xff),
6816-
};
6793+
(byte)((value >> 8) & 0xff), (byte)(value & 0xff),
6794+
} : value <= 0xffffffffL ? new byte[] { (byte)(26 | (type << 5)),
6795+
(byte)((value >> 24) & 0xff), (byte)((value >> 16) & 0xff),
6796+
(byte)((value >> 8) & 0xff), (byte)(value & 0xff),
6797+
} : new byte[] { (byte)(27 | (type << 5)), (byte)((value >> 56) & 0xff),
6798+
(byte)((value >> 48) & 0xff), (byte)((value >> 40) & 0xff),
6799+
(byte)((value >> 32) & 0xff), (byte)((value >> 24) & 0xff),
6800+
(byte)((value >> 16) & 0xff), (byte)((value >> 8) & 0xff),
6801+
(byte)(value & 0xff),
6802+
};
68176803
}
68186804

68196805
private static byte[] GetPositiveIntBytes(int type, int value) {
@@ -6824,11 +6810,11 @@ private static byte[] GetPositiveIntBytes(int type, int value) {
68246810
return value < 24 ? new byte[] { (byte)((byte)value | (byte)(type << 5)) } :
68256811
value <= 0xff ? new byte[] { (byte)(24 | (type << 5)), (byte)(value & 0xff),
68266812
} : value <= 0xffff ? new byte[] { (byte)(25 | (type << 5)),
6827-
(byte)((value >> 8) & 0xff), (byte)(value & 0xff),
6828-
} : new byte[] { (byte)(26 | (type << 5)), (byte)((value >> 24) & 0xff),
6829-
(byte)((value >> 16) & 0xff), (byte)((value >> 8) & 0xff),
6830-
(byte)(value & 0xff),
6831-
};
6813+
(byte)((value >> 8) & 0xff), (byte)(value & 0xff),
6814+
} : new byte[] { (byte)(26 | (type << 5)), (byte)((value >> 24) & 0xff),
6815+
(byte)((value >> 16) & 0xff), (byte)((value >> 8) & 0xff),
6816+
(byte)(value & 0xff),
6817+
};
68326818
}
68336819

68346820
// Initialize fixed values for certain

0 commit comments

Comments
 (0)