public void generate(JNIField field) { String name = field.getName(); Iterator<File> keys = files.keySet().iterator(); while (keys.hasNext()) { File key = keys.next(); String str = files.get(key); if (str.indexOf(name) != -1) { int modifiers = field.getModifiers(); String modifiersStr = Modifier.toString(modifiers); output("\t"); output(modifiersStr); if (modifiersStr.length() > 0) output(" "); output(field.getType().getTypeSignature3(false)); output(" "); output(field.getName()); output(" = "); output(getFieldValue(field)); outputln(";"); usedCount++; return; } } unusedCount++; // output("NOT USED=" + field.toString() + " \n"); }
String getFieldValue(JNIField field) { String name = field.getName(); int index = 0; while (true) { index = classSource.indexOf(name, index + 1); if (index == -1) return null; int equalsIndex = classSource.indexOf("=", index); if (classSource.substring(index + name.length(), equalsIndex).trim().length() == 0) { int semiIndex = classSource.indexOf(";", equalsIndex); return classSource.substring(equalsIndex + 1, semiIndex).trim(); } } }