// set the property.
int dot = helmaKey.indexOf(".");
if (dot > -1) {
String prototype = helmaKey.substring(0, dot);
INode node = (INode) nodeCache.get(prototype);
helmaKey = helmaKey.substring(dot + 1);
if ((node != null) && (node.getString(helmaKey) == null)) {
node.setString(helmaKey, XmlUtil.getTextContent(childNode));
}
} else if (helmaNode.getString(helmaKey) == null) {
helmaNode.setString(helmaKey, XmlUtil.getTextContent(childNode));
if (DEBUG) {
debug("childtext-2-property mapping, setting " + helmaKey +
" as string");
}
}
continue;
}
// is there a simple child-2-property mapping?
// (lets the user define to use only one element and make this a property
// and simply ignore other elements of the same name)
if ((props != null) && props.containsKey(domKey + "._property")) {
helmaKey = props.getProperty(domKey + "._property");
// if property is set but without value, read elementname for this mapping:
if (helmaKey.equals("")) {
helmaKey = childElement.getNodeName().replace(':',
defaultSeparator);
}
if (DEBUG) {
debug("child-2-property mapping, helmaKey " + helmaKey +
" for domKey " + domKey);
}
// get the node on which to opererate, depending on the helmaKey
// value from the properties file.
INode node = helmaNode;
int dot = helmaKey.indexOf(".");
if (dot > -1) {
String prototype = helmaKey.substring(0, dot);
if (!prototype.equalsIgnoreCase(node.getPrototype())) {
node = (INode) nodeCache.get(prototype);
}
helmaKey = helmaKey.substring(dot + 1);
}
if (node == null) {
continue;
}
if (node.getNode(helmaKey) == null) {
convert(childElement, node.createNode(helmaKey), nodeCache);
if (DEBUG) {
debug("read " + childElement.toString() +
node.getNode(helmaKey).toString());
}
}
continue;
}
// map it to one of the children-lists
helma.objectmodel.INode newHelmaNode = null;
String childrenMapping = props.getProperty(element.getNodeName() +
"._children");
// do we need a mapping directly among _children of helmaNode?
// can either be through property elname._children=_all or elname._children=childname
if ((childrenMapping != null) &&
(childrenMapping.equals("_all") ||
childrenMapping.equals(childElement.getNodeName()))) {
newHelmaNode = convert(childElement, helmaNode.createNode(null),
nodeCache);
}
// in which virtual subnode collection should objects of this type be stored?
helmaKey = props.getProperty(domKey);
if ((helmaKey == null) && !sparse) {
helmaKey = childElement.getNodeName().replace(':', defaultSeparator);
}
if (helmaKey == null) {
// we don't map this child element itself since we do
// sparse parsing, but there may be something of interest
// in the child's attributes and child elements.
attributes(childElement, helmaNode, nodeCache);
children(childElement, helmaNode, nodeCache);
continue;
}
// get the node on which to opererate, depending on the helmaKey
// value from the properties file.
INode node = helmaNode;
int dot = helmaKey.indexOf(".");
if (dot > -1) {
String prototype = helmaKey.substring(0, dot);
if (!prototype.equalsIgnoreCase(node.getPrototype())) {
node = (INode) nodeCache.get(prototype);
}
helmaKey = helmaKey.substring(dot + 1);
}
if (node == null) {
continue;
}
// try to get the virtual node
INode worknode = null;
if ("_children".equals(helmaKey)) {
worknode = node;
} else {
worknode = node.getNode(helmaKey);
if (worknode == null) {
// if virtual node doesn't exist, create it
worknode = helmaNode.createNode(helmaKey);
}
}
if (DEBUG) {
debug("mounting child " + childElement.getNodeName() +
" at worknode " + worknode.toString());
}
// now mount it, possibly re-using the helmaNode that's been created before
if (newHelmaNode != null) {
worknode.addNode(newHelmaNode);
} else {
convert(childElement, worknode.createNode(null), nodeCache);
}
}
// forget about other types (comments etc)
continue;