mirror of https://github.com/apache/poi.git
[github-260] Check XDGFCell value for null to avoid NullPointerException. Thanks to Dmitry Komarov.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1893988 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
56520578dd
commit
36cf0e943e
|
@ -39,9 +39,9 @@ import com.microsoft.schemas.office.visio.x2012.main.CellType;
|
||||||
public class XDGFCell {
|
public class XDGFCell {
|
||||||
|
|
||||||
public static Boolean maybeGetBoolean(Map<String, XDGFCell> cells,
|
public static Boolean maybeGetBoolean(Map<String, XDGFCell> cells,
|
||||||
String name) {
|
String name) {
|
||||||
XDGFCell cell = cells.get(name);
|
XDGFCell cell = cells.get(name);
|
||||||
if (cell == null)
|
if (cell == null || cell.getValue() == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (cell.getValue().equals("0"))
|
if (cell.getValue().equals("0"))
|
||||||
|
@ -61,7 +61,7 @@ public class XDGFCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer maybeGetInteger(Map<String, XDGFCell> cells,
|
public static Integer maybeGetInteger(Map<String, XDGFCell> cells,
|
||||||
String name) {
|
String name) {
|
||||||
XDGFCell cell = cells.get(name);
|
XDGFCell cell = cells.get(name);
|
||||||
if (cell != null)
|
if (cell != null)
|
||||||
return parseIntegerValue(cell._cell);
|
return parseIntegerValue(cell._cell);
|
||||||
|
@ -72,7 +72,7 @@ public class XDGFCell {
|
||||||
XDGFCell cell = cells.get(name);
|
XDGFCell cell = cells.get(name);
|
||||||
if (cell != null) {
|
if (cell != null) {
|
||||||
String v = cell._cell.getV();
|
String v = cell._cell.getV();
|
||||||
if (v.equals("Themed"))
|
if (v == null || v.equals("Themed"))
|
||||||
return null;
|
return null;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,9 @@ public class XDGFCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Double parseDoubleValue(CellType cell) {
|
public static Double parseDoubleValue(CellType cell) {
|
||||||
|
if (cell.getV() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return Double.parseDouble(cell.getV());
|
return Double.parseDouble(cell.getV());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
@ -91,6 +94,9 @@ public class XDGFCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer parseIntegerValue(CellType cell) {
|
public static Integer parseIntegerValue(CellType cell) {
|
||||||
|
if (cell.getV() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(cell.getV());
|
return Integer.parseInt(cell.getV());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
@ -106,6 +112,9 @@ public class XDGFCell {
|
||||||
* @return A value converted to inches
|
* @return A value converted to inches
|
||||||
*/
|
*/
|
||||||
public static Double parseVLength(CellType cell) {
|
public static Double parseVLength(CellType cell) {
|
||||||
|
if (cell.getV() == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return Double.parseDouble(cell.getV());
|
return Double.parseDouble(cell.getV());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|
Loading…
Reference in New Issue