0,0 → 1,52 |
package ak.hostadmiral.util; |
|
public abstract class StringConverter |
{ |
public static boolean isEmpty(Object o) |
{ |
if(o == null) |
return true; |
else if((o instanceof String) && ((String)o).equals("")) |
return true; |
else |
return false; |
} |
|
public static Long parseLong(Object o) |
throws NumberFormatException |
{ |
if(o instanceof String) { |
String s = (String)o; |
if(s == null || s.equals("")) |
return null; |
else |
return new Long(s); |
} |
else { |
throw new ClassCastException("String is expected, but it is " + o.getClass()); |
} |
} |
|
public static Integer parseInteger(Object o) |
throws NumberFormatException |
{ |
if(o instanceof String) { |
String s = (String)o; |
if(s == null || s.equals("")) |
return null; |
else |
return new Integer(s); |
} |
else { |
throw new ClassCastException("String is expected, but it is " + o.getClass()); |
} |
} |
|
public static String toString(Object o) |
{ |
if(o == null) |
return null; |
else |
return o.toString(); |
} |
} |