Removed duplicate Integer parsing code
This commit is contained in:
+12
-38
@@ -219,42 +219,27 @@ public class JaudiotaggerParser extends MetaDataParser {
|
||||
* track numbers on the form "4/12".
|
||||
*/
|
||||
private Integer parseTrackNumber(String trackNumber) {
|
||||
if (trackNumber == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Integer result = null;
|
||||
|
||||
try {
|
||||
result = Integer.valueOf(trackNumber);
|
||||
} catch (NumberFormatException x) {
|
||||
Matcher matcher = TRACK_NUMBER_PATTERN.matcher(trackNumber);
|
||||
if (matcher.matches()) {
|
||||
try {
|
||||
result = Integer.valueOf(matcher.group(1));
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Integer.valueOf(0).equals(result)) {
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
return parseIntegerPattern(trackNumber, TRACK_NUMBER_PATTERN);
|
||||
}
|
||||
|
||||
private Integer parseYear(String year) {
|
||||
if (year == null) {
|
||||
return parseIntegerPattern(year, YEAR_NUMBER_PATTERN);
|
||||
}
|
||||
|
||||
private Integer parseIntegerPattern(String str, Pattern pattern) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Integer result = null;
|
||||
|
||||
try {
|
||||
result = Integer.valueOf(year);
|
||||
result = Integer.valueOf(str);
|
||||
} catch (NumberFormatException x) {
|
||||
Matcher matcher = YEAR_NUMBER_PATTERN.matcher(year);
|
||||
if (pattern == null) {
|
||||
return null;
|
||||
}
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
if (matcher.matches()) {
|
||||
try {
|
||||
result = Integer.valueOf(matcher.group(1));
|
||||
@@ -272,18 +257,7 @@ public class JaudiotaggerParser extends MetaDataParser {
|
||||
|
||||
private Integer parseInteger(String s) {
|
||||
s = StringUtils.trimToNull(s);
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Integer result = Integer.valueOf(s);
|
||||
if (Integer.valueOf(0).equals(result)) {
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
} catch (NumberFormatException x) {
|
||||
return null;
|
||||
}
|
||||
return parseIntegerPattern(s, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user