Commit 37e50895 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Removed always true IF statement.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8542 b35dd754-fafc-0310-a699-88a17e54d16e
parent f0daf674
package org.jivesoftware.util; package org.jivesoftware.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.Node; import org.dom4j.Node;
import java.util.*;
/** /**
* <p>We use a simple * <p>We use a simple
* naming convention of meta-data key names: data is stored * naming convention of meta-data key names: data is stored
...@@ -91,44 +88,39 @@ public class ElementUtil { ...@@ -91,44 +88,39 @@ public class ElementUtil {
* @return true if the specified property is included in the XML hierarchy. * @return true if the specified property is included in the XML hierarchy.
*/ */
public static boolean includesProperty(Element element, String name) { public static boolean includesProperty(Element element, String name) {
String value = null; String[] propName = parsePropertyName(name);
if (value == null) {
String[] propName = parsePropertyName(name);
// Grab the attribute if there is one // Grab the attribute if there is one
String lastName = propName[propName.length - 1]; String lastName = propName[propName.length - 1];
String attName = null; String attName = null;
int attributeIndex = lastName.indexOf(':'); int attributeIndex = lastName.indexOf(':');
if (attributeIndex >= 0) { if (attributeIndex >= 0) {
propName[propName.length - 1] = lastName.substring(0, attributeIndex); propName[propName.length - 1] = lastName.substring(0, attributeIndex);
attName = lastName.substring(attributeIndex + 1); attName = lastName.substring(attributeIndex + 1);
} }
// Search for this property by traversing down the XML hierarchy. // Search for this property by traversing down the XML hierarchy.
int i = propName[0].equals(element.getName()) ? 1 : 0; int i = propName[0].equals(element.getName()) ? 1 : 0;
for (; i < propName.length; i++) { for (; i < propName.length; i++) {
element = element.element(propName[i]); element = element.element(propName[i]);
if (element == null) { if (element == null) {
break; break;
}
} }
}
if (element != null) { if (element != null) {
if (attName == null){ if (attName == null){
// The property exists so return true // The property exists so return true
return true; return true;
} else { } else {
// The property exists if the attribute exists in the element // The property exists if the attribute exists in the element
return element.attribute(attName) != null; return element.attribute(attName) != null;
}
}
else {
// The property does not exist so return false
return false;
} }
} }
return true; else {
// The property does not exist so return false
return false;
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment