public class Properties extends JavaScriptObject {\r
\r
public static Properties create(String properties) {\r
- return (Properties) createImpl(wrapPropertiesString(properties));\r
+ String p = wrapPropertiesString(properties);\r
+ try {\r
+ return (Properties) createImpl(p);\r
+ } catch (Exception e) {\r
+ System.err.println("Error creating Properties: \n" + properties + "\n" + p + "\n" + e.getMessage());\r
+ return (Properties) createImpl("({})");\r
+ }\r
}\r
\r
public static final native JavaScriptObject createImpl(String properties) /*-{\r
- return eval(properties);\r
- }-*/;\r
+ return eval(properties);\r
+ }-*/;\r
\r
- protected static String wrapPropertiesString(String s) {\r
- return "({" + s.replaceFirst("^[({]+", "").replaceFirst("[})]+$", "") + "})";\r
+ public static String wrapPropertiesString(String s) {\r
+ String ret = "({"\r
+ + s.replaceFirst("^[({]+", "").replaceFirst("[})]+$", "")\r
+ .replaceAll(":\\s*([^\"'\\s])([^,}]+)\\s*", ":\"$1$2\"") + "})";\r
+ return ret;\r
}\r
\r
protected Properties() {\r
for (String k : keys()){\r
ret += k + ": '" + get(k) + "', ";\r
}\r
- return "({" + ret.replaceAll("[, ]+","") + "})";\r
+ return "({" + ret.replaceAll("[, ]+$","") + "})";\r
}\r
}\r