return findNode(path);
}
boolean isLeaf=path.charAt(0)!='[';
int k1=isLeaf?0:1, k2=path.length();
if(m_flat){
Node node=m_deHashtable.get(path);
if(node==null){
int k3=path.indexOf('#'), k4=isLeaf?path.length():(path.length()-1);
boolean bMultipleMapping=k3>=0;
boolean bIsPrecondition=path.startsWith(Node.c_sPrecondition);
Node parent=m_root.getChildAt(0);
if(bMultipleMapping){
int i_mapping=Integer.parseInt(path.substring(k3+1,k4));
Node parent_saved=parent;
parent=parent.findMultipleMappingExist(i_mapping);
if(parent==null){
parent=parent_saved.insertMultipleMapping(i_mapping);
}
}
for(Node child:parent.getChildren()){
if (bIsPrecondition) {
if (child.isPrecondition())
return child;
} else if (path.equals(child.getName())) {
return child;
}
}
if (bIsPrecondition) {
return insertPreconditionNode(parent);
} else {
throw new TreeMapperException("Failed to find the node:" + path + " for flat target structure.");
}
}
return node;
}
char c;
for(;k2>k1;k2--)if((c=path.charAt(k2-1))=='.'||c=='$')break;
if(k2<k1)return null;
StringTokenizer tk=new StringTokenizer(path.substring(k1,k2),"$.",false);
Node parent=m_root,node=null;
if(parent.getName().length()>0){
if(tk.hasMoreTokens()){
if(!tk.nextToken().equals(parent.getName()))
throw new TreeMapperException(
"Find target data element failed, the root name is inconsistent with the path. root name="+parent.getName()+", path="+path);
} else {
return null;
}
}
while(tk.hasMoreTokens()&&parent!=null){
String token=tk.nextToken();
parent.expandNode();
node=parent.findChildFolder(token);
if(node!=null && node.isValueLeaf()){
if(path.endsWith(CROM.PRECONDITION_TAG)){
node=node.turnOffShortDisplay();
node=insertPreconditionNode(node);
}
return node;
}
if(node==null&&(parent.isDerivedTypeHolder()||parent.isSubstitutionGroupHeader())){
// this could be a derived type or a substitution group
String typeName=StringUtils.substringBefore(token, "#");
node=parent.expandHoldersTypeNode(typeName,token);
}
if(node==null){
int k=token.indexOf('#');
if(k>=0){
if((k+1)<token.length()){
int i_mapping=Integer.parseInt(token.substring(k+1));
String name=token.substring(0,k);
node=parent.findChildFolder(name);
if(node!=null){
node.expandNode();
node.insertMultipleMapping(i_mapping);
}
} else {
throw new TreeMapperException("Find target data element failed, path="+path);
}
}
else {
parent.expandNode();
}
node=parent.findChildFolder(token);
}
parent=node;
}
if(parent!=null){
parent.expandNode();
if(path.endsWith(CROM.PRECONDITION_TAG)){
insertPreconditionNode(parent);
}
}