Replaced (String)props.get() with props.getProperty().

Removed toLowerCase() because XML is supposed to be case
sensitive (or am I missing something here?)
This commit is contained in:
hns 2002-07-05 15:53:58 +00:00
parent 649aac3f7c
commit 8ee53d5a25

View file

@ -12,7 +12,9 @@ import helma.util.SystemProperties;
public class XmlConverter implements XmlConstants { public class XmlConverter implements XmlConstants {
private boolean DEBUG=false; private boolean DEBUG = false;
private boolean sparse = false;
private Properties props; private Properties props;
@ -78,7 +80,7 @@ public class XmlConverter implements XmlConstants {
if (DEBUG) if (DEBUG)
debug("reading " + element.getNodeName() ); debug("reading " + element.getNodeName() );
helmaNode.setName( element.getNodeName() ); helmaNode.setName( element.getNodeName() );
String prototype = (String)props.get(element.getNodeName().toLowerCase()+"._prototype"); String prototype = props.getProperty(element.getNodeName()+"._prototype");
if ( prototype == null ) if ( prototype == null )
prototype = "HopObject"; prototype = "HopObject";
helmaNode.setPrototype( prototype ); helmaNode.setPrototype( prototype );
@ -117,11 +119,11 @@ public class XmlConverter implements XmlConstants {
Element childElement = (Element)childNode; Element childElement = (Element)childNode;
// get the basic key we have to look for in the properties-table // get the basic key we have to look for in the properties-table
domKey = (element.getNodeName()+"."+childElement.getNodeName()).toLowerCase(); domKey = element.getNodeName()+"."+childElement.getNodeName();
// is there a childtext-2-property mapping? // is there a childtext-2-property mapping?
if ( props!=null && props.containsKey(domKey+"._text") ) { if ( props!=null && props.containsKey(domKey+"._text") ) {
helmaKey = (String)props.get(domKey+"._text"); helmaKey = props.getProperty(domKey+"._text");
if( helmaKey.equals("") ) if( helmaKey.equals("") )
// if property is set but without value, read elementname for this mapping // if property is set but without value, read elementname for this mapping
helmaKey = childElement.getNodeName().replace(':',defaultSeparator); helmaKey = childElement.getNodeName().replace(':',defaultSeparator);
@ -139,7 +141,7 @@ public class XmlConverter implements XmlConstants {
// (lets the user define to use only one element and make this a property // (lets the user define to use only one element and make this a property
// and simply ignore other elements of the same name) // and simply ignore other elements of the same name)
if ( props!=null && props.containsKey(domKey+"._property") ) { if ( props!=null && props.containsKey(domKey+"._property") ) {
helmaKey = (String)props.get(domKey+"._property"); helmaKey = props.getProperty(domKey+"._property");
// if property is set but without value, read elementname for this mapping: // if property is set but without value, read elementname for this mapping:
if ( helmaKey.equals("") ) if ( helmaKey.equals("") )
helmaKey = childElement.getNodeName().replace(':',defaultSeparator); helmaKey = childElement.getNodeName().replace(':',defaultSeparator);
@ -156,14 +158,14 @@ public class XmlConverter implements XmlConstants {
// map it to one of the children-lists // map it to one of the children-lists
helma.objectmodel.INode newHelmaNode = null; helma.objectmodel.INode newHelmaNode = null;
String childrenMapping = (String)props.get(element.getNodeName().toLowerCase()+"._children"); String childrenMapping = props.getProperty(element.getNodeName()+"._children");
// do we need a mapping directly among _children of helmaNode? // do we need a mapping directly among _children of helmaNode?
// can either be through property elname._children=_all or elname._children=childname // can either be through property elname._children=_all or elname._children=childname
if( childrenMapping!=null && ( childrenMapping.equals("_all") || childrenMapping.equals(childElement.getNodeName()) ) ) { if( childrenMapping!=null && ( childrenMapping.equals("_all") || childrenMapping.equals(childElement.getNodeName()) ) ) {
newHelmaNode = convert(childElement, helmaNode.createNode(null) ); newHelmaNode = convert(childElement, helmaNode.createNode(null) );
} }
// which name to choose for a virtual subnode: // which name to choose for a virtual subnode:
helmaKey = (String)props.get(domKey); helmaKey = props.getProperty(domKey);
if ( helmaKey==null ) { if ( helmaKey==null ) {
helmaKey = childElement.getNodeName().replace(':',defaultSeparator); helmaKey = childElement.getNodeName().replace(':',defaultSeparator);
} }
@ -188,7 +190,7 @@ public class XmlConverter implements XmlConstants {
// if there's some text content for this element, map it: // if there's some text content for this element, map it:
if ( textcontent.length()>0 ) { if ( textcontent.length()>0 ) {
helmaKey = (String)props.get(element.getNodeName().toLowerCase()+"._text"); helmaKey = props.getProperty(element.getNodeName()+"._text");
if ( helmaKey==null ) if ( helmaKey==null )
helmaKey = "text"; helmaKey = "text";
helmaNode.setString(helmaKey, textcontent.toString().trim() ); helmaNode.setString(helmaKey, textcontent.toString().trim() );
@ -210,7 +212,7 @@ public class XmlConverter implements XmlConstants {
} else if ( attr.getNodeName().equals("_name") ) { } else if ( attr.getNodeName().equals("_name") ) {
helmaNode.setName( attr.getNodeValue() ); helmaNode.setName( attr.getNodeValue() );
} else { } else {
String helmaKey = (String)props.get(element.getNodeName().toLowerCase()+"._attribute."+attr.getNodeName().toLowerCase()); String helmaKey = props.getProperty(element.getNodeName()+"._attribute."+attr.getNodeName());
if ( helmaKey==null ) if ( helmaKey==null )
helmaKey = attr.getNodeName().replace(':',defaultSeparator); helmaKey = attr.getNodeName().replace(':',defaultSeparator);
helmaNode.setString( helmaKey, attr.getNodeValue() ); helmaNode.setString( helmaKey, attr.getNodeValue() );
@ -224,8 +226,9 @@ public class XmlConverter implements XmlConstants {
*/ */
private void extractProperties( Properties props ) { private void extractProperties( Properties props ) {
if ( props.containsKey("separator") ) { if ( props.containsKey("separator") ) {
defaultSeparator = ((String)props.get("separator")).charAt(0); defaultSeparator = props.getProperty("separator").charAt(0);
} }
sparse = "sparse".equalsIgnoreCase (props.getProperty("_mode"));
} }
/** for testing */ /** for testing */