protected int indexOfAttributeInstance(String name) { if (attributes == null) { return -1; } int nameHash = name.hashCode(); for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.equalsName(name, nameHash)) { return i; } } return -1; }
protected Attribute getAttributeInstance(String name) { if (attributes == null) { return null; } int nameHash = name.hashCode(); for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.equalsName(name, nameHash)) { return attr; } } return null; }
/** * Returns <code>true</code> if node contains an attribute. */ public boolean hasAttribute(String name) { if (attributes == null) { return false; } int nameHash = name.hashCode(); for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.equalsName(name, nameHash)) { return true; } } return false; }
/** * Sets attribute value. Value may be <code>null</code>. */ public void setAttribute(String name, String value) { initAttributes(); if (!caseSensitive) { name = name.toLowerCase(); } // search if attribute with the same name exist int nameHash = name.hashCode(); for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.equalsName(name, nameHash)) { attr.setValue(value); return; } } attributes.add(new Attribute(name, value, true)); }