drtshock loves formatting, so I may as well

This commit is contained in:
gomeow
2013-04-12 10:54:25 -07:00
parent 678f61127e
commit 03a7b52a8e
22 changed files with 677 additions and 793 deletions
@@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender;
import com.drtshock.playervaults.util.Lang; import com.drtshock.playervaults.util.Lang;
public class Feedback { public class Feedback {
public enum Type { public enum Type {
OPEN, OPEN,
@@ -16,7 +16,6 @@ public class VaultOperations {
private static Main plugin; private static Main plugin;
private static VaultManager vm = new VaultManager(plugin); private static VaultManager vm = new VaultManager(plugin);
public static boolean checkPerms(CommandSender cs, int number) { public static boolean checkPerms(CommandSender cs, int number) {
if(cs.hasPermission("playervaults.amount." + String.valueOf(number))) return true; if(cs.hasPermission("playervaults.amount." + String.valueOf(number))) return true;
for(int x = number; x <= 99; x++) { for(int x = number; x <= 99; x++) {
@@ -39,8 +38,7 @@ public class VaultOperations {
number = Integer.parseInt(arg); number = Integer.parseInt(arg);
if(number == 0) if(number == 0)
return false; return false;
} } catch(NumberFormatException nfe) {
catch(NumberFormatException nfe) {
sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER);
return false; return false;
} }
@@ -78,8 +76,7 @@ public class VaultOperations {
number = Integer.parseInt(arg); number = Integer.parseInt(arg);
if(number == 0) if(number == 0)
return false; return false;
} } catch(NumberFormatException nfe) {
catch(NumberFormatException nfe) {
sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER);
} }
vm.loadVault(sender, user, number); vm.loadVault(sender, user, number);
@@ -109,8 +106,7 @@ public class VaultOperations {
if(number == 0) if(number == 0)
sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER);
return; return;
} } catch(NumberFormatException nfe) {
catch(NumberFormatException nfe) {
sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER);
} }
try { try {
@@ -143,8 +139,7 @@ public class VaultOperations {
sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER);
return; return;
} }
} } catch(NumberFormatException nfe) {
catch(NumberFormatException nfe) {
sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER);
} }
try { try {
@@ -10,6 +10,7 @@ import com.drtshock.playervaults.Main;
public class DropOnDeath { public class DropOnDeath {
public static Main plugin; public static Main plugin;
public DropOnDeath(Main instance) { public DropOnDeath(Main instance) {
DropOnDeath.plugin = instance; DropOnDeath.plugin = instance;
} }
@@ -25,6 +25,7 @@ public class EconomyOperations {
configFile = new File(plugin.getDataFolder(), "config.yml"); configFile = new File(plugin.getDataFolder(), "config.yml");
bukkitConfig.load(configFile); bukkitConfig.load(configFile);
} }
/** /**
* Have a player pay to open a vault. * Have a player pay to open a vault.
* Returns true if successful. Otherwise false. * Returns true if successful. Otherwise false.
@@ -32,7 +33,7 @@ public class EconomyOperations {
* @return transaction success * @return transaction success
*/ */
public static boolean payToOpen(Player player) { public static boolean payToOpen(Player player) {
if(!bukkitConfig.getBoolean("economy.enabled") || /*player.hasPermission("playervaults.free") || */!Main.useVault) if(!bukkitConfig.getBoolean("economy.enabled") || player.hasPermission("playervaults.free") || !Main.useVault)
return true; return true;
double cost = bukkitConfig.getDouble("economy.cost-to-open", 10); double cost = bukkitConfig.getDouble("economy.cost-to-open", 10);
@@ -44,6 +45,7 @@ public class EconomyOperations {
return false; return false;
} }
/** /**
* Have a player pay to create a vault. * Have a player pay to create a vault.
* Returns true if successful. Otherwise false. * Returns true if successful. Otherwise false.
@@ -51,7 +53,7 @@ public class EconomyOperations {
* @return transaction success * @return transaction success
*/ */
public static boolean payToCreate(Player player) { public static boolean payToCreate(Player player) {
if(!bukkitConfig.getBoolean("economy.enabled") || /*player.hasPermission("playervaults.free") || */!Main.useVault) if(!bukkitConfig.getBoolean("economy.enabled") || player.hasPermission("playervaults.free") || !Main.useVault)
return true; return true;
double cost = bukkitConfig.getDouble("economy.cost-to-create", 100); double cost = bukkitConfig.getDouble("economy.cost-to-create", 100);
@@ -239,7 +239,8 @@ public class Metrics {
try { try {
// This has to be synchronized or it can collide with the disable method. // This has to be synchronized or it can collide with the disable method.
synchronized (optOutLock) { synchronized (optOutLock) {
// Disable Task, if it is running and the server owner decided to opt-out // Disable Task, if it is running and the server owner decided to
// opt-out
if(isOptOut() && taskId > 0) { if(isOptOut() && taskId > 0) {
plugin.getServer().getScheduler().cancelTask(taskId); plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1; taskId = -1;
@@ -250,7 +251,8 @@ public class Metrics {
} }
} }
// We use the inverse of firstPost because if it is the first time we are posting, // We use the inverse of firstPost because if it is the first time we are
// posting,
// it is not a interval ping, so it evaluates to FALSE // it is not a interval ping, so it evaluates to FALSE
// Each time thereafter it will evaluate to TRUE, i.e PING! // Each time thereafter it will evaluate to TRUE, i.e PING!
postPlugin(!firstPost); postPlugin(!firstPost);
@@ -338,7 +340,8 @@ public class Metrics {
* @return the File object for the config file * @return the File object for the config file
*/ */
public File getConfigFile() { public File getConfigFile() {
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use // I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins
// to use
// is to abuse the plugin object we already have // is to abuse the plugin object we already have
// plugin.getDataFolder() => base/plugins/PluginA/ // plugin.getDataFolder() => base/plugins/PluginA/
// pluginsFolder => base/plugins/ // pluginsFolder => base/plugins/
@@ -353,7 +356,8 @@ public class Metrics {
* Generic method that posts a plugin to the metrics website * Generic method that posts a plugin to the metrics website
*/ */
private void postPlugin(final boolean isPing) throws IOException { private void postPlugin(final boolean isPing) throws IOException {
// The plugin's description file containg all of the plugin data such as name, version, author, etc // The plugin's description file containg all of the plugin data such as name, version,
// author, etc
final PluginDescriptionFile description = plugin.getDescription(); final PluginDescriptionFile description = plugin.getDescription();
// Construct the post data // Construct the post data
@@ -631,4 +635,3 @@ public class Metrics {
} }
} }
@@ -33,6 +33,7 @@ public class Serialization {
} }
return map; return map;
} }
private static Object fromJson(Object json) throws JSONException { private static Object fromJson(Object json) throws JSONException {
if(json == JSONObject.NULL) { if(json == JSONObject.NULL) {
return null; return null;
@@ -103,6 +104,7 @@ public class Serialization {
serialized.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(cs.getClass())); serialized.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(cs.getClass()));
return serialized; return serialized;
} }
public static Map<String, Object> recreateMap(Map<String, Object> original) { public static Map<String, Object> recreateMap(Map<String, Object> original) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
for(Entry<String, Object> entry:original.entrySet()) { for(Entry<String, Object> entry:original.entrySet()) {
@@ -114,7 +116,8 @@ public class Serialization {
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
public static ConfigurationSerializable deserialize(Map<String, Object> map) { public static ConfigurationSerializable deserialize(Map<String, Object> map) {
for(Entry<String, Object> entry:map.entrySet()) { for(Entry<String, Object> entry:map.entrySet()) {
// Check if any of its sub-maps are ConfigurationSerializable. They need to be done first. // Check if any of its sub-maps are ConfigurationSerializable. They need to be done
// first.
if(entry.getValue() instanceof Map && ((Map) entry.getValue()).containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) { if(entry.getValue() instanceof Map && ((Map) entry.getValue()).containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) {
entry.setValue(deserialize((Map) entry.getValue())); entry.setValue(deserialize((Map) entry.getValue()));
} }
@@ -40,14 +40,14 @@ public class Updater extends Main {
public String getNewVersion() { public String getNewVersion() {
return this.newVersion; return this.newVersion;
} }
public boolean getUpdate() throws Exception { public boolean getUpdate() throws Exception {
String version = this.version; String version = this.version;
URL url = new URL("http://dev.bukkit.org/server-mods/playervaults/files.rss"); URL url = new URL("http://dev.bukkit.org/server-mods/playervaults/files.rss");
InputStreamReader isr = null; InputStreamReader isr = null;
try { try {
isr = new InputStreamReader(url.openStream()); isr = new InputStreamReader(url.openStream());
} } catch(UnknownHostException e) {
catch(UnknownHostException e) {
return false; // Cannot connect return false; // Cannot connect
} }
BufferedReader in = new BufferedReader(isr); BufferedReader in = new BufferedReader(isr);
@@ -55,7 +55,20 @@ public class Updater extends Main {
int lineNum = 0; int lineNum = 0;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
if(line.length() != line.replace("<title>", "").length()) { if(line.length() != line.replace("<title>", "").length()) {
line = line.replaceAll("<title>", "").replaceAll("</title>", "").replaceAll(" ", "").substring(1); //Substring 1 for me, takes off the beginning v on my file name "v1.3.2" line = line.replaceAll("<title>", "").replaceAll("</title>", "").replaceAll(" ", "").substring(1); // Substring
// 1
// for
// me,
// takes
// off
// the
// beginning
// v
// on
// my
// file
// name
// "v1.3.2"
if(lineNum == 1) { if(lineNum == 1) {
this.newVersion = line; this.newVersion = line;
Integer newVer = Integer.parseInt(line.replace(".", "")); Integer newVer = Integer.parseInt(line.replace(".", ""));
@@ -18,6 +18,7 @@ import com.drtshock.playervaults.Main;
public class VaultManager { public class VaultManager {
public Main plugin; public Main plugin;
public VaultManager(Main instance) { public VaultManager(Main instance) {
this.plugin = instance; this.plugin = instance;
} }
+21 -22
View File
@@ -1,27 +1,27 @@
package org.json; package org.json;
/* /*
Copyright (c) 2002 JSON.org * Copyright (c) 2002 JSON.org
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in all * The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. * copies or substantial portions of the Software.
*
The Software shall be used for Good, not Evil. * The Software shall be used for Good, not Evil.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. * SOFTWARE.
*/ */
/** /**
@@ -233,7 +233,6 @@ public class CDL {
return ja; return ja;
} }
/** /**
* Produce a comma delimited text from a JSONArray of JSONObjects. The * Produce a comma delimited text from a JSONArray of JSONObjects. The
* first row will be a list of names obtained by inspecting the first * first row will be a list of names obtained by inspecting the first
+21 -23
View File
@@ -1,27 +1,27 @@
package org.json; package org.json;
/* /*
Copyright (c) 2002 JSON.org * Copyright (c) 2002 JSON.org
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in all * The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. * copies or substantial portions of the Software.
*
The Software shall be used for Good, not Evil. * The Software shall be used for Good, not Evil.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. * SOFTWARE.
*/ */
/** /**
@@ -62,7 +62,6 @@ public class Cookie {
return sb.toString(); return sb.toString();
} }
/** /**
* Convert a cookie specification string into a JSONObject. The string * Convert a cookie specification string into a JSONObject. The string
* will contain a name value pair separated by '='. The name and the value * will contain a name value pair separated by '='. The name and the value
@@ -104,7 +103,6 @@ public class Cookie {
return jo; return jo;
} }
/** /**
* Convert a JSONObject into a cookie specification string. The JSONObject * Convert a JSONObject into a cookie specification string. The JSONObject
* must contain "name" and "value" members. * must contain "name" and "value" members.
+21 -22
View File
@@ -1,27 +1,27 @@
package org.json; package org.json;
/* /*
Copyright (c) 2002 JSON.org * Copyright (c) 2002 JSON.org
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in all * The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. * copies or substantial portions of the Software.
*
The Software shall be used for Good, not Evil. * The Software shall be used for Good, not Evil.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. * SOFTWARE.
*/ */
import java.util.Iterator; import java.util.Iterator;
@@ -58,7 +58,6 @@ public class CookieList {
return jo; return jo;
} }
/** /**
* Convert a JSONObject into a cookie list. A cookie list is a sequence * Convert a JSONObject into a cookie list. A cookie list is a sequence
* of name/value pairs. The names are separated from the values by '='. * of name/value pairs. The names are separated from the values by '='.
+21 -21
View File
@@ -1,27 +1,27 @@
package org.json; package org.json;
/* /*
Copyright (c) 2002 JSON.org * Copyright (c) 2002 JSON.org
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in all * The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. * copies or substantial portions of the Software.
*
The Software shall be used for Good, not Evil. * The Software shall be used for Good, not Evil.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. * SOFTWARE.
*/ */
import java.util.Iterator; import java.util.Iterator;
+21 -22
View File
@@ -1,27 +1,27 @@
package org.json; package org.json;
/* /*
Copyright (c) 2002 JSON.org * Copyright (c) 2002 JSON.org
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in all * The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. * copies or substantial portions of the Software.
*
The Software shall be used for Good, not Evil. * The Software shall be used for Good, not Evil.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. * SOFTWARE.
*/ */
/** /**
@@ -40,7 +40,6 @@ public class HTTPTokener extends JSONTokener {
super(string); super(string);
} }
/** /**
* Get the next token or string. This is used in parsing HTTP headers. * Get the next token or string. This is used in parsing HTTP headers.
* @throws JSONException * @throws JSONException
+21 -68
View File
@@ -1,27 +1,27 @@
package org.json; package org.json;
/* /*
Copyright (c) 2002 JSON.org * Copyright (c) 2002 JSON.org
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in all * The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. * copies or substantial portions of the Software.
*
The Software shall be used for Good, not Evil. * The Software shall be used for Good, not Evil.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. * SOFTWARE.
*/ */
import java.io.IOException; import java.io.IOException;
@@ -81,13 +81,11 @@ import java.util.Map;
*/ */
public class JSONArray { public class JSONArray {
/** /**
* The arrayList where the JSONArray's properties are kept. * The arrayList where the JSONArray's properties are kept.
*/ */
private final ArrayList<Object> myArrayList; private final ArrayList<Object> myArrayList;
/** /**
* Construct an empty JSONArray. * Construct an empty JSONArray.
*/ */
@@ -132,7 +130,6 @@ public class JSONArray {
} }
} }
/** /**
* Construct a JSONArray from a source JSON text. * Construct a JSONArray from a source JSON text.
* @param source A string that begins with * @param source A string that begins with
@@ -144,7 +141,6 @@ public class JSONArray {
this(new JSONTokener(source)); this(new JSONTokener(source));
} }
/** /**
* Construct a JSONArray from a Collection. * Construct a JSONArray from a Collection.
* @param collection A Collection. * @param collection A Collection.
@@ -159,7 +155,6 @@ public class JSONArray {
} }
} }
/** /**
* Construct a JSONArray from an array * Construct a JSONArray from an array
* @throws JSONException If not an array. * @throws JSONException If not an array.
@@ -177,7 +172,6 @@ public class JSONArray {
} }
} }
/** /**
* Get the object value associated with an index. * Get the object value associated with an index.
* @param index * @param index
@@ -193,7 +187,6 @@ public class JSONArray {
return object; return object;
} }
/** /**
* Get the boolean value associated with an index. * Get the boolean value associated with an index.
* The string values "true" and "false" are converted to boolean. * The string values "true" and "false" are converted to boolean.
@@ -217,7 +210,6 @@ public class JSONArray {
throw new JSONException("JSONArray[" + index + "] is not a boolean."); throw new JSONException("JSONArray[" + index + "] is not a boolean.");
} }
/** /**
* Get the double value associated with an index. * Get the double value associated with an index.
* *
@@ -238,7 +230,6 @@ public class JSONArray {
} }
} }
/** /**
* Get the int value associated with an index. * Get the int value associated with an index.
* *
@@ -258,7 +249,6 @@ public class JSONArray {
} }
} }
/** /**
* Get the JSONArray associated with an index. * Get the JSONArray associated with an index.
* @param index The index must be between 0 and length() - 1. * @param index The index must be between 0 and length() - 1.
@@ -275,7 +265,6 @@ public class JSONArray {
"] is not a JSONArray."); "] is not a JSONArray.");
} }
/** /**
* Get the JSONObject associated with an index. * Get the JSONObject associated with an index.
* @param index subscript * @param index subscript
@@ -292,7 +281,6 @@ public class JSONArray {
"] is not a JSONObject."); "] is not a JSONObject.");
} }
/** /**
* Get the long value associated with an index. * Get the long value associated with an index.
* *
@@ -313,7 +301,6 @@ public class JSONArray {
} }
} }
/** /**
* Get the string associated with an index. * Get the string associated with an index.
* @param index The index must be between 0 and length() - 1. * @param index The index must be between 0 and length() - 1.
@@ -328,7 +315,6 @@ public class JSONArray {
throw new JSONException("JSONArray[" + index + "] not a string."); throw new JSONException("JSONArray[" + index + "] not a string.");
} }
/** /**
* Determine if the value is null. * Determine if the value is null.
* @param index The index must be between 0 and length() - 1. * @param index The index must be between 0 and length() - 1.
@@ -338,7 +324,6 @@ public class JSONArray {
return JSONObject.NULL.equals(this.opt(index)); return JSONObject.NULL.equals(this.opt(index));
} }
/** /**
* Make a string from the contents of this JSONArray. The * Make a string from the contents of this JSONArray. The
* <code>separator</code> string is inserted between each element. * <code>separator</code> string is inserted between each element.
@@ -360,7 +345,6 @@ public class JSONArray {
return sb.toString(); return sb.toString();
} }
/** /**
* Get the number of elements in the JSONArray, included nulls. * Get the number of elements in the JSONArray, included nulls.
* *
@@ -370,7 +354,6 @@ public class JSONArray {
return this.myArrayList.size(); return this.myArrayList.size();
} }
/** /**
* Get the optional object value associated with an index. * Get the optional object value associated with an index.
* @param index The index must be between 0 and length() - 1. * @param index The index must be between 0 and length() - 1.
@@ -383,7 +366,6 @@ public class JSONArray {
: this.myArrayList.get(index); : this.myArrayList.get(index);
} }
/** /**
* Get the optional boolean value associated with an index. * Get the optional boolean value associated with an index.
* It returns false if there is no value at that index, * It returns false if there is no value at that index,
@@ -396,7 +378,6 @@ public class JSONArray {
return this.optBoolean(index, false); return this.optBoolean(index, false);
} }
/** /**
* Get the optional boolean value associated with an index. * Get the optional boolean value associated with an index.
* It returns the defaultValue if there is no value at that index or if * It returns the defaultValue if there is no value at that index or if
@@ -414,7 +395,6 @@ public class JSONArray {
} }
} }
/** /**
* Get the optional double value associated with an index. * Get the optional double value associated with an index.
* NaN is returned if there is no value for the index, * NaN is returned if there is no value for the index,
@@ -427,7 +407,6 @@ public class JSONArray {
return this.optDouble(index, Double.NaN); return this.optDouble(index, Double.NaN);
} }
/** /**
* Get the optional double value associated with an index. * Get the optional double value associated with an index.
* The defaultValue is returned if there is no value for the index, * The defaultValue is returned if there is no value for the index,
@@ -445,7 +424,6 @@ public class JSONArray {
} }
} }
/** /**
* Get the optional int value associated with an index. * Get the optional int value associated with an index.
* Zero is returned if there is no value for the index, * Zero is returned if there is no value for the index,
@@ -458,7 +436,6 @@ public class JSONArray {
return this.optInt(index, 0); return this.optInt(index, 0);
} }
/** /**
* Get the optional int value associated with an index. * Get the optional int value associated with an index.
* The defaultValue is returned if there is no value for the index, * The defaultValue is returned if there is no value for the index,
@@ -475,7 +452,6 @@ public class JSONArray {
} }
} }
/** /**
* Get the optional JSONArray associated with an index. * Get the optional JSONArray associated with an index.
* @param index subscript * @param index subscript
@@ -487,7 +463,6 @@ public class JSONArray {
return o instanceof JSONArray ? (JSONArray) o : null; return o instanceof JSONArray ? (JSONArray) o : null;
} }
/** /**
* Get the optional JSONObject associated with an index. * Get the optional JSONObject associated with an index.
* Null is returned if the key is not found, or null if the index has * Null is returned if the key is not found, or null if the index has
@@ -501,7 +476,6 @@ public class JSONArray {
return o instanceof JSONObject ? (JSONObject) o : null; return o instanceof JSONObject ? (JSONObject) o : null;
} }
/** /**
* Get the optional long value associated with an index. * Get the optional long value associated with an index.
* Zero is returned if there is no value for the index, * Zero is returned if there is no value for the index,
@@ -514,7 +488,6 @@ public class JSONArray {
return this.optLong(index, 0); return this.optLong(index, 0);
} }
/** /**
* Get the optional long value associated with an index. * Get the optional long value associated with an index.
* The defaultValue is returned if there is no value for the index, * The defaultValue is returned if there is no value for the index,
@@ -531,7 +504,6 @@ public class JSONArray {
} }
} }
/** /**
* Get the optional string value associated with an index. It returns an * Get the optional string value associated with an index. It returns an
* empty string if there is no value at that index. If the value * empty string if there is no value at that index. If the value
@@ -544,7 +516,6 @@ public class JSONArray {
return this.optString(index, ""); return this.optString(index, "");
} }
/** /**
* Get the optional string associated with an index. * Get the optional string associated with an index.
* The defaultValue is returned if the key is not found. * The defaultValue is returned if the key is not found.
@@ -560,7 +531,6 @@ public class JSONArray {
: object.toString(); : object.toString();
} }
/** /**
* Append a boolean value. This increases the array's length by one. * Append a boolean value. This increases the array's length by one.
* *
@@ -572,7 +542,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Put a value in the JSONArray, where the value will be a * Put a value in the JSONArray, where the value will be a
* JSONArray which is produced from a Collection. * JSONArray which is produced from a Collection.
@@ -584,7 +553,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Append a double value. This increases the array's length by one. * Append a double value. This increases the array's length by one.
* *
@@ -599,7 +567,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Append an int value. This increases the array's length by one. * Append an int value. This increases the array's length by one.
* *
@@ -611,7 +578,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Append an long value. This increases the array's length by one. * Append an long value. This increases the array's length by one.
* *
@@ -623,7 +589,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Put a value in the JSONArray, where the value will be a * Put a value in the JSONArray, where the value will be a
* JSONObject which is produced from a Map. * JSONObject which is produced from a Map.
@@ -635,7 +600,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Append an object value. This increases the array's length by one. * Append an object value. This increases the array's length by one.
* @param value An object value. The value should be a * @param value An object value. The value should be a
@@ -648,7 +612,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Put or replace a boolean value in the JSONArray. If the index is greater * Put or replace a boolean value in the JSONArray. If the index is greater
* than the length of the JSONArray, then null elements will be added as * than the length of the JSONArray, then null elements will be added as
@@ -663,7 +626,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Put a value in the JSONArray, where the value will be a * Put a value in the JSONArray, where the value will be a
* JSONArray which is produced from a Collection. * JSONArray which is produced from a Collection.
@@ -678,7 +640,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Put or replace a double value. If the index is greater than the length of * Put or replace a double value. If the index is greater than the length of
* the JSONArray, then null elements will be added as necessary to pad * the JSONArray, then null elements will be added as necessary to pad
@@ -694,7 +655,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Put or replace an int value. If the index is greater than the length of * Put or replace an int value. If the index is greater than the length of
* the JSONArray, then null elements will be added as necessary to pad * the JSONArray, then null elements will be added as necessary to pad
@@ -709,7 +669,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Put or replace a long value. If the index is greater than the length of * Put or replace a long value. If the index is greater than the length of
* the JSONArray, then null elements will be added as necessary to pad * the JSONArray, then null elements will be added as necessary to pad
@@ -724,7 +683,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Put a value in the JSONArray, where the value will be a * Put a value in the JSONArray, where the value will be a
* JSONObject that is produced from a Map. * JSONObject that is produced from a Map.
@@ -739,7 +697,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Put or replace an object value in the JSONArray. If the index is greater * Put or replace an object value in the JSONArray. If the index is greater
* than the length of the JSONArray, then null elements will be added as * than the length of the JSONArray, then null elements will be added as
@@ -768,7 +725,6 @@ public class JSONArray {
return this; return this;
} }
/** /**
* Remove an index and close the hole. * Remove an index and close the hole.
* @param index The index of the element to be removed. * @param index The index of the element to be removed.
@@ -781,7 +737,6 @@ public class JSONArray {
return o; return o;
} }
/** /**
* Produce a JSONObject by combining a JSONArray of names with the values * Produce a JSONObject by combining a JSONArray of names with the values
* of this JSONArray. * of this JSONArray.
@@ -802,7 +757,6 @@ public class JSONArray {
return jo; return jo;
} }
/** /**
* Make a JSON text of this JSONArray. For compactness, no * Make a JSON text of this JSONArray. For compactness, no
* unnecessary whitespace is added. If it is not possible to produce a * unnecessary whitespace is added. If it is not possible to produce a
@@ -822,7 +776,6 @@ public class JSONArray {
} }
} }
/** /**
* Make a prettyprinted JSON text of this JSONArray. * Make a prettyprinted JSON text of this JSONArray.
* Warning: This method assumes that the data structure is acyclical. * Warning: This method assumes that the data structure is acyclical.
+23 -84
View File
@@ -1,27 +1,27 @@
package org.json; package org.json;
/* /*
Copyright (c) 2002 JSON.org * Copyright (c) 2002 JSON.org
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in all * The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. * copies or substantial portions of the Software.
*
The Software shall be used for Good, not Evil. * The Software shall be used for Good, not Evil.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. * SOFTWARE.
*/ */
import java.io.IOException; import java.io.IOException;
@@ -142,13 +142,11 @@ public class JSONObject {
} }
} }
/** /**
* The map where the JSONObject's properties are kept. * The map where the JSONObject's properties are kept.
*/ */
private final Map map; private final Map map;
/** /**
* It is sometimes more convenient and less ambiguous to have a * It is sometimes more convenient and less ambiguous to have a
* <code>NULL</code> object than to use Java's <code>null</code> value. * <code>NULL</code> object than to use Java's <code>null</code> value.
@@ -157,7 +155,6 @@ public class JSONObject {
*/ */
public static final Object NULL = new Null(); public static final Object NULL = new Null();
/** /**
* Construct an empty JSONObject. * Construct an empty JSONObject.
*/ */
@@ -165,7 +162,6 @@ public class JSONObject {
this.map = new HashMap(); this.map = new HashMap();
} }
/** /**
* Construct a JSONObject from a subset of another JSONObject. * Construct a JSONObject from a subset of another JSONObject.
* An array of strings is used to identify the keys that should be copied. * An array of strings is used to identify the keys that should be copied.
@@ -185,7 +181,6 @@ public class JSONObject {
} }
} }
/** /**
* Construct a JSONObject from a JSONTokener. * Construct a JSONObject from a JSONTokener.
* @param x A JSONTokener object containing the source string. * @param x A JSONTokener object containing the source string.
@@ -242,7 +237,6 @@ public class JSONObject {
} }
} }
/** /**
* Construct a JSONObject from a Map. * Construct a JSONObject from a Map.
* *
@@ -264,7 +258,6 @@ public class JSONObject {
} }
} }
/** /**
* Construct a JSONObject from an Object using bean getters. * Construct a JSONObject from an Object using bean getters.
* It reflects on all of the public methods of the object. * It reflects on all of the public methods of the object.
@@ -289,7 +282,6 @@ public class JSONObject {
this.populateMap(bean); this.populateMap(bean);
} }
/** /**
* Construct a JSONObject from an Object, using reflection to find the * Construct a JSONObject from an Object, using reflection to find the
* public members. The resulting JSONObject's keys will be the strings * public members. The resulting JSONObject's keys will be the strings
@@ -313,7 +305,6 @@ public class JSONObject {
} }
} }
/** /**
* Construct a JSONObject from a source JSON text string. * Construct a JSONObject from a source JSON text string.
* This is the most commonly used JSONObject constructor. * This is the most commonly used JSONObject constructor.
@@ -327,7 +318,6 @@ public class JSONObject {
this(new JSONTokener(source)); this(new JSONTokener(source));
} }
/** /**
* Construct a JSONObject from a ResourceBundle. * Construct a JSONObject from a ResourceBundle.
* @param baseName The ResourceBundle base name. * @param baseName The ResourceBundle base name.
@@ -367,7 +357,6 @@ public class JSONObject {
} }
} }
/** /**
* Accumulate values under a key. It is similar to the put method except * Accumulate values under a key. It is similar to the put method except
* that if there is already an object stored under the key then a * that if there is already an object stored under the key then a
@@ -402,7 +391,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Append values to the array under a key. If the key does not exist in the * Append values to the array under a key. If the key does not exist in the
* JSONObject, then the key is put in the JSONObject with its value being a * JSONObject, then the key is put in the JSONObject with its value being a
@@ -428,7 +416,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Produce a string from a double. The string "null" will be returned if * Produce a string from a double. The string "null" will be returned if
* the number is not finite. * the number is not finite.
@@ -455,7 +442,6 @@ public class JSONObject {
return string; return string;
} }
/** /**
* Get the value object associated with a key. * Get the value object associated with a key.
* *
@@ -475,7 +461,6 @@ public class JSONObject {
return object; return object;
} }
/** /**
* Get the boolean value associated with a key. * Get the boolean value associated with a key.
* *
@@ -499,7 +484,6 @@ public class JSONObject {
"] is not a Boolean."); "] is not a Boolean.");
} }
/** /**
* Get the double value associated with a key. * Get the double value associated with a key.
* @param key A key string. * @param key A key string.
@@ -519,7 +503,6 @@ public class JSONObject {
} }
} }
/** /**
* Get the int value associated with a key. * Get the int value associated with a key.
* *
@@ -540,7 +523,6 @@ public class JSONObject {
} }
} }
/** /**
* Get the JSONArray value associated with a key. * Get the JSONArray value associated with a key.
* *
@@ -558,7 +540,6 @@ public class JSONObject {
"] is not a JSONArray."); "] is not a JSONArray.");
} }
/** /**
* Get the JSONObject value associated with a key. * Get the JSONObject value associated with a key.
* *
@@ -576,7 +557,6 @@ public class JSONObject {
"] is not a JSONObject."); "] is not a JSONObject.");
} }
/** /**
* Get the long value associated with a key. * Get the long value associated with a key.
* *
@@ -597,7 +577,6 @@ public class JSONObject {
} }
} }
/** /**
* Get an array of field names from a JSONObject. * Get an array of field names from a JSONObject.
* *
@@ -618,7 +597,6 @@ public class JSONObject {
return names; return names;
} }
/** /**
* Get an array of field names from an Object. * Get an array of field names from an Object.
* *
@@ -641,7 +619,6 @@ public class JSONObject {
return names; return names;
} }
/** /**
* Get the string associated with a key. * Get the string associated with a key.
* *
@@ -658,7 +635,6 @@ public class JSONObject {
"] not a string."); "] not a string.");
} }
/** /**
* Determine if the JSONObject contains a specific key. * Determine if the JSONObject contains a specific key.
* @param key A key string. * @param key A key string.
@@ -668,7 +644,6 @@ public class JSONObject {
return this.map.containsKey(key); return this.map.containsKey(key);
} }
/** /**
* Increment a property of a JSONObject. If there is no such property, * Increment a property of a JSONObject. If there is no such property,
* create one with a value of 1. If there is such a property, and if * create one with a value of 1. If there is such a property, and if
@@ -696,7 +671,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Determine if the value associated with the key is null or if there is * Determine if the value associated with the key is null or if there is
* no value. * no value.
@@ -708,7 +682,6 @@ public class JSONObject {
return JSONObject.NULL.equals(this.opt(key)); return JSONObject.NULL.equals(this.opt(key));
} }
/** /**
* Get an enumeration of the keys of the JSONObject. * Get an enumeration of the keys of the JSONObject.
* *
@@ -718,7 +691,6 @@ public class JSONObject {
return this.keySet().iterator(); return this.keySet().iterator();
} }
/** /**
* Get a set of keys of the JSONObject. * Get a set of keys of the JSONObject.
* *
@@ -728,7 +700,6 @@ public class JSONObject {
return this.map.keySet(); return this.map.keySet();
} }
/** /**
* Get the number of keys stored in the JSONObject. * Get the number of keys stored in the JSONObject.
* *
@@ -738,7 +709,6 @@ public class JSONObject {
return this.map.size(); return this.map.size();
} }
/** /**
* Produce a JSONArray containing the names of the elements of this * Produce a JSONArray containing the names of the elements of this
* JSONObject. * JSONObject.
@@ -782,7 +752,6 @@ public class JSONObject {
return string; return string;
} }
/** /**
* Get an optional value associated with a key. * Get an optional value associated with a key.
* @param key A key string. * @param key A key string.
@@ -792,7 +761,6 @@ public class JSONObject {
return key == null ? null : this.map.get(key); return key == null ? null : this.map.get(key);
} }
/** /**
* Get an optional boolean associated with a key. * Get an optional boolean associated with a key.
* It returns false if there is no such key, or if the value is not * It returns false if there is no such key, or if the value is not
@@ -805,7 +773,6 @@ public class JSONObject {
return this.optBoolean(key, false); return this.optBoolean(key, false);
} }
/** /**
* Get an optional boolean associated with a key. * Get an optional boolean associated with a key.
* It returns the defaultValue if there is no such key, or if it is not * It returns the defaultValue if there is no such key, or if it is not
@@ -823,7 +790,6 @@ public class JSONObject {
} }
} }
/** /**
* Get an optional double associated with a key, * Get an optional double associated with a key,
* or NaN if there is no such key or if its value is not a number. * or NaN if there is no such key or if its value is not a number.
@@ -837,7 +803,6 @@ public class JSONObject {
return this.optDouble(key, Double.NaN); return this.optDouble(key, Double.NaN);
} }
/** /**
* Get an optional double associated with a key, or the * Get an optional double associated with a key, or the
* defaultValue if there is no such key or if its value is not a number. * defaultValue if there is no such key or if its value is not a number.
@@ -856,7 +821,6 @@ public class JSONObject {
} }
} }
/** /**
* Get an optional int value associated with a key, * Get an optional int value associated with a key,
* or zero if there is no such key or if the value is not a number. * or zero if there is no such key or if the value is not a number.
@@ -870,7 +834,6 @@ public class JSONObject {
return this.optInt(key, 0); return this.optInt(key, 0);
} }
/** /**
* Get an optional int value associated with a key, * Get an optional int value associated with a key,
* or the default if there is no such key or if the value is not a number. * or the default if there is no such key or if the value is not a number.
@@ -889,7 +852,6 @@ public class JSONObject {
} }
} }
/** /**
* Get an optional JSONArray associated with a key. * Get an optional JSONArray associated with a key.
* It returns null if there is no such key, or if its value is not a * It returns null if there is no such key, or if its value is not a
@@ -903,7 +865,6 @@ public class JSONObject {
return o instanceof JSONArray ? (JSONArray) o : null; return o instanceof JSONArray ? (JSONArray) o : null;
} }
/** /**
* Get an optional JSONObject associated with a key. * Get an optional JSONObject associated with a key.
* It returns null if there is no such key, or if its value is not a * It returns null if there is no such key, or if its value is not a
@@ -917,7 +878,6 @@ public class JSONObject {
return object instanceof JSONObject ? (JSONObject) object : null; return object instanceof JSONObject ? (JSONObject) object : null;
} }
/** /**
* Get an optional long value associated with a key, * Get an optional long value associated with a key,
* or zero if there is no such key or if the value is not a number. * or zero if there is no such key or if the value is not a number.
@@ -931,7 +891,6 @@ public class JSONObject {
return this.optLong(key, 0); return this.optLong(key, 0);
} }
/** /**
* Get an optional long value associated with a key, * Get an optional long value associated with a key,
* or the default if there is no such key or if the value is not a number. * or the default if there is no such key or if the value is not a number.
@@ -950,7 +909,6 @@ public class JSONObject {
} }
} }
/** /**
* Get an optional string associated with a key. * Get an optional string associated with a key.
* It returns an empty string if there is no such key. If the value is not * It returns an empty string if there is no such key. If the value is not
@@ -963,7 +921,6 @@ public class JSONObject {
return this.optString(key, ""); return this.optString(key, "");
} }
/** /**
* Get an optional string associated with a key. * Get an optional string associated with a key.
* It returns the defaultValue if there is no such key. * It returns the defaultValue if there is no such key.
@@ -977,7 +934,6 @@ public class JSONObject {
return NULL.equals(object) ? defaultValue : object.toString(); return NULL.equals(object) ? defaultValue : object.toString();
} }
private void populateMap(Object bean) { private void populateMap(Object bean) {
Class klass = bean.getClass(); Class klass = bean.getClass();
@@ -1025,7 +981,6 @@ public class JSONObject {
} }
} }
/** /**
* Put a key/boolean pair in the JSONObject. * Put a key/boolean pair in the JSONObject.
* *
@@ -1039,7 +994,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Put a key/value pair in the JSONObject, where the value will be a * Put a key/value pair in the JSONObject, where the value will be a
* JSONArray which is produced from a Collection. * JSONArray which is produced from a Collection.
@@ -1053,7 +1007,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Put a key/double pair in the JSONObject. * Put a key/double pair in the JSONObject.
* *
@@ -1067,7 +1020,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Put a key/int pair in the JSONObject. * Put a key/int pair in the JSONObject.
* *
@@ -1081,7 +1033,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Put a key/long pair in the JSONObject. * Put a key/long pair in the JSONObject.
* *
@@ -1095,7 +1046,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Put a key/value pair in the JSONObject, where the value will be a * Put a key/value pair in the JSONObject, where the value will be a
* JSONObject which is produced from a Map. * JSONObject which is produced from a Map.
@@ -1109,7 +1059,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Put a key/value pair in the JSONObject. If the value is null, * Put a key/value pair in the JSONObject. If the value is null,
* then the key will be removed from the JSONObject if it is present. * then the key will be removed from the JSONObject if it is present.
@@ -1144,7 +1093,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Put a key/value pair in the JSONObject, but only if the key and the * Put a key/value pair in the JSONObject, but only if the key and the
* value are both non-null, and only if there is not already a member * value are both non-null, and only if there is not already a member
@@ -1164,7 +1112,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Put a key/value pair in the JSONObject, but only if the * Put a key/value pair in the JSONObject, but only if the
* key and the value are both non-null. * key and the value are both non-null.
@@ -1182,7 +1129,6 @@ public class JSONObject {
return this; return this;
} }
/** /**
* Produce a string in double quotes with backslash sequences in all the * Produce a string in double quotes with backslash sequences in all the
* right places. A backslash will be inserted within </, producing <\/, * right places. A backslash will be inserted within </, producing <\/,
@@ -1324,7 +1270,6 @@ public class JSONObject {
return string; return string;
} }
/** /**
* Throw an exception if the object is a NaN or infinite number. * Throw an exception if the object is a NaN or infinite number.
* @param o The object to test. * @param o The object to test.
@@ -1346,7 +1291,6 @@ public class JSONObject {
} }
} }
/** /**
* Produce a JSONArray containing the values of the members of this * Produce a JSONArray containing the values of the members of this
* JSONObject. * JSONObject.
@@ -1386,7 +1330,6 @@ public class JSONObject {
} }
} }
/** /**
* Make a prettyprinted JSON text of this JSONObject. * Make a prettyprinted JSON text of this JSONObject.
* <p> * <p>
@@ -1502,11 +1445,9 @@ public class JSONObject {
String objectPackageName = objectPackage != null String objectPackageName = objectPackage != null
? objectPackage.getName() ? objectPackage.getName()
: ""; : "";
if ( if(objectPackageName.startsWith("java.") ||
objectPackageName.startsWith("java.") ||
objectPackageName.startsWith("javax.") || objectPackageName.startsWith("javax.") ||
object.getClass().getClassLoader() == null object.getClass().getClassLoader() == null) {
) {
return object.toString(); return object.toString();
} }
return new JSONObject(object); return new JSONObject(object);
@@ -1515,7 +1456,6 @@ public class JSONObject {
} }
} }
/** /**
* Write the contents of the JSONObject as JSON text to a writer. * Write the contents of the JSONObject as JSON text to a writer.
* For compactness, no whitespace is added. * For compactness, no whitespace is added.
@@ -1529,7 +1469,6 @@ public class JSONObject {
return this.write(writer, 0, 0); return this.write(writer, 0, 0);
} }
static final Writer writeValue(Writer writer, Object value, static final Writer writeValue(Writer writer, Object value,
int indentFactor, int indent) throws JSONException, IOException { int indentFactor, int indent) throws JSONException, IOException {
if(value == null || value.equals(null)) { if(value == null || value.equals(null)) {
+1
View File
@@ -1,4 +1,5 @@
package org.json; package org.json;
/** /**
* The <code>JSONString</code> interface allows a <code>toJSONString()</code> * The <code>JSONString</code> interface allows a <code>toJSONString()</code>
* method so that a class can change the behavior of * method so that a class can change the behavior of
+21 -21
View File
@@ -1,27 +1,27 @@
package org.json; package org.json;
/* /*
Copyright (c) 2006 JSON.org * Copyright (c) 2006 JSON.org
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in all * The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. * copies or substantial portions of the Software.
*
The Software shall be used for Good, not Evil. * The Software shall be used for Good, not Evil.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. * SOFTWARE.
*/ */
import java.io.StringWriter; import java.io.StringWriter;
+21 -38
View File
@@ -8,27 +8,27 @@ import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
/* /*
Copyright (c) 2002 JSON.org * Copyright (c) 2002 JSON.org
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in all * The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. * copies or substantial portions of the Software.
*
The Software shall be used for Good, not Evil. * The Software shall be used for Good, not Evil.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. * SOFTWARE.
*/ */
/** /**
@@ -48,7 +48,6 @@ public class JSONTokener {
private Reader reader; private Reader reader;
private boolean usePrevious; private boolean usePrevious;
/** /**
* Construct a JSONTokener from a Reader. * Construct a JSONTokener from a Reader.
* *
@@ -66,7 +65,6 @@ public class JSONTokener {
this.line = 1; this.line = 1;
} }
/** /**
* Construct a JSONTokener from an InputStream. * Construct a JSONTokener from an InputStream.
*/ */
@@ -74,7 +72,6 @@ public class JSONTokener {
this(new InputStreamReader(inputStream)); this(new InputStreamReader(inputStream));
} }
/** /**
* Construct a JSONTokener from a string. * Construct a JSONTokener from a string.
* *
@@ -84,7 +81,6 @@ public class JSONTokener {
this(new StringReader(s)); this(new StringReader(s));
} }
/** /**
* Back up one character. This provides a sort of lookahead capability, * Back up one character. This provides a sort of lookahead capability,
* so that you can test for a digit or letter before attempting to parse * so that you can test for a digit or letter before attempting to parse
@@ -100,7 +96,6 @@ public class JSONTokener {
this.eof = false; this.eof = false;
} }
/** /**
* Get the hex value of a character (base16). * Get the hex value of a character (base16).
* @param c A character between '0' and '9' or between 'A' and 'F' or * @param c A character between '0' and '9' or between 'A' and 'F' or
@@ -124,7 +119,6 @@ public class JSONTokener {
return this.eof && !this.usePrevious; return this.eof && !this.usePrevious;
} }
/** /**
* Determine if the source string still contains characters that next() * Determine if the source string still contains characters that next()
* can consume. * can consume.
@@ -139,7 +133,6 @@ public class JSONTokener {
return true; return true;
} }
/** /**
* Get the next character in the source string. * Get the next character in the source string.
* *
@@ -176,7 +169,6 @@ public class JSONTokener {
return this.previous; return this.previous;
} }
/** /**
* Consume the next character, and check that it matches a specified * Consume the next character, and check that it matches a specified
* character. * character.
@@ -193,7 +185,6 @@ public class JSONTokener {
return n; return n;
} }
/** /**
* Get the next n characters. * Get the next n characters.
* *
@@ -221,7 +212,6 @@ public class JSONTokener {
return new String(chars); return new String(chars);
} }
/** /**
* Get the next char in the string, skipping whitespace. * Get the next char in the string, skipping whitespace.
* @throws JSONException * @throws JSONException
@@ -236,7 +226,6 @@ public class JSONTokener {
} }
} }
/** /**
* Return the characters up to the next close quote character. * Return the characters up to the next close quote character.
* Backslash processing is done. The formal JSON format does not * Backslash processing is done. The formal JSON format does not
@@ -298,7 +287,6 @@ public class JSONTokener {
} }
} }
/** /**
* Get the text up but not including the specified character or the * Get the text up but not including the specified character or the
* end of line, whichever comes first. * end of line, whichever comes first.
@@ -319,7 +307,6 @@ public class JSONTokener {
} }
} }
/** /**
* Get the text up but not including one of the specified delimiter * Get the text up but not including one of the specified delimiter
* characters or the end of line, whichever comes first. * characters or the end of line, whichever comes first.
@@ -342,7 +329,6 @@ public class JSONTokener {
} }
} }
/** /**
* Get the next value. The value can be a Boolean, Double, Integer, * Get the next value. The value can be a Boolean, Double, Integer,
* JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object. * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
@@ -389,7 +375,6 @@ public class JSONTokener {
return JSONObject.stringToValue(string); return JSONObject.stringToValue(string);
} }
/** /**
* Skip characters until the next character is the requested character. * Skip characters until the next character is the requested character.
* If the requested character is not found, no characters are skipped. * If the requested character is not found, no characters are skipped.
@@ -422,7 +407,6 @@ public class JSONTokener {
return c; return c;
} }
/** /**
* Make a JSONException to signal a syntax error. * Make a JSONException to signal a syntax error.
* *
@@ -433,7 +417,6 @@ public class JSONTokener {
return new JSONException(message + this.toString()); return new JSONException(message + this.toString());
} }
/** /**
* Make a printable string of this JSONTokener. * Make a printable string of this JSONTokener.
* *
+21 -25
View File
@@ -4,27 +4,27 @@ import java.io.IOException;
import java.io.Writer; import java.io.Writer;
/* /*
Copyright (c) 2006 JSON.org * Copyright (c) 2006 JSON.org
*
Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in all * The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. * copies or substantial portions of the Software.
*
The Software shall be used for Good, not Evil. * The Software shall be used for Good, not Evil.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. * SOFTWARE.
*/ */
/** /**
@@ -221,7 +221,6 @@ public class JSONWriter {
throw new JSONException("Misplaced key."); throw new JSONException("Misplaced key.");
} }
/** /**
* Begin appending a new object. All keys and values until the balancing * Begin appending a new object. All keys and values until the balancing
* <code>endObject</code> will be appended to this object. The * <code>endObject</code> will be appended to this object. The
@@ -245,7 +244,6 @@ public class JSONWriter {
} }
/** /**
* Pop an array or object scope. * Pop an array or object scope.
* @param c The scope to close. * @param c The scope to close.
@@ -281,7 +279,6 @@ public class JSONWriter {
this.top += 1; this.top += 1;
} }
/** /**
* Append either the value <code>true</code> or the value * Append either the value <code>true</code> or the value
* <code>false</code>. * <code>false</code>.
@@ -313,7 +310,6 @@ public class JSONWriter {
return this.append(Long.toString(l)); return this.append(Long.toString(l));
} }
/** /**
* Append an object value. * Append an object value.
* @param object The object to append. It can be null, or a Boolean, Number, * @param object The object to append. It can be null, or a Boolean, Number,