AttrValue_List { // Set of methods to return the requested value for the first attribute // matching the input public String getAttributePrefix(String nsPrefix, String name) {{ return getAttributeRecord(nsPrefix, name)[0]; }} public String getAttributeName(String nsPrefix, String name) {{ return getAttributeRecord(nsPrefix, name)[1]; }} public String getAttributeValue(String nsPrefix, String name) {{ return getAttributeRecord(nsPrefix, name)[2]; }} // Set of methods to return the requested value for all attributes // matching the input public String[] getAllAttributeNames(String nsPrefix, String name) {{ String allAttrs[][] = getAllAttributeRecords(nsPrefix, name); String allValues[] = new String[allAttrs.length]; for (int i = 0; i < allAttrs.length; i++) allValues[i] = allAttrs[i][1]; return allValues; }} // Private methods that actually do the lookup and return the appropriate // attribute/attributes private String[] getAttributeRecord(String nsPrefix, String name) {{ String attrRecord[] = new String[] {"", "", ""}; for (Enumeration attrValues = elements(); attrValues.hasMoreElements(); ) { AttrValue attr = (AttrValue) attrValues.nextElement(); String attrPrefix = (attr.prefix==null) ? "" : (attr.prefix.namespace.toString()); String attrName = attr.attrName.toString(); String attrValue = attr.attrValue; if (((nsPrefix == null) || (attrPrefix.equals(nsPrefix))) && ((name == null) || (attrName.equals(name)))) { attrRecord[0] = attrPrefix; attrRecord[1] = attrName; attrRecord[2] = attrValue; break; } } return attrRecord; }} private String[][] getAllAttributeRecords(String nsPrefix, String name) {{ Vector allMatchingAttributes = new Vector(); String attrRecord[] = new String[] {"", "", ""}; for (Enumeration attrValues = elements(); attrValues.hasMoreElements(); ) { AttrValue attr = (AttrValue) attrValues.nextElement(); String attrPrefix = (attr.prefix==null) ? "" : (attr.prefix.namespace.toString()); String attrName = attr.attrName.toString(); String attrValue = attr.attrValue; if (((nsPrefix == null) || (attrPrefix.equals(nsPrefix))) && ((name == null) || (attrName.equals(name)))) { attrRecord[0] = attrPrefix; attrRecord[1] = attrName; attrRecord[2] = attrValue; allMatchingAttributes.addElement(attrRecord); } } String returnValue[][] = new String[allMatchingAttributes.size()][]; allMatchingAttributes.copyInto(returnValue); return returnValue; }} }