Methods Integer.parseInt/Boolean.parseBoolean should be preferred over Integer.valueOf/Boolean.valueOf/ if final result is primitive.
They are generally faster and generate less garbage.
String existingHandle = object.getHandleIdentifier();
int suffixPosition = existingHandle.indexOf('!');
if (suffixPosition != -1) {
- count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1;
+ count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1;
} else {
if (count == 1) {
count = 2;
String existingHandle = object.getHandleIdentifier();
int suffixPosition = existingHandle.indexOf('!');
if (suffixPosition != -1) {
- count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1;
+ count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1;
} else {
if (count == 1) {
count = 2;
int suffixPosition = existingHandle.lastIndexOf('!');
int lastSquareBracket = existingHandle.lastIndexOf('['); // type delimiter
if (suffixPosition != -1 && lastSquareBracket < suffixPosition) { // pr260384
- count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1;
+ count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1;
} else {
if (count == 1) {
count = 2;
int suffixPosition = existingHandle.lastIndexOf('!');
int lastSquareBracket = existingHandle.lastIndexOf('['); // type delimiter
if (suffixPosition != -1 && lastSquareBracket < suffixPosition) { // pr260384
- count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1;
+ count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1;
} else {
if (count == 1) {
count = 2;
String existingHandle = object.getHandleIdentifier();
int suffixPosition = existingHandle.indexOf('!');
if (suffixPosition != -1) {
- count = Integer.valueOf(existingHandle.substring(suffixPosition + 1)) + 1;
+ count = Integer.parseInt(existingHandle.substring(suffixPosition + 1)) + 1;
} else {
if (count == 1) {
count = 2;
if (-1 != loc)
s = s.substring(loc + 1);
try {
- exp[i] = Integer.valueOf(s);
+ exp[i] = Integer.parseInt(s);
sb.append(exp[i] + ((i < (exp.length - 1)) ? ", " : ""));
} catch (NumberFormatException e) {
info(handler, "bad " + label + ":" + expected[i]);
private static boolean getBoolean(String name, boolean def) {
String defaultValue = String.valueOf(def);
String value = System.getProperty(name, defaultValue);
- return Boolean.valueOf(value);
+ return Boolean.parseBoolean(value);
}
/*
protected static boolean getBoolean(String name, boolean def) {
String defaultValue = String.valueOf(def);
String value = System.getProperty(name,defaultValue);
- return Boolean.valueOf(value);
+ return Boolean.parseBoolean(value);
}
static {
description.setLength(0);
description.append((prefix + " " + suffix).trim());
try {
- result.setBugId(Integer.valueOf(pr));
+ result.setBugId(Integer.parseInt(pr));
} catch (NumberFormatException e) {
throw new Error("unable to convert " + pr + " for " + result
+ " at " + lineReader);
AjcTest.Spec test = new AjcTest.Spec();
test.setDescription(title);
test.setTestDirOffset(dir);
- test.setBugId(Integer.valueOf(pr));
+ test.setBugId(Integer.parseInt(pr));
test.setSourceLocation(sourceLocation);
//AjcTest test = new AjcTest(title, dir, pr, sourceLocation);
file = new File("XXX"); //XXX
}
- int line = Integer.valueOf(getAttributeString(child, "line"));
+ int line = Integer.parseInt(getAttributeString(child, "line"));
ISourceLocation sourceLocation = new SourceLocation(file, line, line, 0);
if (null != sourceLocation) {
throw new IllegalStateException("cannot set line after creating source location");
}
- this.line = Integer.valueOf(line);
+ this.line = Integer.parseInt(line);
SourceLocation.validLine(this.line);
}
}
private int convert(String in) {
- return Integer.valueOf(in);
+ return Integer.parseInt(in);
}
public String getLocationContext() {
try {
String value = System.getProperty(propertyName);
if (null != value) {
- return Boolean.valueOf(value);
+ return Boolean.parseBoolean(value);
}
} catch (Throwable t) {
// default below