From: <bo...@us...> - 2007-05-29 12:31:29
|
Revision: 216 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=216&view=rev Author: bodewig Date: 2007-05-29 05:31:26 -0700 (Tue, 29 May 2007) Log Message: ----------- fix PMD detected problems, nothing major Modified Paths: -------------- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameQualifier.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeInputStream.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/TolerantSaxDocumentBuilder.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Transform.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/Validator.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathNodeTracker.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/MultiLevelElementNameAndTextQualifier.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/XPathRegexAssert.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitException.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitRuntimeException.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/XMLUnitNamespaceContext2Jaxp13.java Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DetailedDiff.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -73,7 +73,6 @@ */ public int differenceFound(Difference difference) { final int returnValue = super.differenceFound(difference); - Difference localDifference = null; switch (returnValue) { case RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL: return returnValue; @@ -82,6 +81,11 @@ case RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR: difference.setRecoverable(true); break; + default: + throw new IllegalArgumentException(returnValue + + " is not a defined " + + " DifferenceListener" + + ".RETURN_... value"); } allDifferences.add(difference); return returnValue; Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Diff.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -279,7 +279,7 @@ * @param difference */ private void appendDifference(StringBuffer appendTo, Difference difference) { - appendTo.append(" ").append(difference).append('\n'); + appendTo.append(' ').append(difference).append('\n'); } /** Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DifferenceEngine.java 2007-05-29 12:31:26 UTC (rev 216) @@ -37,7 +37,6 @@ package org.custommonkey.xmlunit; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -264,7 +263,7 @@ boolean flag = n.hasChildNodes(); if (flag && XMLUnit.getIgnoreComments()) { List nl = nodeList2List(n.getChildNodes()); - flag = nl.size() > 0; + flag = !nl.isEmpty(); } return flag ? Boolean.TRUE : Boolean.FALSE; } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeReader.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/DoctypeSupport.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -76,7 +76,7 @@ StringBuffer sb = new StringBuffer(DOCTYPE_OPEN_DECL); sb.append(DOCTYPE).append(name).append(SYSTEM) - .append(systemId).append("\"").append(DOCTYPE_CLOSE_DECL); + .append(systemId).append('\"').append(DOCTYPE_CLOSE_DECL); String s = sb.toString(); IntegerBuffer buf = new IntegerBuffer(s.length() * (characters ? 1 : 2)); Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameQualifier.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameQualifier.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/ElementNameQualifier.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeInputStream.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeInputStream.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/NodeInputStream.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/SimpleXpathEngine.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -228,10 +228,10 @@ prefix = ""; } - if (uri.indexOf("'") != -1) { + if (uri.indexOf('\'') != -1) { quoteStyle = "\""; } - nsDecls.append(" ").append(XMLNS_PREFIX); + nsDecls.append(' ').append(XMLNS_PREFIX); if (prefix.length() > 0) { nsDecls.append(':'); } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/TolerantSaxDocumentBuilder.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/TolerantSaxDocumentBuilder.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/TolerantSaxDocumentBuilder.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -158,7 +158,6 @@ return; } - String nodeName; Node parentNode = null; boolean atDocumentRoot = false, foundTagToEnd = false; Element startElement = currentElement; Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Transform.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Transform.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Transform.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -37,6 +37,7 @@ package org.custommonkey.xmlunit; import org.custommonkey.xmlunit.exceptions.ConfigurationException; +import org.custommonkey.xmlunit.exceptions.XMLUnitRuntimeException; import java.io.File; import java.io.StringReader; @@ -178,7 +179,8 @@ try { return PWD.toURL().toExternalForm(); } catch (MalformedURLException e) { - throw new RuntimeException("Unable to determine current working directory!"); + throw new XMLUnitRuntimeException("Unable to determine current " + + "working directory!", e); } } /** Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/Validator.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/Validator.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/Validator.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2001-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathEngine.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathEngine.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2006-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -36,11 +36,9 @@ package org.custommonkey.xmlunit; -import org.custommonkey.xmlunit.exceptions.ConfigurationException; import org.custommonkey.xmlunit.exceptions.XpathException; import org.w3c.dom.Document; -import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathNodeTracker.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathNodeTracker.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/XpathNodeTracker.java 2007-05-29 12:31:26 UTC (rev 216) @@ -62,7 +62,7 @@ * Simple constructor */ public XpathNodeTracker() { - indent(); + newLevel(); } /** @@ -81,6 +81,10 @@ if (currentEntry != null) { currentEntry.clearTrackedAttribute(); } + newLevel(); + } + + private void newLevel() { currentEntry = new TrackingEntry(); indentationList.add(currentEntry); } @@ -138,6 +142,9 @@ case Node.TEXT_NODE: visitedNode(node, XPATH_CHARACTER_NODE_IDENTIFIER); break; + default: + // ignore unhandled node types + break; } } @@ -203,15 +210,15 @@ value = startAt; } - public final void increment() { + public void increment() { ++value; } - public final int getValue() { + public int getValue() { return value; } - public final Integer toInteger() { + public Integer toInteger() { return new Integer(value); } } @@ -237,7 +244,7 @@ * @param visited the non-attribute node visited * @param value the String-ified value of the non-attribute node visited */ - public final void trackNode(Node visited, String value) { + public void trackNode(Node visited, String value) { if (nodeReferenceMap == null || trackNodeReferences) { Int occurrence = lookup(value); if (occurrence == null) { @@ -260,14 +267,14 @@ * Keep a reference to the visited attribute at the current visited node * @param value the attribute visited */ - public final void trackAttribute(String visited) { + public void trackAttribute(String visited) { currentAttribute = visited; } /** * Clear any reference to the current visited attribute */ - public final void clearTrackedAttribute() { + public void clearTrackedAttribute() { currentAttribute = null; } @@ -275,7 +282,7 @@ * Append the details of the current visited node to a StringBuffer * @param buf the StringBuffer to append to */ - public final void appendEntryTo(StringBuffer buf) { + public void appendEntryTo(StringBuffer buf) { if (currentValue == null) { return; } Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/MultiLevelElementNameAndTextQualifier.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/MultiLevelElementNameAndTextQualifier.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/MultiLevelElementNameAndTextQualifier.java 2007-05-29 12:31:26 UTC (rev 216) @@ -38,8 +38,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; import org.custommonkey.xmlunit.ElementNameAndTextQualifier; import org.custommonkey.xmlunit.ElementNameQualifier; Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/XPathRegexAssert.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/XPathRegexAssert.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/examples/XPathRegexAssert.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,7 +1,7 @@ // -*- Mode: JDE -*- /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2006-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -56,6 +56,8 @@ */ public class XPathRegexAssert { + // no instances + private XPathRegexAssert() {} public static void assertXPathMatches(String message, String regex, String xpath, Document doc) Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitException.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitException.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitException.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2006-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitRuntimeException.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitRuntimeException.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XMLUnitRuntimeException.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2006-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -55,6 +55,15 @@ } /** + * Inititializes an exeption without cause. + * + * @param message the detail message + */ + public XMLUnitRuntimeException(String message) { + this(message, null); + } + + /** * Root cause of the exception, if any. */ public Throwable getCause() { Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/exceptions/XpathException.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2006-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/Jaxp13XpathEngine.java 2007-05-29 12:31:26 UTC (rev 216) @@ -48,7 +48,6 @@ import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; -import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** Modified: trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/XMLUnitNamespaceContext2Jaxp13.java =================================================================== --- trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/XMLUnitNamespaceContext2Jaxp13.java 2007-05-29 11:35:11 UTC (rev 215) +++ trunk/xmlunit/src/java/org/custommonkey/xmlunit/jaxp13/XMLUnitNamespaceContext2Jaxp13.java 2007-05-29 12:31:26 UTC (rev 216) @@ -1,6 +1,6 @@ /* ****************************************************************** -Copyright (c) 2001, Jeff Martin, Tim Bacon +Copyright (c) 2006-2007, Jeff Martin, Tim Bacon All rights reserved. Redistribution and use in source and binary forms, with or without @@ -52,7 +52,7 @@ public class XMLUnitNamespaceContext2Jaxp13 implements javax.xml.namespace.NamespaceContext { - private final HashMap/*<String, String>*/ nsMap; + private final Map/*<String, String>*/ nsMap; public XMLUnitNamespaceContext2Jaxp13(NamespaceContext ctx) { nsMap = turnIntoMap(ctx); @@ -91,7 +91,7 @@ return i.hasNext() ? (String) i.next() : null; } - private static HashMap turnIntoMap(NamespaceContext ctx) { + private static Map turnIntoMap(NamespaceContext ctx) { HashMap/*<String, String>*/ m = new HashMap(); for (Iterator i = ctx.getPrefixes(); i.hasNext(); ) { String prefix = (String) i.next(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |