MCPcopy Index your code
hub / github.com/processing/processing / wrap

Method wrap

core/src/processing/data/JSONObject.java:1712–1751  ·  view source on GitHub ↗

Wrap an object, if necessary. If the object is null, return the NULL object. If it is an array or collection, wrap it in a JSONArray. If it is a map, wrap it in a JSONObject. If it is a standard property (Double, String, et al) then it is already wrapped. Otherwise, if it comes from one of the java

(Object object)

Source from the content-addressed store, hash-verified

1710 * @return The wrapped value
1711 */
1712 static protected Object wrap(Object object) {
1713 try {
1714 if (object == null) {
1715 return NULL;
1716 }
1717 if (object instanceof JSONObject || object instanceof JSONArray ||
1718 NULL.equals(object) || /*object instanceof JSONString ||*/
1719 object instanceof Byte || object instanceof Character ||
1720 object instanceof Short || object instanceof Integer ||
1721 object instanceof Long || object instanceof Boolean ||
1722 object instanceof Float || object instanceof Double ||
1723 object instanceof String) {
1724 return object;
1725 }
1726
1727 if (object instanceof Collection) {
1728 return new JSONArray(object);
1729 }
1730 if (object.getClass().isArray()) {
1731 return new JSONArray(object);
1732 }
1733 if (object instanceof Map) {
1734 return new JSONObject(object);
1735 }
1736 Package objectPackage = object.getClass().getPackage();
1737 String objectPackageName = objectPackage != null
1738 ? objectPackage.getName()
1739 : "";
1740 if (
1741 objectPackageName.startsWith("java.") ||
1742 objectPackageName.startsWith("javax.") ||
1743 object.getClass().getClassLoader() == null
1744 ) {
1745 return object.toString();
1746 }
1747 return new JSONObject(object);
1748 } catch(Exception exception) {
1749 return null;
1750 }
1751 }
1752
1753
1754// /**

Callers 15

JSONArrayMethod · 0.95
JSONObjectMethod · 0.95
populateMapMethod · 0.95
copyToTextureMethod · 0.80
allocateByteBufferMethod · 0.80
updateByteBufferMethod · 0.80
allocateShortBufferMethod · 0.80
updateShortBufferMethod · 0.80
allocateIntBufferMethod · 0.80
updateIntBufferMethod · 0.80
allocateFloatBufferMethod · 0.80
updateFloatBufferMethod · 0.80

Calls 5

startsWithMethod · 0.80
getClassLoaderMethod · 0.80
equalsMethod · 0.45
getNameMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected