X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Forg%2Fjson%2FProperty.java;h=b21fb1f49e0aca776e3b0530010f0869bf8c5b12;hb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;hp=ff33a04bca48233009d4f6f67445b31613aada84;hpb=e7338a61f3ce96dadf44ac80b2b32cc5ba4b94c8;p=jalview.git diff --git a/src/org/json/Property.java b/src/org/json/Property.java index ff33a04..b21fb1f 100644 --- a/src/org/json/Property.java +++ b/src/org/json/Property.java @@ -29,47 +29,63 @@ import java.util.Properties; /** * Converts a Property file data into JSONObject and back. + * * @author JSON.org * @version 2015-05-05 */ -public class Property { - /** - * Converts a property file object into a JSONObject. The property file object is a table of name value pairs. - * @param properties java.util.Properties - * @return JSONObject - * @throws JSONException - */ - public static JSONObject toJSONObject(java.util.Properties properties) throws JSONException { - // can't use the new constructor for Android support - // JSONObject jo = new JSONObject(properties == null ? 0 : properties.size()); - JSONObject jo = new JSONObject(); - if (properties != null && !properties.isEmpty()) { - Enumeration enumProperties = properties.propertyNames(); - while(enumProperties.hasMoreElements()) { - String name = (String)enumProperties.nextElement(); - jo.put(name, properties.getProperty(name)); - } - } - return jo; +public class Property +{ + /** + * Converts a property file object into a JSONObject. The property file object + * is a table of name value pairs. + * + * @param properties + * java.util.Properties + * @return JSONObject + * @throws JSONException + */ + public static JSONObject toJSONObject(java.util.Properties properties) + throws JSONException + { + // can't use the new constructor for Android support + // JSONObject jo = new JSONObject(properties == null ? 0 : + // properties.size()); + JSONObject jo = new JSONObject(); + if (properties != null && !properties.isEmpty()) + { + Enumeration enumProperties = properties.propertyNames(); + while (enumProperties.hasMoreElements()) + { + String name = (String) enumProperties.nextElement(); + jo.put(name, properties.getProperty(name)); + } } + return jo; + } - /** - * Converts the JSONObject into a property file object. - * @param jo JSONObject - * @return java.util.Properties - * @throws JSONException - */ - public static Properties toProperties(JSONObject jo) throws JSONException { - Properties properties = new Properties(); - if (jo != null) { - // Don't use the new entrySet API to maintain Android support - for (final String key : jo.keySet()) { - Object value = jo.opt(key); - if (!JSONObject.NULL.equals(value)) { - properties.put(key, value.toString()); - } - } + /** + * Converts the JSONObject into a property file object. + * + * @param jo + * JSONObject + * @return java.util.Properties + * @throws JSONException + */ + public static Properties toProperties(JSONObject jo) throws JSONException + { + Properties properties = new Properties(); + if (jo != null) + { + // Don't use the new entrySet API to maintain Android support + for (final String key : jo.keySet()) + { + Object value = jo.opt(key); + if (!JSONObject.NULL.equals(value)) + { + properties.put(key, value.toString()); } - return properties; + } } + return properties; + } }