Skip to content

Commit bf2dbda

Browse files
authored
Merge pull request #29 from winfriedgerlach/cleanup-redundant-casts
cleanup: reorder modifiers to comply with JLS; remove redundant casts
2 parents ad6c43f + c949421 commit bf2dbda

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

src/main/java/org/codehaus/stax2/ri/typed/ValueDecoderFactory.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ public DoubleArrayDecoder getDoubleArrayDecoder()
178178
public abstract static class DecoderBase
179179
extends TypedValueDecoder
180180
{
181-
final static long L_BILLION = 1000000000;
181+
static final long L_BILLION = 1000000000;
182182

183-
final static long L_MAX_INT = (long) Integer.MAX_VALUE;
183+
static final long L_MAX_INT = Integer.MAX_VALUE;
184184

185-
final static long L_MIN_INT = (long) Integer.MIN_VALUE;
185+
static final long L_MIN_INT = Integer.MIN_VALUE;
186186

187-
final static BigInteger BD_MIN_LONG = BigInteger.valueOf(Long.MIN_VALUE);
188-
final static BigInteger BD_MAX_LONG = BigInteger.valueOf(Long.MAX_VALUE);
187+
static final BigInteger BD_MIN_LONG = BigInteger.valueOf(Long.MIN_VALUE);
188+
static final BigInteger BD_MAX_LONG = BigInteger.valueOf(Long.MAX_VALUE);
189189

190190
/**
191191
* Pointer to the next character to check, within lexical value
@@ -319,7 +319,7 @@ protected int skipSignAndZeroes(char[] lexical, char ch, boolean hasSign, final
319319
*
320320
* @return Parsed integer value
321321
*/
322-
protected final static int parseInt(char[] digitChars, int start, int end)
322+
protected static final int parseInt(char[] digitChars, int start, int end)
323323
{
324324
/* This looks ugly, but appears to be the fastest way
325325
* (based on perf testing, profiling)
@@ -352,7 +352,7 @@ protected final static int parseInt(char[] digitChars, int start, int end)
352352
return num;
353353
}
354354

355-
protected final static int parseInt(int num, char[] digitChars, int start, int end)
355+
protected static final int parseInt(int num, char[] digitChars, int start, int end)
356356
{
357357
num = (num * 10) + (digitChars[start] - '0');
358358
if (++start < end) {
@@ -379,7 +379,7 @@ protected final static int parseInt(int num, char[] digitChars, int start, int e
379379
return num;
380380
}
381381

382-
protected final static int parseInt(String digitChars, int start, int end)
382+
protected static final int parseInt(String digitChars, int start, int end)
383383
{
384384
int num = digitChars.charAt(start) - '0';
385385
if (++start < end) {
@@ -409,7 +409,7 @@ protected final static int parseInt(String digitChars, int start, int end)
409409
return num;
410410
}
411411

412-
protected final static int parseInt(int num, String digitChars, int start, int end)
412+
protected static final int parseInt(int num, String digitChars, int start, int end)
413413
{
414414
num = (num * 10) + (digitChars.charAt(start) - '0');
415415
if (++start < end) {
@@ -436,20 +436,20 @@ protected final static int parseInt(int num, String digitChars, int start, int e
436436
return num;
437437
}
438438

439-
protected final static long parseLong(char[] digitChars, int start, int end)
439+
protected static final long parseLong(char[] digitChars, int start, int end)
440440
{
441441
// Note: caller must ensure length is [10, 18]
442442
int start2 = end-9;
443443
long val = parseInt(digitChars, start, start2) * L_BILLION;
444-
return val + (long) parseInt(digitChars, start2, end);
444+
return val + parseInt(digitChars, start2, end);
445445
}
446446

447-
protected final static long parseLong(String digitChars, int start, int end)
447+
protected static final long parseLong(String digitChars, int start, int end)
448448
{
449449
// Note: caller must ensure length is [10, 18]
450450
int start2 = end-9;
451451
long val = parseInt(digitChars, start, start2) * L_BILLION;
452-
return val + (long) parseInt(digitChars, start2, end);
452+
return val + parseInt(digitChars, start2, end);
453453
}
454454

455455
/*
@@ -492,7 +492,7 @@ protected String _clean(String str)
492492
/////////////////////////////////////////////////////
493493
*/
494494

495-
public final static class BooleanDecoder
495+
public static final class BooleanDecoder
496496
extends DecoderBase
497497
{
498498
protected boolean mValue;
@@ -579,7 +579,7 @@ public void decode(char[] lexical, int start, int end)
579579
}
580580
}
581581

582-
public final static class IntDecoder
582+
public static final class IntDecoder
583583
extends DecoderBase
584584
{
585585
protected int mValue;
@@ -627,7 +627,7 @@ public void decode(String lexical) throws IllegalArgumentException
627627
base += L_BILLION;
628628
}
629629
int i = parseInt(lexical, ptr, ptr+charsLeft);
630-
long l = base + (long) i;
630+
long l = base + i;
631631
if (neg) {
632632
l = -l;
633633
if (l >= L_MIN_INT) {
@@ -682,7 +682,7 @@ public void decode(char[] lexical, final int start, final int end)
682682
base += L_BILLION;
683683
}
684684
int i = parseInt(lexical, ptr, ptr+charsLeft);
685-
long l = base + (long) i;
685+
long l = base + i;
686686
if (neg) {
687687
l = -l;
688688
if (l >= L_MIN_INT) {
@@ -700,7 +700,7 @@ public void decode(char[] lexical, final int start, final int end)
700700
}
701701
}
702702

703-
public final static class LongDecoder
703+
public static final class LongDecoder
704704
extends DecoderBase
705705
{
706706
protected long mValue;
@@ -731,15 +731,15 @@ public void decode(String lexical)
731731
// Quick check for short (single-digit) values:
732732
int charsLeft = end-ptr;
733733
if (charsLeft == 0) {
734-
mValue = (long) (neg ? -nr : nr);
734+
mValue = (neg ? -nr : nr);
735735
return;
736736
}
737737
verifyDigits(lexical, ptr, end);
738738
// Note: charsLeft one less than total length (skipped first digit)
739739
// Can parse more cheaply, if it's really just an int...
740740
if (charsLeft <= 8) { // no overflow
741741
int i = parseInt(nr, lexical, ptr, ptr+charsLeft);
742-
mValue = (long) (neg ? -i : i);
742+
mValue = (neg ? -i : i);
743743
return;
744744
}
745745
// At this point, let's just push back the first digit... simpler
@@ -777,7 +777,7 @@ public void decode(char[] lexical, final int start, final int end)
777777
// Quick check for short (single-digit) values:
778778
int charsLeft = end-ptr;
779779
if (charsLeft == 0) {
780-
mValue = (long) (neg ? -nr : nr);
780+
mValue = (neg ? -nr : nr);
781781
return;
782782
}
783783
verifyDigits(lexical, start, end, ptr);
@@ -823,7 +823,7 @@ private long parseUsingBD(String lexical, boolean neg)
823823
}
824824
}
825825

826-
public final static class FloatDecoder
826+
public static final class FloatDecoder
827827
extends DecoderBase
828828
{
829829
protected float mValue;
@@ -915,7 +915,7 @@ public void decode(char[] lexical, int start, int end)
915915
}
916916
}
917917

