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

remove tabs

Location:
applications/editors/josm/plugins/livegps/src/org/json
Files:
5 edited

Legend:

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

    r21622 r23191  
    7474 * <li>Values can be separated by <code>;</code> <small>(semicolon)</small> as
    7575 *     well as by <code>,</code> <small>(comma)</small>.</li>
    76  * <li>Numbers may have the 
     76 * <li>Numbers may have the
    7777 *     <code>0x-</code> <small>(hex)</small> prefix.</li>
    7878 * </ul>
     
    164164     */
    165165    public JSONArray(Collection collection) {
    166                 this.myArrayList = new ArrayList();
    167                 if (collection != null) {
    168                         Iterator iter = collection.iterator();
    169                         while (iter.hasNext()) {
    170                             Object o = iter.next();
    171                 this.myArrayList.add(JSONObject.wrap(o)); 
    172                         }
    173                 }
    174     }
    175 
    176    
     166        this.myArrayList = new ArrayList();
     167        if (collection != null) {
     168            Iterator iter = collection.iterator();
     169            while (iter.hasNext()) {
     170                Object o = iter.next();
     171                this.myArrayList.add(JSONObject.wrap(o));
     172            }
     173        }
     174    }
     175
     176
    177177    /**
    178178     * Construct a JSONArray from an array
     
    192192    }
    193193
    194      
     194
    195195    /**
    196196     * Get the object value associated with an index.
     
    765765        return this;
    766766    }
    767    
    768    
     767
     768
    769769    /**
    770770     * Remove an index and close the hole.
     
    774774     */
    775775    public Object remove(int index) {
    776         Object o = opt(index);
     776        Object o = opt(index);
    777777        this.myArrayList.remove(index);
    778778        return o;
  • applications/editors/josm/plugins/livegps/src/org/json/JSONException.java

    r21622 r23191  
    88public class JSONException extends Exception {
    99    /**
    10         *
    11         */
    12         private static final long serialVersionUID = 0;
    13         private Throwable cause;
     10    *
     11    */
     12    private static final long serialVersionUID = 0;
     13    private Throwable cause;
    1414
    1515    /**
  • 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.
  • applications/editors/josm/plugins/livegps/src/org/json/JSONString.java

    r21622 r23191  
    99 */
    1010public interface JSONString {
    11         /**
    12         * The <code>toJSONString</code> method allows a class to produce its own JSON
    13         * serialization.
    14         *
    15         * @return A strictly syntactically correct JSON text.
    16         */
    17         public String toJSONString();
     11    /**
     12    * The <code>toJSONString</code> method allows a class to produce its own JSON
     13    * serialization.
     14    *
     15    * @return A strictly syntactically correct JSON text.
     16    */
     17    public String toJSONString();
    1818}
  • applications/editors/josm/plugins/livegps/src/org/json/JSONTokener.java

    r21622 r23191  
    3939public class JSONTokener {
    4040
    41     private int         character;
    42         private boolean eof;
    43     private int         index;
    44     private int         line;
    45     private char        previous;
    46     private Reader      reader;
     41    private int     character;
     42    private boolean eof;
     43    private int     index;
     44    private int     line;
     45    private char    previous;
     46    private Reader  reader;
    4747    private boolean usePrevious;
    4848
     
    5454     */
    5555    public JSONTokener(Reader reader) {
    56         this.reader = reader.markSupported() ? 
    57                         reader : new BufferedReader(reader);
     56        this.reader = reader.markSupported() ?
     57                reader : new BufferedReader(reader);
    5858        this.eof = false;
    5959        this.usePrevious = false;
     
    109109        return -1;
    110110    }
    111    
     111
    112112    public boolean end() {
    113         return eof && !usePrevious;     
     113        return eof && !usePrevious;
    114114    }
    115115
     
    124124        if (end()) {
    125125            return false;
    126         } 
     126        }
    127127        back();
    128128        return true;
     
    138138        int c;
    139139        if (this.usePrevious) {
    140                 this.usePrevious = false;
     140            this.usePrevious = false;
    141141            c = this.previous;
    142142        } else {
    143                 try {
    144                     c = this.reader.read();
    145                 } catch (IOException exception) {
    146                     throw new JSONException(exception);
    147                 }
    148        
    149                 if (c <= 0) { // End of stream
    150                         this.eof = true;
    151                         c = 0;
    152                 } 
    153         }
    154         this.index += 1;
    155         if (this.previous == '\r') {
    156                 this.line += 1;
    157                 this.character = c == '\n' ? 0 : 1;
    158         } else if (c == '\n') {
    159                 this.line += 1;
    160                 this.character = 0;
    161         } else {
    162                 this.character += 1;
    163         }
    164         this.previous = (char) c;
     143            try {
     144                c = this.reader.read();
     145            } catch (IOException exception) {
     146                throw new JSONException(exception);
     147            }
     148
     149            if (c <= 0) { // End of stream
     150                this.eof = true;
     151                c = 0;
     152            }
     153        }
     154        this.index += 1;
     155        if (this.previous == '\r') {
     156            this.line += 1;
     157            this.character = c == '\n' ? 0 : 1;
     158        } else if (c == '\n') {
     159            this.line += 1;
     160            this.character = 0;
     161        } else {
     162            this.character += 1;
     163        }
     164        this.previous = (char) c;
    165165        return this.previous;
    166166    }
     
    204204             buffer[pos] = next();
    205205             if (end()) {
    206                  throw syntaxError("Substring bounds error");                 
     206                 throw syntaxError("Substring bounds error");
    207207             }
    208208             pos += 1;
     
    273273                case '\\':
    274274                case '/':
    275                         sb.append(c);
    276                         break;
     275                    sb.append(c);
     276                    break;
    277277                default:
    278278                    throw syntaxError("Illegal escape.");
     
    412412        return c;
    413413    }
    414    
     414
    415415
    416416    /**
Note: See TracChangeset for help on using the changeset viewer.