[jboss-cvs] JBossCache/src/org/jboss/cache/xml ...
Manik Surtani
msurtani at jboss.com
Tue Jul 18 13:50:56 EDT 2006
User: msurtani
Date: 06/07/18 13:50:56
Modified: src/org/jboss/cache/xml XmlHelper.java
Log:
Make sure configuration impl reads in configs properly
Revision Changes Path
1.10 +39 -5 JBossCache/src/org/jboss/cache/xml/XmlHelper.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: XmlHelper.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/xml/XmlHelper.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- XmlHelper.java 18 Jul 2006 10:50:46 -0000 1.9
+++ XmlHelper.java 18 Jul 2006 17:50:56 -0000 1.10
@@ -38,7 +38,14 @@
public static final String NAME="name";
- public static String getAttr(Element elem, String myName, String tagName, String attributeName)
+ /**
+ * Returns the contents of a specific node of given tagName, provided a certain attribute exists and contains value myValue.
+ * @param elem
+ * @param myName
+ * @param tagName
+ * @param attributeName
+ */
+ public static String getTagContents(Element elem, String myName, String tagName, String attributeName)
{
NodeList list = elem.getElementsByTagName(tagName);
@@ -52,26 +59,53 @@
String name = element.getAttribute(attributeName);
if (name.equals(myName))
{
- String valueStr = getElementContent(element, true);
- return valueStr;
+ return getElementContent(element, true);
}
}
return null;
}
+ /**
+ * Retrieves the value of a given attribute for the first encountered instance of a tag in an element.
+ * @param elem
+ * @param tagName
+ * @param attributeName
+ */
+ public static String getAttributeValue(Element elem, String tagName, String attributeName)
+ {
+ NodeList list = elem.getElementsByTagName(tagName);
+
+ for (int s = 0; s < list.getLength(); s++)
+ {
+ org.w3c.dom.Node node = list.item(s);
+ if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
+ continue;
+
+ Element element = (Element) node;
+ return element.getAttribute(attributeName);
+
+ }
+ return null;
+ }
+
public static Element getConfigSubElement(Element element)
{
+ return getSubElement(element, CONFIG_ATTR);
+ }
+
+ public static Element getSubElement(Element element, String subElementName)
+ {
NodeList nl=element.getChildNodes();
for(int i=0; i < nl.getLength(); i++)
{
Node node=nl.item(i);
- if(node.getNodeType() == Node.ELEMENT_NODE && CONFIG_ATTR.equals( ((Element)node).getTagName() ) )
+ if(node.getNodeType() == Node.ELEMENT_NODE && subElementName.equals( ((Element)node).getTagName() ) )
{
return (Element)node;
}
}
- log.debug("getConfigSubElement(): Does not exist for " + CONFIG_ATTR);
+ log.debug("getConfigSubElement(): Does not exist for " + subElementName);
return null;
}
More information about the jboss-cvs-commits
mailing list