Ignore:
Timestamp:
2010-09-15T18:56:19+02:00 (15 years ago)
Author:
stoecker
Message:

remove tabs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified applications/editors/josm/plugins/livegps/src/org/json/JSONObject.java

    r21622 r23191  
    155155     * @param jo A JSONObject.
    156156     * @param names An array of strings.
    157      * @throws JSONException 
     157     * @throws JSONException
    158158     * @exception JSONException If a value is a non-finite number or if a name is duplicated.
    159159     */
     
    161161        this();
    162162        for (int i = 0; i < names.length; i += 1) {
    163                 try {
    164                         putOnce(names[i], jo.opt(names[i]));
    165                 } catch (Exception ignore) {
    166                 }
     163            try {
     164                putOnce(names[i], jo.opt(names[i]));
     165            } catch (Exception ignore) {
     166            }
    167167        }
    168168    }
     
    235235     * @param map A map object that can be used to initialize the contents of
    236236     *  the JSONObject.
    237      * @throws JSONException 
     237     * @throws JSONException
    238238     */
    239239    public JSONObject(Map map) {
     
    455455
    456456    /**
    457      * Get the int value associated with a key. 
     457     * Get the int value associated with a key.
    458458     *
    459459     * @param key   A key string.
     
    512512
    513513    /**
    514      * Get the long value associated with a key. 
     514     * Get the long value associated with a key.
    515515     *
    516516     * @param key   A key string.
     
    596596        return this.map.containsKey(key);
    597597    }
    598    
    599    
     598
     599
    600600    /**
    601601     * Increment a property of a JSONObject. If there is no such property,
     
    608608     */
    609609    public JSONObject increment(String key) throws JSONException {
    610         Object value = opt(key);
    611         if (value == null) {
    612                 put(key, 1);
    613         } else {
    614                 if (value instanceof Integer) {
    615                         put(key, ((Integer)value).intValue() + 1);
    616                 } else if (value instanceof Long) {
    617                         put(key, ((Long)value).longValue() + 1);                       
    618                 } else if (value instanceof Double) {
    619                         put(key, ((Double)value).doubleValue() + 1);                           
    620                 } else if (value instanceof Float) {
    621                         put(key, ((Float)value).floatValue() + 1);                     
    622                     } else {
    623                         throw new JSONException("Unable to increment [" + key + "].");
    624                     }
    625             }
    626         return this;
     610        Object value = opt(key);
     611        if (value == null) {
     612            put(key, 1);
     613        } else {
     614            if (value instanceof Integer) {
     615                put(key, ((Integer)value).intValue() + 1);
     616            } else if (value instanceof Long) {
     617                put(key, ((Long)value).longValue() + 1);
     618            } else if (value instanceof Double) {
     619                put(key, ((Double)value).doubleValue() + 1);
     620            } else if (value instanceof Float) {
     621                put(key, ((Float)value).floatValue() + 1);
     622            } else {
     623                throw new JSONException("Unable to increment [" + key + "].");
     624            }
     625        }
     626        return this;
    627627    }
    628628
     
    903903        Class klass = bean.getClass();
    904904
    905 // If klass is a System class then set includeSuperClass to false. 
     905// If klass is a System class then set includeSuperClass to false.
    906906
    907907        boolean includeSuperClass = klass.getClassLoader() != null;
     
    916916                    String key = "";
    917917                    if (name.startsWith("get")) {
    918                         if (name.equals("getClass") || 
    919                                         name.equals("getDeclaringClass")) {
    920                                 key = "";
    921                         } else {
    922                                 key = name.substring(3);
    923                         }
     918                        if (name.equals("getClass") ||
     919                                name.equals("getDeclaringClass")) {
     920                            key = "";
     921                        } else {
     922                            key = name.substring(3);
     923                        }
    924924                    } else if (name.startsWith("is")) {
    925925                        key = name.substring(2);
     
    11991199
    12001200        /*
    1201          * If it might be a number, try converting it. 
    1202          * We support the non-standard 0x- convention. 
     1201         * If it might be a number, try converting it.
     1202         * We support the non-standard 0x- convention.
    12031203         * If a number cannot be produced, then the value will just
    12041204         * be a string. Note that the 0x-, plus, and implied string
     
    12171217            }
    12181218            try {
    1219                 if (s.indexOf('.') > -1 || 
    1220                                 s.indexOf('e') > -1 || s.indexOf('E') > -1) {
     1219                if (s.indexOf('.') > -1 ||
     1220                        s.indexOf('e') > -1 || s.indexOf('E') > -1) {
    12211221                    return Double.valueOf(s);
    12221222                } else {
     
    14951495
    14961496     /**
    1497       * Wrap an object, if necessary. If the object is null, return the NULL 
    1498       * object. If it is an array or collection, wrap it in a JSONArray. If 
    1499       * it is a map, wrap it in a JSONObject. If it is a standard property 
    1500       * (Double, String, et al) then it is already wrapped. Otherwise, if it 
    1501       * comes from one of the java packages, turn it into a string. And if 
     1497      * Wrap an object, if necessary. If the object is null, return the NULL
     1498      * object. If it is an array or collection, wrap it in a JSONArray. If
     1499      * it is a map, wrap it in a JSONObject. If it is a standard property
     1500      * (Double, String, et al) then it is already wrapped. Otherwise, if it
     1501      * comes from one of the java packages, turn it into a string. And if
    15021502      * it doesn't, try to wrap it in a JSONObject. If the wrapping fails,
    15031503      * then null is returned.
     
    15111511                 return NULL;
    15121512             }
    1513              if (object instanceof JSONObject || object instanceof JSONArray || 
    1514                         NULL.equals(object)      || object instanceof JSONString || 
    1515                         object instanceof Byte   || object instanceof Character ||
     1513             if (object instanceof JSONObject || object instanceof JSONArray ||
     1514                    NULL.equals(object)      || object instanceof JSONString ||
     1515                    object instanceof Byte   || object instanceof Character ||
    15161516                     object instanceof Short  || object instanceof Integer   ||
    1517                      object instanceof Long   || object instanceof Boolean   || 
     1517                     object instanceof Long   || object instanceof Boolean   ||
    15181518                     object instanceof Float  || object instanceof Double    ||
    15191519                     object instanceof String) {
    15201520                 return object;
    15211521             }
    1522              
     1522
    15231523             if (object instanceof Collection) {
    15241524                 return new JSONArray((Collection)object);
     
    15331533             String objectPackageName = ( objectPackage != null ? objectPackage.getName() : "" );
    15341534             if (objectPackageName.startsWith("java.") ||
    1535                         objectPackageName.startsWith("javax.") ||
    1536                         object.getClass().getClassLoader() == null) {
     1535                    objectPackageName.startsWith("javax.") ||
     1536                    object.getClass().getClassLoader() == null) {
    15371537                 return object.toString();
    15381538             }
     
    15431543     }
    15441544
    1545      
     1545
    15461546     /**
    15471547      * Write the contents of the JSONObject as JSON text to a writer.
Note: See TracChangeset for help on using the changeset viewer.