/** * Parse the attributes of an element, given the list of required and optional ones. * Return values in same order, null for those not present. * Log warnings for extra attributes or missing required attributes. */ protected String[] parseAttributes(Attributes attributes, String[] required, String[] optional) { String[] result = new String[required.length + optional.length]; for (int i = 0; i < attributes.getLength(); i += 1) { String name = attributes.getLocalName(i); String value = attributes.getValue(i).trim().intern(); int j; if ((j = indexOf(required, name)) >= 0) { result[j] = value; } else if ((j = indexOf(optional, name)) >= 0) { result[required.length + j] = value; } else { unexpectedAttribute(elementHandled, name, value); } } for (int i = 0; i < required.length; i += 1) { checkRequiredAttribute(elementHandled, required[i], result[i]); } return result; }
/** * Parse the attributes of an element, given the list of required and optional ones. * Return values in same order, null for those not present. * Log warnings for extra attributes or missing required attributes. */ protected String[] parseAttributes(Attributes attributes, String[] required, String[] optional) { String[] result = new String[required.length + optional.length]; for (int i = 0; i < attributes.getLength(); i += 1) { String name = attributes.getLocalName(i); String value = attributes.getValue(i).trim().intern(); int j; if ((j = indexOf(required, name)) >= 0) { result[j] = value; } else if ((j = indexOf(optional, name)) >= 0) { result[required.length + j] = value; } else { unexpectedAttribute(elementHandled, name, value); } } for (int i = 0; i < required.length; i += 1) { checkRequiredAttribute(elementHandled, required[i], result[i]); } return result; }