Skip to content
Permalink
Browse files
checkstyle/pmd
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/jxpath/trunk@670727 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mbenson committed Jun 23, 2008
1 parent 738c838 commit d783b219111b2f92b048a5588f6de3d4e8040c2b
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 62 deletions.
@@ -148,7 +148,7 @@ public abstract JXPathContext newContext(
try {
debug = System.getProperty("jxpath.debug") != null;
}
catch (SecurityException se) {
catch (SecurityException se) { //NOPMD
// This is ok
}
}
@@ -174,7 +174,7 @@ private static String findFactory(String property, String defaultFactory) {
}

}
catch (SecurityException se) {
catch (SecurityException se) { //NOPMD
// Ignore
}

@@ -193,11 +193,13 @@ private static String findFactory(String property, String defaultFactory) {
FileInputStream fis = new FileInputStream(f);
try {
props.load(fis);
} finally {
}
finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
}
catch (IOException e) { //NOPMD
//swallow
}
}
@@ -240,10 +242,12 @@ private static String findFactory(String property, String defaultFactory) {
String factory = null;
try {
factory = rd.readLine();
} finally {
}
finally {
try {
rd.close();
} catch (IOException e) {
}
catch (IOException e) { //NOPMD
//swallow
}
}
@@ -168,7 +168,7 @@ private static synchronized JXPathBeanInfo findInformant(Class beanClass) {
try {
return (JXPathBeanInfo) instantiate(beanClass, name);
}
catch (Exception ex) {
catch (Exception ex) { //NOPMD
// Just drop through
}

@@ -178,7 +178,7 @@ private static synchronized JXPathBeanInfo findInformant(Class beanClass) {
return (JXPathBeanInfo) beanClass.newInstance();
}
}
catch (Exception ex) {
catch (Exception ex) { //NOPMD
// Just drop through
}

@@ -204,7 +204,7 @@ private static Object instantiate(Class sibling, String className)
Class cls = cl.loadClass(className);
return cls.newInstance();
}
catch (Exception ex) {
catch (Exception ex) { //NOPMD
// Just drop through and try the system classloader.
}
}
@@ -115,7 +115,7 @@ public Function getFunction(
String namespace,
String name,
Object[] parameters) {
if ((namespace == null && this.namespace != null)
if ((namespace == null && this.namespace != null) //NOPMD
|| (namespace != null && !namespace.equals(this.namespace))) {
return null;
}
@@ -352,11 +352,9 @@ public Object getValue(String xpath) {
public Object getValue(String xpath, Expression expr) {
Object result = expr.computeValue(getEvalContext());
if (result == null) {
if (expr instanceof Path) {
if (!isLenient()) {
throw new JXPathNotFoundException("No value for xpath: "
+ xpath);
}
if (expr instanceof Path && !isLenient()) {
throw new JXPathNotFoundException("No value for xpath: "
+ xpath);
}
return null;
}
@@ -89,7 +89,8 @@ public boolean nextNode() {
setStarted = true;
if (stack == null) {
stack = new Stack();
} else {
}
else {
stack.clear();
}
currentNodePointer = parentContext.getCurrentNodePointer();
@@ -83,7 +83,8 @@ public boolean nextNode() {
setStarted = true;
if (stack == null) {
stack = new Stack();
} else {
}
else {
stack.clear();
}
currentRootLocation = parentContext.getCurrentNodePointer();
@@ -48,10 +48,8 @@ public Pointer getSingleNodePointer() {
}

public NodePointer getCurrentNodePointer() {
if (position == 0) {
if (!setPosition(1)) {
return null;
}
if (position == 0 && !setPosition(1)) {
return null;
}
return nodePointer;
}
@@ -117,14 +117,12 @@ public boolean equals(Object object) {
}

BeanPointer other = (BeanPointer) object;
if (parent != other.parent) {
if (parent == null || !parent.equals(other.parent)) {
return false;
}
if (parent != other.parent && (parent == null || !parent.equals(other.parent))) {
return false;
}

if ((name == null && other.name != null)
|| (name != null && !name.equals(other.name))) {
|| (name != null && !name.equals(other.name))) {
return false;
}

@@ -135,8 +133,8 @@ public boolean equals(Object object) {
}

if (bean instanceof Number
|| bean instanceof String
|| bean instanceof Boolean) {
|| bean instanceof String
|| bean instanceof Boolean) {
return bean.equals(other.bean);
}
return bean == other.bean;
@@ -123,15 +123,16 @@ public Object getBaseValue() {
}

public void setIndex(int index) {
if (this.index != index) {
// When dealing with a scalar, index == 0 is equivalent to
// WHOLE_COLLECTION, so do not change it.
if (this.index != WHOLE_COLLECTION
if (this.index == index) {
return;
}
// When dealing with a scalar, index == 0 is equivalent to
// WHOLE_COLLECTION, so do not change it.
if (this.index != WHOLE_COLLECTION
|| index != 0
|| isCollection()) {
super.setIndex(index);
value = UNINITIALIZED;
}
super.setIndex(index);
value = UNINITIALIZED;
}
}

@@ -33,7 +33,7 @@
*/
public class DOMAttributePointer extends NodePointer {
private static final long serialVersionUID = 1115085175427555951L;

private Attr attr;

/**
@@ -66,29 +66,25 @@ public boolean canConvert(Object object, final Class toType) {
return true;
}

if (object instanceof Boolean) {
if (Number.class.isAssignableFrom(useType)
|| "java.util.concurrent.atomic.AtomicBoolean"
.equals(useType.getName())) {
return true;
}
if (object instanceof Boolean && (Number.class.isAssignableFrom(useType)
|| "java.util.concurrent.atomic.AtomicBoolean"
.equals(useType.getName()))) {
return true;
}
if (object instanceof Number) {
if (Number.class.isAssignableFrom(useType) || useType == Boolean.class) {
return true;
}
if (object instanceof Number
&& (Number.class.isAssignableFrom(useType) || useType == Boolean.class)) {
return true;
}
if (object instanceof String) {
if (useType == Boolean.class
|| useType == Character.class
|| useType == Byte.class
|| useType == Short.class
|| useType == Integer.class
|| useType == Long.class
|| useType == Float.class
|| useType == Double.class) {
if (object instanceof String
&& (useType == Boolean.class
|| useType == Character.class
|| useType == Byte.class
|| useType == Short.class
|| useType == Integer.class
|| useType == Long.class
|| useType == Float.class
|| useType == Double.class)) {
return true;
}
}
if (fromType.isArray()) {
// Collection -> array
@@ -509,7 +505,7 @@ public List getPointers() {
*/
static final class ValuePointer implements Pointer {
private static final long serialVersionUID = -4817239482392206188L;

private Object bean;

/**
@@ -70,7 +70,7 @@ public static Constructor lookupConstructor(
return constructor;
}
}
catch (NoSuchMethodException ex) {
catch (NoSuchMethodException ex) { //NOPMD
// Ignore
}
}
@@ -139,7 +139,7 @@ public static Method lookupStaticMethod(
return method;
}
}
catch (NoSuchMethodException ex) {
catch (NoSuchMethodException ex) { //NOPMD
// Ignore
}
}
@@ -224,7 +224,7 @@ public static Method lookupMethod(
return method;
}
}
catch (NoSuchMethodException ex) {
catch (NoSuchMethodException ex) { //NOPMD
// Ignore
}
}
@@ -599,7 +599,7 @@ public static Method getAccessibleMethod(Method method) {
try {
return clazz.getDeclaredMethod(name, parameterTypes);
}
catch (NoSuchMethodException e) {
catch (NoSuchMethodException e) { //NOPMD
//ignore
}
}
@@ -637,7 +637,7 @@ private static Method getAccessibleMethodFromInterfaceNest(Class clazz,
method =
interfaces[i].getDeclaredMethod(methodName, parameterTypes);
}
catch (NoSuchMethodException e) {
catch (NoSuchMethodException e) { //NOPMD
//ignore
}
if (method != null) {

0 comments on commit d783b21

Please sign in to comment.