[jboss-cvs] JBossCache/src/org/jboss/cache/xml ...
Manik Surtani
msurtani at jboss.com
Sat Dec 30 14:48:45 EST 2006
User: msurtani
Date: 06/12/30 14:48:45
Modified: src/org/jboss/cache/xml XmlHelper.java
Log:
Genericised, autoboxed
Revision Changes Path
1.13 +211 -204 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.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- XmlHelper.java 29 Sep 2006 18:27:21 -0000 1.12
+++ XmlHelper.java 30 Dec 2006 19:48:45 -0000 1.13
@@ -32,14 +32,15 @@
public class XmlHelper
{
private static Log log = LogFactory.getLog(XmlHelper.class);
- public static final String ROOT="mbean";
- public static final String ATTR="attribute";
- public static final String CONFIG_ATTR="config";
- public static final String NAME="name";
+ public static final String ROOT = "mbean";
+ public static final String ATTR = "attribute";
+ public static final String CONFIG_ATTR = "config";
+ public static final String NAME = "name";
/**
* 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
@@ -67,6 +68,7 @@
/**
* Retrieves the value of a given attribute for the first encountered instance of a tag in an element.
+ *
* @param elem
* @param tagName
* @param attributeName
@@ -95,13 +97,13 @@
public static Element getSubElement(Element element, String subElementName)
{
- NodeList nl=element.getChildNodes();
- for(int i=0; i < nl.getLength(); i++)
+ NodeList nl = element.getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++)
{
- Node node=nl.item(i);
- if(node.getNodeType() == Node.ELEMENT_NODE && subElementName.equals( ((Element)node).getTagName() ) )
+ Node node = nl.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE && subElementName.equals(((Element) node).getTagName()))
{
- return (Element)node;
+ return (Element) node;
}
}
@@ -153,17 +155,21 @@
}
}
- public static String escapeBackslashes(String value) {
+ public static String escapeBackslashes(String value)
+ {
StringBuffer buf = new StringBuffer(value);
- for(int looper = 0; looper < buf.length(); looper++) {
+ for (int looper = 0; looper < buf.length(); looper++)
+ {
char curr = buf.charAt(looper);
char next = 0;
- if(looper + 1 < buf.length())
- next = buf.charAt(looper+1);
+ if (looper + 1 < buf.length())
+ next = buf.charAt(looper + 1);
- if(curr == '\\') {
- if(next != '\\') { // only if not already escaped
- buf.insert(looper,'\\'); // escape backslash
+ if (curr == '\\')
+ {
+ if (next != '\\')
+ { // only if not already escaped
+ buf.insert(looper, '\\'); // escape backslash
}
looper++; // skip past extra backslash (either the one we added or existing)
}
@@ -194,7 +200,7 @@
String val = readStringContents(element, tagName);
if (val.equalsIgnoreCase("true") || val.equalsIgnoreCase("false"))
{
- return Boolean.valueOf(val).booleanValue();
+ return Boolean.valueOf(val);
}
return defaultValue;
}
@@ -210,27 +216,27 @@
public static Element getDocumentRoot(InputStream is)
{
- Document doc=null;
+ Document doc = null;
try
{
- InputSource xmlInp=new InputSource(is);
+ InputSource xmlInp = new InputSource(is);
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
- doc=parser.parse(xmlInp);
- Element root=doc.getDocumentElement();
+ doc = parser.parse(xmlInp);
+ Element root = doc.getDocumentElement();
root.normalize();
return root;
}
- catch(SAXParseException err)
+ catch (SAXParseException err)
{
log.error("Configurator SAXParse error", err);
}
- catch(SAXException e)
+ catch (SAXException e)
{
- log.error("Configurator SAX error",e);
+ log.error("Configurator SAX error", e);
}
- catch(Exception pce)
+ catch (Exception pce)
{
log.error("Configurator general error", pce);
}
@@ -239,6 +245,7 @@
/**
* Retrieves the boolean value of a given attribute for the first encountered instance of a tag in an element.
+ *
* @param elem
* @param tagName
* @param attributeName
More information about the jboss-cvs-commits
mailing list