MCPcopy Index your code
hub / github.com/benfry/processing4 / wrap

Method wrap

core/src/processing/data/JSONObject.java:1766–1805  ·  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

1764 * @return The wrapped value
1765 */
1766 static protected Object wrap(Object object) {
1767 try {
1768 if (object == null) {
1769 return NULL;
1770 }
1771 if (object instanceof JSONObject || object instanceof JSONArray ||
1772 NULL.equals(object) || /*object instanceof JSONString ||*/
1773 object instanceof Byte || object instanceof Character ||
1774 object instanceof Short || object instanceof Integer ||
1775 object instanceof Long || object instanceof Boolean ||
1776 object instanceof Float || object instanceof Double ||
1777 object instanceof String) {
1778 return object;
1779 }
1780
1781 if (object instanceof Collection) {
1782 return new JSONArray(object);
1783 }
1784 if (object.getClass().isArray()) {
1785 return new JSONArray(object);
1786 }
1787 if (object instanceof Map) {
1788 return new JSONObject(object);
1789 }
1790 Package objectPackage = object.getClass().getPackage();
1791 String objectPackageName = objectPackage != null
1792 ? objectPackage.getName()
1793 : "";
1794 if (
1795 objectPackageName.startsWith("java.") ||
1796 objectPackageName.startsWith("javax.") ||
1797 object.getClass().getClassLoader() == null
1798 ) {
1799 return object.toString();
1800 }
1801 return new JSONObject(object);
1802 } catch(Exception exception) {
1803 return null;
1804 }
1805 }
1806
1807
1808// /**

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 4

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

Tested by

no test coverage detected