From d8e255cac8a262b4c20042b9aff467fd5fdd590c Mon Sep 17 00:00:00 2001 From: Claudio Barril Date: Sun, 7 Sep 2014 20:16:09 -0300 Subject: [PATCH] considering possibility of null positions --- .../exporter/VerticalPositionComparator.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/exporter/VerticalPositionComparator.java b/wise-webapp/src/main/java/com/wisemapping/exporter/VerticalPositionComparator.java index ccac4dd2..dfda0adc 100644 --- a/wise-webapp/src/main/java/com/wisemapping/exporter/VerticalPositionComparator.java +++ b/wise-webapp/src/main/java/com/wisemapping/exporter/VerticalPositionComparator.java @@ -10,9 +10,17 @@ public class VerticalPositionComparator implements Comparator { public int compare(TopicType o1, TopicType o2) { final String myPosition = o1.getPosition(); final String otherPosition = o2.getPosition(); - int myPositionY = Integer.parseInt(myPosition.split(",")[1]); - int otherPositionY = Integer.parseInt(otherPosition.split(",")[1]); - return myPositionY - otherPositionY; + int result; + if (otherPosition == null) { + result = -1; + } else if (myPosition == null) { + result = 1; + } else { + int myPositionY = Integer.parseInt(myPosition.split(",")[1]); + int otherPositionY = Integer.parseInt(otherPosition.split(",")[1]); + result = myPositionY - otherPositionY; + } + return result; } }