Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
victormunoz committed May 29, 2017
1 parent 7f52c24 commit 8f5ec46
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/main/java/com/easyinnova/tiff/model/TagValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,27 @@ public int getCardinality() {
*/
public long getFirstNumericValue() {
String val = (value != null) ? value.get(0).toString() : readValue.get(0).toString();
return Long.parseLong(val);
if (isInteger(val)) {
return Long.parseLong(val);
} else {
return 0;
}
}

boolean isInteger(String s) {
return isInteger(s,10);
}

boolean isInteger(String s, int radix) {
if(s.isEmpty()) return false;
for(int i = 0; i < s.length(); i++) {
if(i == 0 && s.charAt(i) == '-') {
if(s.length() == 1) return false;
else continue;
}
if(Character.digit(s.charAt(i),radix) < 0) return false;
}
return true;
}

/**
Expand Down

0 comments on commit 8f5ec46

Please sign in to comment.