Skip to content

Commit 14392bc

Browse files
committed
Using modern Java APIs
1 parent f7e8e8b commit 14392bc

File tree

21 files changed

+51
-55
lines changed

21 files changed

+51
-55
lines changed

src/org/beanio/internal/compiler/ParserFactorySupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ protected Property createProperty(PropertyConfig config) {
15271527
if (config.getComponentType() == ComponentConfig.SEGMENT) {
15281528
required = config.getMinOccurs() > 0 && !config.isNillable();
15291529
}
1530-
boolean matchNull = !required && new Integer(0).equals(config.getMinOccurs());
1530+
boolean matchNull = !required && Integer.valueOf(0).equals(config.getMinOccurs());
15311531

15321532
CollectionBean collection = new CollectionBean();
15331533
collection.setName(config.getName());
@@ -1538,7 +1538,7 @@ protected Property createProperty(PropertyConfig config) {
15381538
}
15391539
else {
15401540
boolean required = propertyStack.isEmpty();
1541-
boolean matchNull = !required && new Integer(0).equals(config.getMinOccurs());
1541+
boolean matchNull = !required && Integer.valueOf(0).equals(config.getMinOccurs());
15421542

15431543
Bean bean = new Bean();
15441544
bean.setName(config.getName());

src/org/beanio/internal/compiler/flat/FlatPreprocessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ else if (field.getLength() == null) {
360360
}
361361
}
362362
else {
363-
if (new Integer(-1).equals(field.getLength())) {
363+
if (Integer.valueOf(-1).equals(field.getLength())) {
364364
field.setLength(null);
365365
}
366366
}

src/org/beanio/internal/compiler/json/JsonParserFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected FieldFormat createFieldFormat(FieldConfig config, Class<?> type) {
147147
format.setJsonName(config.getJsonName());
148148
format.setJsonArray(config.isJsonArray());
149149
format.setJsonArrayIndex(config.getJsonArrayIndex());
150-
format.setLazy(config.getMinOccurs() != null && new Integer(0).equals(config.getMinOccurs()));
150+
format.setLazy(config.getMinOccurs() != null && Integer.valueOf(0).equals(config.getMinOccurs()));
151151
format.setNillable(true); // for now, allow any JSON field to be nullable
152152

153153
// default the JSON type based on the property type

src/org/beanio/internal/config/annotation/AnnotationParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ private static Integer toUnboundedValue(int n) {
754754
if (val == null) {
755755
return null;
756756
}
757-
if (val.compareTo(new Integer(0)) < 0) {
757+
if (val.compareTo(Integer.valueOf(0)) < 0) {
758758
return Integer.MAX_VALUE;
759759
}
760760
return val;

src/org/beanio/internal/parser/format/delimited/DelimitedMarshallingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public Entry(int position, String text) {
142142
}
143143

144144
public int compareTo(Entry o) {
145-
return new Integer(this.order).compareTo(o.order);
145+
return Integer.valueOf(this.order).compareTo(o.order);
146146
}
147147

148148
@Override

src/org/beanio/internal/parser/format/fixedlength/FixedLengthMarshallingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public Entry(int position, String text) {
133133
}
134134

135135
public int compareTo(Entry o) {
136-
return new Integer(this.order).compareTo(o.order);
136+
return Integer.valueOf(this.order).compareTo(o.order);
137137
}
138138

139139
@Override

src/org/beanio/internal/util/DebugUtil.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.beanio.internal.util;
22

33
import java.io.*;
4+
import java.nio.charset.StandardCharsets;
45

56
import org.beanio.internal.parser.format.FieldPadding;
67

@@ -45,13 +46,8 @@ public static String formatPadding(FieldPadding padding) {
4546
}
4647

4748
public static String toString(Debuggable c) {
48-
try {
49-
ByteArrayOutputStream out = new ByteArrayOutputStream();
50-
c.debug(new PrintStream(out));
51-
return new String(out.toByteArray(), "ASCII");
52-
}
53-
catch (UnsupportedEncodingException e) {
54-
throw new IllegalStateException(e);
55-
}
49+
ByteArrayOutputStream out = new ByteArrayOutputStream();
50+
c.debug(new PrintStream(out));
51+
return new String(out.toByteArray(), StandardCharsets.US_ASCII);
5652
}
5753
}

src/org/beanio/internal/util/JsonUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ public static Number toNumber(String text) throws NumberFormatException {
7575
return d;
7676
}
7777
else if (text.length() < INT_SIZE) {
78-
return new Integer(text);
78+
return Integer.valueOf(text);
7979
}
8080
else {
8181
Long n = new Long(text);
8282
if (n.intValue() == n.longValue()) {
83-
return new Integer(n.intValue());
83+
return Integer.valueOf(n.intValue());
8484
}
8585
return n;
8686
}

test/org/beanio/parser/annotation/AnnotationTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ public void testAnnotatedFields() {
113113
Assert.assertEquals("left", user.getHands()[0]);
114114
Assert.assertEquals("right", user.getHands()[1]);
115115
Assert.assertEquals(new GregorianCalendar(1970, 0, 1).getTime(), user.birthDate);
116-
Assert.assertEquals(new Integer(28), user.getAge());
116+
Assert.assertEquals(Integer.valueOf(28), user.getAge());
117117
Assert.assertEquals(2, user.letters.size());
118-
Assert.assertEquals(new Character('A'), user.letters.get(0));
119-
Assert.assertEquals(new Character('B'), user.letters.get(1));
118+
Assert.assertEquals(Character.valueOf('A'), user.letters.get(0));
119+
Assert.assertEquals(Character.valueOf('B'), user.letters.get(1));
120120
Assert.assertEquals(1, user.numbers.size());
121121
Assert.assertEquals(LinkedList.class, user.numbers.getClass());
122-
Assert.assertEquals(new Integer(1), user.numbers.get(0));
122+
Assert.assertEquals(Integer.valueOf(1), user.numbers.get(0));
123123
Assert.assertEquals("END", user.end);
124124

125125
Assert.assertEquals(input[i], m[i].marshal(user).toString());

test/org/beanio/parser/json/segment/JsonSegmentParserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void testSegment_JsonTypeObjectList() {
5656

5757
try {
5858
Map map = (Map) in.read();
59-
assertEquals(new Integer(2), map.get("count"));
59+
assertEquals(Integer.valueOf(2), map.get("count"));
6060

6161
List list = (List) map.get("friends");
6262
Person person = (Person) list.get(0);

0 commit comments

Comments
 (0)