Revision: 4432 http://vexi.svn.sourceforge.net/vexi/?rev=4432&view=rev Author: mkpg2 Date: 2012-08-16 00:30:29 +0000 (Thu, 16 Aug 2012) Log Message: ----------- Fix. NPE when calling Number.cast("").
Modified Paths: -------------- trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSNumber.java trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSU.java Modified: trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSNumber.java =================================================================== --- trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSNumber.java 2012-08-15 23:04:03 UTC (rev 4431) +++ trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSNumber.java 2012-08-16 00:30:29 UTC (rev 4432) @@ -63,8 +63,9 @@ JSNumber n; if(!(o instanceof JSNumber)){ String s = JSU.toString(o); + if(s.trim().isEmpty()) return null; n = tryParseString(s, formatConst); - if(n==null) throw new JSExn("Cannot cast to string: "+s); + if(n==null) throw new JSExn("Cannot cast to number: "+s); }else{ n = (JSNumber)o; } @@ -91,7 +92,9 @@ JS arg = args[0]; if("tryParseString".equals(methodStr)) { String s = JSU.toString(arg); - return tryParseString(s, -1); + JS format = null; + if(args.length>=2) format = args[1]; + return tryParseString(s, typeString2const(format)); }else if("cast".equals(methodStr)) { JS format = null; if(args.length>=2) format = args[1]; Modified: trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSU.java =================================================================== --- trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSU.java 2012-08-15 23:04:03 UTC (rev 4431) +++ trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSU.java 2012-08-16 00:30:29 UTC (rev 4432) @@ -211,6 +211,8 @@ } static final public JSNumber N(Number n) { + if(n==null) + return null; if(n instanceof Integer) return N(n.intValue()); if(n instanceof Rational) return N((Rational)n); return N(n.doubleValue()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn