/** * Returns this field's children. These may be either terminal or non-terminal fields. * * @return he list of child fields. */ public List<PDField> getChildren() { List<PDField> children = new ArrayList<PDField>(); COSArray kids = (COSArray) getCOSObject().getDictionaryObject(COSName.KIDS); for (int i = 0; i < kids.size(); i++) { PDField field = PDField.fromDictionary(getAcroForm(), (COSDictionary) kids.getObject(i), this); if (field != null) { children.add(field); } } return children; }
/** * This will find one of the child elements. The name array are the components of the name to * search down the tree of names. The nameIndex is where to start in that array. This method is * called recursively until it finds the end point based on the name array. * * @param name An array that picks the path to the field. * @param nameIndex The index into the array. * @return The field at the endpoint or null if none is found. */ PDField findKid(String[] name, int nameIndex) { PDField retval = null; COSArray kids = (COSArray) dictionary.getDictionaryObject(COSName.KIDS); if (kids != null) { for (int i = 0; retval == null && i < kids.size(); i++) { COSDictionary kidDictionary = (COSDictionary) kids.getObject(i); if (name[nameIndex].equals(kidDictionary.getString(COSName.T))) { retval = PDField.fromDictionary(acroForm, kidDictionary, (PDNonTerminalField) this); if (retval != null && name.length > nameIndex + 1) { retval = retval.findKid(name, nameIndex + 1); } } } } return retval; }