Skip to content
Permalink
Browse files
findbugs
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/jxpath/trunk@668329 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mbenson committed Jun 16, 2008
1 parent 4466098 commit 65811463048ef988c857aa4c87a4db54a4a826a4
Show file tree
Hide file tree
Showing 23 changed files with 226 additions and 50 deletions.
@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<FindBugsFilter>
<Match>
<!-- deprecated class: -->
<Class name="org.apache.commons.jxpath.XMLDocumentContainer" />
</Match>
<Match>
<Package name="org.apache.commons.jxpath.ri.parser" />
</Match>
<Match>
<Or>
<Package name="org.apache.commons.jxpath.ri" />
<Package name="~org\.apache\.commons\.jxpath\.ri\..*" />
</Or>
<Or>
<Bug pattern="EI_EXPOSE_REP" />
<Bug pattern="EI_EXPOSE_REP2" />
<Bug pattern="MS_EXPOSE_REP" />
<Bug pattern="BC_UNCONFIRMED_CAST" />
</Or>
</Match>
<Match>
<Class name="org.apache.commons.jxpath.JXPathContextFactory" />
<Method name="findFactory" />
<Bug pattern="REC_CATCH_EXCEPTION" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.JXPathIntrospector" />
<Or>
<Method name="findInformant" />
<Method name="instantiate" />
</Or>
<Bug pattern="REC_CATCH_EXCEPTION" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.util.BasicTypeConverter" />
<Or>
<Method name="allocateNumber" />
<Method name="canCreateCollection" />
</Or>
<Bug pattern="REC_CATCH_EXCEPTION" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.util.ValueUtils" />
<Or>
<Method name="getValue" />
<Method name="setValue" />
</Or>
<Bug pattern="REC_CATCH_EXCEPTION" />
</Match>
<Match>
<Or>
<Class name="org.apache.commons.jxpath.xml.DOMParser" />
<Class name="org.apache.commons.jxpath.xml.JDOMParser" />
</Or>
<Method name="parseXML" />
<Bug pattern="REC_CATCH_EXCEPTION" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.JXPathBasicBeanInfo" />
<Method name="getPropertyDescriptors" />
<Or>
<Bug pattern="EI_EXPOSE_REP" />
<Bug pattern="NP_NULL_ON_SOME_PATH_EXCEPTION" />
</Or>
</Match>
<Match>
<Class name="org.apache.commons.jxpath.JXPathBasicBeanInfo" />
<Field name="propertyDescriptorMap" />
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer" />
<Field name="names" />
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.ri.compiler.CoreFunction" />
<Or>
<Local name="maxArgs" />
<Local name="minArgs" />
<Local name="argCount" />
</Or>
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.ri.axes.SimplePathInterpreter" />
<Local name="round" />
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
</Match>
<Match>
<Class name="~org\.apache\.commons\.jxpath\.ri\.model\.dyna.*\.Dyna.*Pointer" />
<Or>
<Field name="dynaBean" />
<Field name="handler" />
</Or>
<Bug pattern="SE_BAD_FIELD" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.ri.model.dom.DOMAttributePointer" />
<Field name="attr" />
<Bug pattern="SE_BAD_FIELD" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.ri.model.dom.DOMNodePointer" />
<Field name="node" />
<Bug pattern="SE_BAD_FIELD" />
</Match>
<!-- trust we're not dumb enough to do this by accident -->
<Match>
<Method name="equalStrings" />
<Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.ri.model.NodePointer" />
<Field name="rootNode" />
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.ri.model.NodePointer" />
<Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS" />
</Match>
<Match>
<Class name="org.apache.commons.jxpath.util.BasicTypeConverter$ValuePointer" />
<Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS" />
</Match>
<!-- if/when we go to Java 1.4, use Double.compare(double, double) and remove this -->
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
</FindBugsFilter>
@@ -228,7 +228,7 @@ under the License.
<artifactId>findbugs-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<!--<excludeFilterFile>conf/findbugs-exclude-filter.xml</excludeFilterFile>-->
<excludeFilterFile>conf/findbugs-exclude-filter.xml</excludeFilterFile>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
@@ -36,11 +36,20 @@
* @version $Revision$ $Date$
*/
public class JXPathBasicBeanInfo implements JXPathBeanInfo {
private static final long serialVersionUID = -3863803443111484155L;

private static final Comparator PROPERTY_DESCRIPTOR_COMPARATOR = new Comparator() {
public int compare(Object left, Object right) {
return ((PropertyDescriptor) left).getName().compareTo(
((PropertyDescriptor) right).getName());
}
};

private boolean atomic = false;
private Class clazz;
private PropertyDescriptor[] propertyDescriptors;
private Class dynamicPropertyHandlerClass;
private HashMap propertyDescriptorMap;
private transient PropertyDescriptor[] propertyDescriptors;
private transient HashMap propertyDescriptorMap;

/**
* Create a new JXPathBasicBeanInfo.
@@ -106,20 +115,20 @@ public synchronized PropertyDescriptor[] getPropertyDescriptors() {
PropertyDescriptor[] pds = bi.getPropertyDescriptors();
PropertyDescriptor[] descriptors = new PropertyDescriptor[pds.length];
System.arraycopy(pds, 0, descriptors, 0, pds.length);
Arrays.sort(descriptors, new Comparator() {
public int compare(Object left, Object right) {
return ((PropertyDescriptor) left).getName().compareTo(
((PropertyDescriptor) right).getName());
}
});
Arrays.sort(descriptors, PROPERTY_DESCRIPTOR_COMPARATOR);
propertyDescriptors = descriptors;
}
catch (IntrospectionException ex) {
ex.printStackTrace();
}
}
}
return propertyDescriptors;
if (propertyDescriptors.length == 0) {
return propertyDescriptors;
}
PropertyDescriptor[] result = new PropertyDescriptor[propertyDescriptors.length];
System.arraycopy(propertyDescriptors, 0, result, 0, propertyDescriptors.length);
return result;
}

public synchronized PropertyDescriptor getPropertyDescriptor(String propertyName) {
@@ -17,6 +17,7 @@
package org.apache.commons.jxpath;

import java.beans.PropertyDescriptor;
import java.io.Serializable;

/**
* JXPathBeanInfo is similar to {@link java.beans.BeanInfo} in that it describes
@@ -33,7 +34,7 @@
* @author Dmitri Plotnikov
* @version $Revision$ $Date$
*/
public interface JXPathBeanInfo {
public interface JXPathBeanInfo extends Serializable {

/**
* Returns true if objects of this class are treated as atomic
@@ -212,7 +212,7 @@ private static String findFactory(String property, String defaultFactory) {
}
}
}
catch (Exception ex) {
catch (IOException ex) {
if (debug) {
ex.printStackTrace();
}
@@ -16,6 +16,7 @@
*/
package org.apache.commons.jxpath.ri;

import java.io.Serializable;
import java.util.HashMap;

import org.apache.commons.jxpath.Pointer;
@@ -28,7 +29,9 @@
* @author Dmitri Plotnikov
* @version $Revision$ $Date$
*/
public class NamespaceResolver implements Cloneable {
public class NamespaceResolver implements Cloneable, Serializable {
private static final long serialVersionUID = 1085590057838651311L;

/** Parent NamespaceResolver */
protected final NamespaceResolver parent;
/** namespace map */
@@ -36,8 +36,8 @@
public class DescendantContext extends EvalContext {
private NodeTest nodeTest;
private boolean setStarted = false;
private Stack stack;
private NodePointer currentNodePointer;
private Stack stack = null;
private NodePointer currentNodePointer = null;
private boolean includeSelf;
private static final NodeTest ELEMENT_NODE_TEST =
new NodeTypeTest(Compiler.NODE_TYPE_NODE);
@@ -87,7 +87,11 @@ public boolean setPosition(int position) {
public boolean nextNode() {
if (!setStarted) {
setStarted = true;
stack = new Stack();
if (stack == null) {
stack = new Stack();
} else {
stack.clear();
}
currentNodePointer = parentContext.getCurrentNodePointer();
if (currentNodePointer != null) {
if (!currentNodePointer.isLeaf()) {
@@ -32,7 +32,7 @@
public class PrecedingOrFollowingContext extends EvalContext {
private NodeTest nodeTest;
private boolean setStarted = false;
private Stack stack;
private Stack stack = null;
private NodePointer currentNodePointer;
private NodePointer currentRootLocation;
private boolean reverse;
@@ -62,7 +62,6 @@ public int getDocumentOrder() {

public void reset() {
super.reset();
stack = new Stack();
setStarted = false;
}

@@ -82,6 +81,11 @@ public boolean setPosition(int position) {
public boolean nextNode() {
if (!setStarted) {
setStarted = true;
if (stack == null) {
stack = new Stack();
} else {
stack.clear();
}
currentRootLocation = parentContext.getCurrentNodePointer();
NodePointer parent = currentRootLocation.getParent();
if (parent != null) {
@@ -178,7 +178,7 @@ public boolean computeContextDependent() {
return true;
}

switch(functionCode) {
switch (functionCode) {
case Compiler.FUNCTION_LAST:
case Compiler.FUNCTION_POSITION:
return true;
@@ -192,6 +192,9 @@ public boolean computeContextDependent() {
case Compiler.FUNCTION_NUMBER:
return args == null || args.length == 0;

case Compiler.FUNCTION_FORMAT_NUMBER:
return args != null && args.length == 2;

case Compiler.FUNCTION_COUNT:
case Compiler.FUNCTION_ID:
case Compiler.FUNCTION_CONCAT:
@@ -210,10 +213,6 @@ public boolean computeContextDependent() {
case Compiler.FUNCTION_FLOOR:
case Compiler.FUNCTION_CEILING:
case Compiler.FUNCTION_ROUND:
return false;

case Compiler.FUNCTION_FORMAT_NUMBER:
return args != null && args.length == 2;
default:
return false;
}
@@ -54,8 +54,8 @@ public abstract class NodePointer implements Pointer {
protected int index = WHOLE_COLLECTION;

private boolean attribute = false;
private transient Object rootNode;
private NamespaceResolver namespaceResolver;
private transient Object rootNode;

/**
* Allocates an entirely new NodePointer by iterating through all installed
@@ -546,7 +546,7 @@ public Locale getLocale() {
public boolean isLanguage(String lang) {
Locale loc = getLocale();
String name = loc.toString().replace('_', '-');
return name.toUpperCase().startsWith(lang.toUpperCase());
return name.toUpperCase(Locale.ENGLISH).startsWith(lang.toUpperCase(Locale.ENGLISH));
}

/**
@@ -35,7 +35,7 @@
public class BeanPointer extends PropertyOwnerPointer {
private QName name;
private Object bean;
private JXPathBeanInfo beanInfo;//TODO determine serialization strategy
private JXPathBeanInfo beanInfo;

private static final long serialVersionUID = -8227317938284982440L;

@@ -32,16 +32,17 @@
* @version $Revision$ $Date$
*/
public class BeanPropertyPointer extends PropertyPointer {
private static final long serialVersionUID = -6008991447676468786L;

private static final Object UNINITIALIZED = new Object();

private String propertyName;
private JXPathBeanInfo beanInfo;
private PropertyDescriptor[] propertyDescriptors;
private PropertyDescriptor propertyDescriptor;//TODO determine proper serialization strategy
private String[] names;
private static final Object UNINITIALIZED = new Object();
private Object baseValue = UNINITIALIZED;
private Object value = UNINITIALIZED;

private static final long serialVersionUID = -6008991447676468786L;
private transient String[] names;
private transient PropertyDescriptor[] propertyDescriptors;
private transient PropertyDescriptor propertyDescriptor;

/**
* Create a new BeanPropertyPointer.
@@ -120,8 +120,7 @@ public NodePointer getValuePointer() {
}

public NodePointer createPath(JXPathContext context) {
Object collection = getBaseValue();
if (ValueUtils.getLength(collection) <= index) {
if (ValueUtils.getLength(getBaseValue()) <= index) {
collection = ValueUtils.expandCollection(getNode(), index + 1);
}
return this;

0 comments on commit 6581146

Please sign in to comment.