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

Method parseInto

core/src/processing/data/Table.java:1045–1191  ·  view source on GitHub ↗

incomplete, do not use

(Object enclosingObject, String fieldName)

Source from the content-addressed store, hash-verified

1043
1044 /** incomplete, do not use */
1045 public void parseInto(Object enclosingObject, String fieldName) {
1046 Class<?> target = null;
1047 Object outgoing = null;
1048 Field targetField = null;
1049 try {
1050 // Object targetObject,
1051 // Class target -> get this from the type of fieldName
1052// Class sketchClass = sketch.getClass();
1053 Class<?> sketchClass = enclosingObject.getClass();
1054 targetField = sketchClass.getDeclaredField(fieldName);
1055// PApplet.println("found " + targetField);
1056 Class<?> targetArray = targetField.getType();
1057 if (!targetArray.isArray()) {
1058 // fieldName is not an array
1059 } else {
1060 target = targetArray.getComponentType();
1061 outgoing = Array.newInstance(target, getRowCount());
1062 }
1063 } catch (NoSuchFieldException e) {
1064 e.printStackTrace();
1065 } catch (SecurityException e) {
1066 e.printStackTrace();
1067 }
1068
1069// Object enclosingObject = sketch;
1070// PApplet.println("enclosing obj is " + enclosingObject);
1071 Class<?> enclosingClass = target.getEnclosingClass();
1072 Constructor<?> con = null;
1073
1074 try {
1075 if (enclosingClass == null) {
1076 con = target.getDeclaredConstructor(); //new Class[] { });
1077// PApplet.println("no enclosing class");
1078 } else {
1079 con = target.getDeclaredConstructor(enclosingClass);
1080// PApplet.println("enclosed by " + enclosingClass.getName());
1081 }
1082 if (!con.canAccess(null)) {
1083// System.out.println("setting constructor to public");
1084 con.setAccessible(true);
1085 }
1086 } catch (SecurityException e) {
1087 e.printStackTrace();
1088 } catch (NoSuchMethodException e) {
1089 e.printStackTrace();
1090 }
1091
1092 Field[] fields = target.getDeclaredFields();
1093 ArrayList<Field> inuse = new ArrayList<>();
1094 for (Field field : fields) {
1095 String name = field.getName();
1096 if (getColumnIndex(name, false) != -1) {
1097 inuse.add(field);
1098 } else {
1099// System.out.println("skipping field " + name);
1100 }
1101 }
1102

Callers 1

parseIntoMethod · 0.95

Calls 15

getRowCountMethod · 0.95
getColumnIndexMethod · 0.95
rowsMethod · 0.95
setMethod · 0.65
getStringMethod · 0.65
setIntMethod · 0.65
getIntMethod · 0.65
setLongMethod · 0.65
getLongMethod · 0.65
setFloatMethod · 0.65
getFloatMethod · 0.65
setDoubleMethod · 0.65

Tested by 1

parseIntoMethod · 0.76