Vector parasedPath = parasePath(path);
String pathType = (String) parasedPath.elementAt(0);
if (pathType.equals(ConfigTool.PATH_TYPE_WRONG))
throw new ChaiDBException(ErrorCode.PARSE_ERROR, "Path is wrong!");
if (pathType.equals(ConfigTool.PATH_TYPE_ROOT)) return root;
if (pathType.equals(ConfigTool.PATH_TYPE_NORMAL)) {
ConfigTool parent = root;
for (int i = 1; i < parasedPath.size(); i++) {
String elementName = (String) parasedPath.elementAt(i);
ElementSet elementSet = parent.getChildren();
if (elementSet == null) break;
ConfigTool child;
for (Iterator childrenIter = elementSet.iterator(); childrenIter.hasNext();) {
child = (ConfigTool) childrenIter.next();
if (child.getName() != null && elementName.equals(child.getName())) {
if (i == parasedPath.size() - 1) {
if (elementID == null) {
return child;
}
if (child.getAttributes() != null && child.getAttributes().get(ELEMENT_ID) != null && ((String) child.getAttributes().get(ELEMENT_ID)).equalsIgnoreCase(elementID)) {
return child;
}
} else {
parent = child;
break;
}
}
}
}
}
throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "No such Config was found! Input Param:path=" + path + "elementId=" + elementID);
}