Removed duplicate Integer parsing code

master
Evan Harris 5 years ago
parent 4a1493e474
commit a44cad0c5b
No known key found for this signature in database
GPG Key ID: FF3BD4DA59FF9EDC
  1. 48
      airsonic-main/src/main/java/org/airsonic/player/service/metadata/JaudiotaggerParser.java

@ -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;
return parseIntegerPattern(trackNumber, TRACK_NUMBER_PATTERN);
}
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;
private Integer parseYear(String year) {
return parseIntegerPattern(year, YEAR_NUMBER_PATTERN);
}
private Integer parseYear(String year) {
if (year == null) {
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);
}
/**

Loading…
Cancel
Save