From c6021715bda849618e5101bae4993fd323ae39e0 Mon Sep 17 00:00:00 2001 From: Daniel Trebbien Date: Thu, 12 Oct 2017 14:01:46 -0500 Subject: [PATCH 1/5] Replace use of obsolete Hashtable with HashMap --- .../jackrabbit/test/api/SysViewContentHandler.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java index c6c3ebaf215..51c01376ed8 100644 --- a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java +++ b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java @@ -40,8 +40,6 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; -import java.util.Hashtable; -import java.util.Enumeration; import java.util.Iterator; import java.util.Map; @@ -562,8 +560,8 @@ private void checkAllProps(NodeElemData nodeElem, boolean skipBinary) private void checkChildren(NodeElemData nodeElem, boolean noRecurse) throws RepositoryException, SAXException { - Hashtable childElemsFound = nodeElem.childNodeElemNames; boolean totalSumOk = false; + Map childElemsFound = nodeElem.childNodeElemNames; boolean partialSumOk = true; if (noRecurse) { totalSumOk = (childElemsFound.size() == 0); @@ -576,8 +574,7 @@ private void checkChildren(NodeElemData nodeElem, boolean noRecurse) NodeIterator nodeIter = nodeElem.node.getNodes(); long children = getSize(nodeIter); - for (Enumeration e = childElemsFound.elements(); e.hasMoreElements();) { - ChildNodeElem child = e.nextElement(); + for (ChildNodeElem child : childElemsFound.values()) { String name = child.name; long number = child.number; @@ -654,7 +651,7 @@ private class NodeElemData { int position = 0; // the childNodeElems (stored are key: name and // value: number of the same name siblings) - Hashtable childNodeElemNames = new Hashtable(); + Map childNodeElemNames = new HashMap(); } /** From 7486e04061459fe3b82b4f44f10cc7e5402451e2 Mon Sep 17 00:00:00 2001 From: Daniel Trebbien Date: Thu, 12 Oct 2017 14:03:29 -0500 Subject: [PATCH 2/5] Replace use of StringBuffer with StringBuilder --- .../org/apache/jackrabbit/test/api/SysViewContentHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java index 51c01376ed8..adbb388ca97 100644 --- a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java +++ b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java @@ -65,7 +65,7 @@ class SysViewContentHandler extends DefaultHandler { // the propElem in process PropElemData currentPropElem; // the valueElem in process - protected StringBuffer currentValue; + protected StringBuilder currentValue; // prefix mapping data protected Map prefixes; // if the first node is yet treated @@ -250,7 +250,7 @@ else if (qName.equals(svProperty)) { else if (qName.equals(svValue)) { // init - currentValue = new StringBuffer(); + currentValue = new StringBuilder(); } else { // invalid element name is used From 72f8de2bfbe2619d93e19312f2f356ed8348b01a Mon Sep 17 00:00:00 2001 From: Daniel Trebbien Date: Thu, 12 Oct 2017 14:04:25 -0500 Subject: [PATCH 3/5] Replace size() == 0 with isEmpty() --- .../org/apache/jackrabbit/test/api/SysViewContentHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java index adbb388ca97..f7142ed1167 100644 --- a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java +++ b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java @@ -425,7 +425,7 @@ private void checkAllProps(NodeElemData nodeElem, boolean skipBinary) List propElems = nodeElem.propElems; // no props exported - if (propElems.size() == 0) { + if (propElems.isEmpty()) { // if node has properties they should be of Binary type and skipBinary should be true if (node.hasProperties()) { if (skipBinary) { From aee05e29b5840c7a7b577899534bbb4c3dc10574 Mon Sep 17 00:00:00 2001 From: Daniel Trebbien Date: Thu, 12 Oct 2017 14:05:43 -0500 Subject: [PATCH 4/5] Remove unused variable assignments --- .../apache/jackrabbit/test/api/SysViewContentHandler.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java index f7142ed1167..e098b37f83b 100644 --- a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java +++ b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java @@ -560,13 +560,10 @@ private void checkAllProps(NodeElemData nodeElem, boolean skipBinary) private void checkChildren(NodeElemData nodeElem, boolean noRecurse) throws RepositoryException, SAXException { - boolean totalSumOk = false; Map childElemsFound = nodeElem.childNodeElemNames; + boolean totalSumOk; boolean partialSumOk = true; - if (noRecurse) { - totalSumOk = (childElemsFound.size() == 0); - } - else { + if (!noRecurse) { // all children found if number of node.getNodes(name) is the same as found // in childElemsFound and if sum(number of nodeGetNodes(names)) // == number of node.getNodes() From e3afd5b74fbd13556967a6f2f6c8616df43f5341 Mon Sep 17 00:00:00 2001 From: Daniel Trebbien Date: Thu, 12 Oct 2017 14:06:01 -0500 Subject: [PATCH 5/5] Fix a typo --- .../org/apache/jackrabbit/test/api/SysViewContentHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java index e098b37f83b..ecfd50b09f0 100644 --- a/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java +++ b/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/SysViewContentHandler.java @@ -87,7 +87,7 @@ class SysViewContentHandler extends DefaultHandler { /** * Constructor - * @param path Thepath to the root node of the tree to be exported. + * @param path The path to the root node of the tree to be exported. * @param session The session used. * @param skipBinary Boolean if the binary properties are not exported. * @param noRecurse Boolean if only the root node of the tree should be exported.