* specified path should be created as needed. When checking the
* state of the map callers should set this to false to avoid
* changing the state unexpectedly
*/
protected AttributeItem getItem(String[] attributePath, boolean create) {
AttributeItem item = null;
AttributeGroup currentGroup = this;
for (int index = 0; index < attributePath.length; index++) {
String attrName = attributePath[index];
item = currentGroup.getItems().get(attrName);
// Add missing AttributeGroup
if (item == null) {
// If not creating missing AttributeGroups then return null
if (!create) {
if (this.superClassGroup != null){
return this.superClassGroup.getItem(attributePath, create);
}
return null;
}
item = newItem(currentGroup, attrName);
currentGroup.getItems().put(attrName, item);
}
// Add a AttributeGroup if not at the end of the attributes path
if (item.getGroup() == null && index < (attributePath.length - 1)) {
if (!create) {
return null;
}
//XXX-dclarke: Converting the attribute[] into a string and then re-parsing it seems odd
AttributeGroup newGroup = newGroup(attrName, currentGroup);
item.setRootGroup(newGroup);
}
currentGroup = item.getGroup();
}
return item;
}