// --------------------------------------------- // get all field names belongs to node // --------------------------------------------- public String[] getFieldNames(VRMLNode node) { int i; int n = node.getNumFields(); // System.out.print(indentStr); // System.out.println(Integer.toString(n)+" fields"); int nValidFields = 0; for (i = 1; i < n; i++) { // System.out.print(indentStr); // System.out.print(i); VRMLFieldDeclaration decl = node.getFieldDeclaration(i); if (decl != null) { // String fieldName = decl.getName(); // field name // System.out.println(" "+fieldName); int fieldAccess = decl.getAccessType(); if ((fieldAccess == FieldConstants.FIELD) || (fieldAccess == FieldConstants.EXPOSEDFIELD)) { nValidFields++; } } } if (nValidFields <= 0) return null; String[] fieldNames = new String[nValidFields]; int iField = 0; for (i = 1; i < n; i++) { // System.out.print(indentStr); // System.out.print(i); VRMLFieldDeclaration decl = node.getFieldDeclaration(i); if (decl != null) { String fieldName = decl.getName(); // field name // System.out.println(" "+fieldName); int fieldAccess = decl.getAccessType(); if ((fieldAccess == FieldConstants.FIELD) || (fieldAccess == FieldConstants.EXPOSEDFIELD)) { fieldNames[iField] = fieldName; iField++; } } } return fieldNames; }
void printNodeSub(VRMLNode node, int indentLevel) { String indentStr = X3DParser.getIndentSpace(indentLevel); System.out.print(indentStr); System.out.println(node.getVRMLNodeName()); if (node instanceof BaseWorldRoot) { BaseWorldRoot root = (BaseWorldRoot) node; VRMLNodeType[] childNodes = root.getChildren(); for (int i = 0; i < childNodes.length; i++) { VRMLNode child = childNodes[i]; printNodeSub(child, indentLevel + 1); } } else { int n = node.getNumFields(); // System.out.print(indentStr); // System.out.println(Integer.toString(n)+" fields"); for (int i = 1; i < n; i++) { // System.out.print(indentStr); // System.out.print(i); VRMLFieldDeclaration decl = node.getFieldDeclaration(i); if (decl != null) { String fieldName = decl.getName(); // field name // System.out.println(" "+fieldName); int fieldAccess = decl.getAccessType(); if ((fieldAccess == FieldConstants.FIELD) || (fieldAccess == FieldConstants.EXPOSEDFIELD)) { printField(node, fieldName, indentLevel); } } } } }