Author: borges
Date: 2012-01-06 14:21:21 -0500 (Fri, 06 Jan 2012)
New Revision: 11995
Modified:
trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java
Log:
Fix warnings, and clarify code.
Modified: trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java
===================================================================
--- trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java 2012-01-06
19:21:02 UTC (rev 11994)
+++ trunk/hornetq-core/src/main/java/org/hornetq/utils/json/JSONObject.java 2012-01-06
19:21:21 UTC (rev 11995)
@@ -57,11 +57,11 @@
* do type checking and type coercion for you.
* <p>
* The <code>put</code> methods adds values to an object. For example,
- *
+ *
* <pre>
* myString = new JSONObject().put("JSON", "Hello,
World!").toString();
* </pre>
- *
+ *
* produces the string <code>{"JSON": "Hello,
World"}</code>.
* <p>
* The texts produced by the <code>toString</code> methods strictly conform
to the JSON syntax
@@ -1571,20 +1571,18 @@
}
if (value instanceof JSONString)
{
- Object o;
+ String o;
try
{
o = ((JSONString)value).toJSONString();
}
- catch (Exception e)
+ catch (RuntimeException e)
{
throw new JSONException(e);
}
- if (o instanceof String)
- {
- return (String)o;
- }
- throw new JSONException("Bad value from toJSONString: " + o);
+ if (o == null)
+ throw new JSONException("Bad value from toJSONString: " + o);
+ return o;
}
if (value instanceof Number)
{
@@ -1633,14 +1631,12 @@
{
if (value instanceof JSONString)
{
- Object o = ((JSONString)value).toJSONString();
- if (o instanceof String)
- {
- return (String)o;
- }
+ String o = ((JSONString)value).toJSONString();
+ if (o != null)
+ return o;
}
}
- catch (Exception e)
+ catch (RuntimeException e)
{
/* forget about it */
}
Show replies by date