918-
public final static class DoubleDecoder
918+
public static final class DoubleDecoder
919919
extends DecoderBase
920920
{
921921
protected double mValue;
@@ -1013,7 +1013,7 @@ public void decode(char[] lexical, int start, int end)
10131013
/////////////////////////////////////////////////////
10141014
*/
10151015

1016-
public final static class IntegerDecoder
1016+
public static final class IntegerDecoder
10171017
extends DecoderBase
10181018
{
10191019
protected BigInteger mValue;
@@ -1047,7 +1047,7 @@ public void decode(char[] lexical, int start, int end) throws IllegalArgumentExc
10471047
}
10481048
}
10491049

1050-
public final static class DecimalDecoder
1050+
public static final class DecimalDecoder
10511051
extends DecoderBase
10521052
{
10531053
protected BigDecimal mValue;
@@ -1086,7 +1086,7 @@ public void decode(char[] lexical, int start, int end) throws IllegalArgumentExc
10861086
}
10871087
}
10881088

1089-
public final static class QNameDecoder
1089+
public static final class QNameDecoder
10901090
extends DecoderBase
10911091
{
10921092
final NamespaceContext mNsCtxt;
@@ -1141,7 +1141,7 @@ protected QName resolveQName(String localName) throws IllegalArgumentException
11411141
protected QName resolveQName(String prefix, String localName)
11421142
throws IllegalArgumentException
11431143
{
1144-
if (prefix.length() == 0 || localName.length() == 0) {
1144+
if (prefix.isEmpty() || localName.isEmpty()) {
11451145
// either prefix or local name is empty String, illegal
11461146
throw constructInvalidValue(prefix+":"+localName);
11471147
}
@@ -1150,7 +1150,7 @@ protected QName resolveQName(String prefix, String localName)
11501150
* namespace' has empty URI)
11511151
*/
11521152
String uri = mNsCtxt.getNamespaceURI(prefix);
1153-
if (uri == null || uri.length() == 0) {
1153+
if (uri == null || uri.isEmpty()) {
11541154
throw new IllegalArgumentException("Value \""+lexicalDesc(prefix+":"+localName)+"\" not a valid QName: prefix '"+prefix+"' not bound to a namespace");
11551155
}
11561156
return new QName(uri, localName, prefix);
@@ -1177,13 +1177,13 @@ public abstract static class BaseArrayDecoder
11771177
* Let's use some modest array size for allocating initial
11781178
* result buffer
11791179
*/
1180-
protected final static int INITIAL_RESULT_BUFFER_SIZE = 40;
1180+
protected static final int INITIAL_RESULT_BUFFER_SIZE = 40;
11811181

11821182
/**
11831183
* When expanding 'small' result buffers, we will expand
11841184
* size by bigger factor than for larger ones.
11851185
*/
1186-
protected final static int SMALL_RESULT_BUFFER_SIZE = 4000;
1186+
protected static final int SMALL_RESULT_BUFFER_SIZE = 4000;
11871187

11881188
protected int mStart;
11891189

@@ -1223,7 +1223,7 @@ protected int calcNewSize(int currSize)
12231223
}
12241224
}
12251225

1226-
public final static class IntArrayDecoder
1226+
public static final class IntArrayDecoder
12271227
extends BaseArrayDecoder
12281228
{
12291229
int[] mResult;
@@ -1291,7 +1291,7 @@ public boolean decodeValue(char[] buffer, int start, int end) throws IllegalArgu
12911291

12921292
}
12931293

1294-
public final static class LongArrayDecoder
1294+
public static final class LongArrayDecoder
12951295
extends BaseArrayDecoder
12961296
{
12971297
long[] mResult;
@@ -1349,7 +1349,7 @@ public boolean decodeValue(char[] buffer, int start, int end) throws IllegalArgu
13491349
}
13501350
}
13511351

1352-
public final static class FloatArrayDecoder
1352+
public static final class FloatArrayDecoder
13531353
extends BaseArrayDecoder
13541354
{
13551355
float[] mResult;
@@ -1407,7 +1407,7 @@ public boolean decodeValue(char[] buffer, int start, int end) throws IllegalArgu
14071407
}
14081408
}
14091409

1410-
public final static class DoubleArrayDecoder
1410+
public static final class DoubleArrayDecoder
14111411
extends BaseArrayDecoder
14121412
{
14131413
double[] mResult;

0 commit comments

Comments
 (0)