Skip to content

Removed compilation warnings #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public JSONObject(Object bean) {
*/
public JSONObject(Object object, String names[]) {
this();
Class c = object.getClass();
Class<?> c = object.getClass();
for (int i = 0; i < names.length; i += 1) {
String name = names[i];
try {
Expand Down Expand Up @@ -631,7 +631,7 @@ public static String[] getNames(Object object) {
if (object == null) {
return null;
}
Class klass = object.getClass();
Class<?> klass = object.getClass();
Field[] fields = klass.getFields();
int length = fields.length;
if (length == 0) {
Expand Down Expand Up @@ -981,7 +981,7 @@ public String optString(String key, String defaultValue) {
}

private void populateMap(Object bean) {
Class klass = bean.getClass();
Class<?> klass = bean.getClass();

// If klass is a System class then set includeSuperClass to false.

Expand Down Expand Up @@ -1512,10 +1512,14 @@ public static String valueToString(Object value) throws JSONException {
return value.toString();
}
if (value instanceof Map) {
return new JSONObject((Map<String, Object>)value).toString();
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) value;
return new JSONObject(map).toString();
}
if (value instanceof Collection) {
return new JSONArray((Collection<Object>) value).toString();
@SuppressWarnings("unchecked")
Collection<Object> coll = (Collection<Object>) value;
return new JSONArray(coll).toString();
}
if (value.getClass().isArray()) {
return new JSONArray(value).toString();
Expand Down Expand Up @@ -1551,13 +1555,17 @@ public static Object wrap(Object object) {
}

if (object instanceof Collection) {
return new JSONArray((Collection<Object>) object);
@SuppressWarnings("unchecked")
Collection<Object> coll = (Collection<Object>) object;
return new JSONArray(coll);
}
if (object.getClass().isArray()) {
return new JSONArray(object);
}
if (object instanceof Map) {
return new JSONObject((Map<String, Object>) object);
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) object;
return new JSONObject(map);
}
Package objectPackage = object.getClass().getPackage();
String objectPackageName = objectPackage != null ? objectPackage
Expand Down Expand Up @@ -1595,9 +1603,13 @@ static final Writer writeValue(Writer writer, Object value,
} else if (value instanceof JSONArray) {
((JSONArray) value).write(writer, indentFactor, indent);
} else if (value instanceof Map) {
new JSONObject((Map<String, Object>) value).write(writer, indentFactor, indent);
@SuppressWarnings("unchecked")
Map<String, Object> map = (Map<String, Object>) value;
new JSONObject(map).write(writer, indentFactor, indent);
} else if (value instanceof Collection) {
new JSONArray((Collection<Object>) value).write(writer, indentFactor,
@SuppressWarnings("unchecked")
Collection<Object> coll = (Collection<Object>) value;
new JSONArray(coll).write(writer, indentFactor,
indent);
} else if (value.getClass().isArray()) {
new JSONArray(value).write(writer, indentFactor, indent);
Expand Down
2 changes: 1 addition & 1 deletion Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Property {
public static JSONObject toJSONObject(java.util.Properties properties) throws JSONException {
JSONObject jo = new JSONObject();
if (properties != null && !properties.isEmpty()) {
Enumeration enumProperties = properties.propertyNames();
Enumeration<?> enumProperties = properties.propertyNames();
while(enumProperties.hasMoreElements()) {
String name = (String)enumProperties.nextElement();
jo.put(name, properties.getProperty(name));
Expand Down