Skip to content

Commit d558b83

Browse files
[refactor] Fix bugs and issues that SonarCloud reported, and fix JavaDoc errors
1 parent 7d93a71 commit d558b83

21 files changed

+57
-51
lines changed

exist-core/src/main/java/org/exist/Indexer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public void endCDATA() {
281281
if (!stack.isEmpty()) {
282282
final ElementImpl last = stack.peek();
283283
if (charBuf != null && charBuf.length() > 0) {
284-
final CDATASectionImpl cdata = new CDATASectionImpl((last != null) ? last.getExpression() : null, charBuf);
284+
final CDATASectionImpl cdata = new CDATASectionImpl(last.getExpression(), charBuf);
285285
cdata.setOwnerDocument(document);
286286
last.appendChildInternal(prevNode, cdata);
287287
if (!validate) {

exist-core/src/main/java/org/exist/backup/restore/AbstractRestoreHandler.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ protected AbstractRestoreHandler(final DBBroker broker, @Nullable final Txn tran
120120
/**
121121
* Either reuses the provided transaction
122122
* in a safe manner or starts a new transaction.
123+
*
124+
* @return the provided transaction or a new transaction
123125
*/
124126
protected Txn beginTransaction() {
125127
if (transaction == null) {
@@ -561,13 +563,16 @@ private static String getAttr(final Attributes atts, final String name, final St
561563
}
562564

563565
/**
566+
* Returns a new restore handler.
567+
*
564568
* @param broker the database broker
565569
* @param transaction the transaction to use for the entire restore,
566570
* or null if restoring each collection/resource
567571
* should occur in its own transaction
568572
* @param descriptor the backup descriptor to start restoring from
569573
* @param listener the listener to report restore events to
570574
* @param pathsToIgnore database paths to ignore in the backup
575+
* @return a new restore handler
571576
*/
572577
protected abstract AbstractRestoreHandler newSelf(final DBBroker broker, @Nullable final Txn transaction,
573578
final BackupDescriptor descriptor, final RestoreListener listener,
@@ -578,6 +583,7 @@ protected abstract AbstractRestoreHandler newSelf(final DBBroker broker, @Nullab
578583
*
579584
* @param collectionUri The URI of the collection being restored.
580585
* @param attributes the attributes of the collection element from the backup descriptor.
586+
* @throws PermissionDeniedException if permission is denied
581587
*/
582588
protected void notifyStartCollectionRestore(final XmldbURI collectionUri, final Attributes attributes) throws PermissionDeniedException {
583589
// no-op by default, may be overridden by subclass
@@ -587,6 +593,7 @@ protected void notifyStartCollectionRestore(final XmldbURI collectionUri, final
587593
* Receives notification at the end of a Collection being restored.
588594
*
589595
* @param collectionUri The URI of the collection being restored.
596+
* @throws PermissionDeniedException if permission is denied
590597
*/
591598
protected void notifyEndCollectionRestore(final XmldbURI collectionUri) throws PermissionDeniedException {
592599
// no-op by default, may be overridden by subclass
@@ -597,6 +604,7 @@ protected void notifyEndCollectionRestore(final XmldbURI collectionUri) throws P
597604
*
598605
* @param documentUri The URI of the document being restored.
599606
* @param attributes the attributes of the collection element from the backup descriptor.
607+
* @throws PermissionDeniedException if permission is denied
600608
*/
601609
protected void notifyStartDocumentRestore(final XmldbURI documentUri, final Attributes attributes) throws PermissionDeniedException {
602610
// no-op by default, may be overridden by subclass
@@ -606,6 +614,7 @@ protected void notifyStartDocumentRestore(final XmldbURI documentUri, final Attr
606614
* Receives notification at the end of a Document being restored.
607615
*
608616
* @param documentUri The URI of the document being restored.
617+
* @throws PermissionDeniedException if permission is denied
609618
*/
610619
protected void notifyEndDocumentRestore(final XmldbURI documentUri) throws PermissionDeniedException {
611620
// no-op by default, may be overridden by subclass

exist-core/src/main/java/org/exist/dom/memtree/SAXAdapter.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,12 @@ public class SAXAdapter implements ContentHandler, LexicalHandler {
4545
private boolean replaceAttributeFlag = false;
4646
private boolean cdataFlag = false;
4747
private final StringBuilder cdataBuf = new StringBuilder();
48-
private final Expression expression;
4948

5049
public SAXAdapter() {
5150
this((Expression) null);
5251
}
5352

5453
public SAXAdapter(final Expression expression) {
55-
this.expression = expression;
5654
setBuilder(new MemTreeBuilder(expression));
5755
}
5856

@@ -61,7 +59,6 @@ public SAXAdapter(final XQueryContext context) {
6159
}
6260

6361
public SAXAdapter(final Expression expression, final XQueryContext context) {
64-
this.expression = expression;
6562
setBuilder(new MemTreeBuilder(expression, context));
6663
}
6764

exist-core/src/main/java/org/exist/dom/persistent/AbstractCharacterData.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,45 +34,45 @@ public abstract class AbstractCharacterData extends StoredNode implements Charac
3434

3535
protected XMLString cdata = null;
3636

37-
public AbstractCharacterData(final short nodeType) {
37+
protected AbstractCharacterData(final short nodeType) {
3838
this(null, nodeType);
3939
}
4040

41-
public AbstractCharacterData(final Expression expression, final short nodeType) {
41+
protected AbstractCharacterData(final Expression expression, final short nodeType) {
4242
super(expression, nodeType);
4343
}
4444

45-
public AbstractCharacterData(final short nodeType, final NodeId nodeId) {
45+
protected AbstractCharacterData(final short nodeType, final NodeId nodeId) {
4646
this(null, nodeType, nodeId);
4747
}
4848

49-
public AbstractCharacterData(final Expression expression, final short nodeType, final NodeId nodeId) {
49+
protected AbstractCharacterData(final Expression expression, final short nodeType, final NodeId nodeId) {
5050
super(expression, nodeType, nodeId);
5151
}
5252

53-
public AbstractCharacterData(final short nodeType, final NodeId nodeId, final String data) {
53+
protected AbstractCharacterData(final short nodeType, final NodeId nodeId, final String data) {
5454
this(null, nodeType, nodeId, data);
5555
}
5656

57-
public AbstractCharacterData(final Expression expression, final short nodeType, final NodeId nodeId, final String data) {
57+
protected AbstractCharacterData(final Expression expression, final short nodeType, final NodeId nodeId, final String data) {
5858
super(expression, nodeType, nodeId);
5959
cdata = new XMLString(data.toCharArray());
6060
}
6161

62-
public AbstractCharacterData(final short nodeType, final String data) {
62+
protected AbstractCharacterData(final short nodeType, final String data) {
6363
this(null, nodeType, data);
6464
}
6565

66-
public AbstractCharacterData(final Expression expression, final short nodeType, final String data) {
66+
protected AbstractCharacterData(final Expression expression, final short nodeType, final String data) {
6767
super(expression, nodeType);
6868
cdata = new XMLString(data.toCharArray());
6969
}
7070

71-
public AbstractCharacterData(final short nodeType, final char[] data, final int start, final int howmany) {
71+
protected AbstractCharacterData(final short nodeType, final char[] data, final int start, final int howmany) {
7272
this(null, nodeType, data, start, howmany);
7373
}
7474

75-
public AbstractCharacterData(final Expression expression, final short nodeType, final char[] data, final int start, final int howmany) {
75+
protected AbstractCharacterData(final Expression expression, final short nodeType, final char[] data, final int start, final int howmany) {
7676
super(expression, nodeType);
7777
cdata = new XMLString(data, start, howmany);
7878
}

exist-core/src/main/java/org/exist/dom/persistent/DocumentImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public DocumentImpl(final int docId, final DocumentImpl prevDoc) {
219219
/**
220220
* Creates a new persistent Document instance to replace an existing document instance.
221221
*
222+
* @param expression the expression from which the Document object derives
222223
* @param docId the id of the document
223224
* @param prevDoc The previous Document object that we are overwriting
224225
*/

exist-core/src/main/java/org/exist/dom/persistent/NamedNode.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ public abstract class NamedNode<T extends NamedNode> extends StoredNode<T> {
3535

3636
protected QName nodeName = null;
3737

38-
public NamedNode(final short nodeType) {
38+
protected NamedNode(final short nodeType) {
3939
this(null, nodeType);
4040
}
4141

42-
public NamedNode(final Expression expression, final short nodeType) {
42+
protected NamedNode(final Expression expression, final short nodeType) {
4343
super(expression, nodeType);
4444
}
4545

46-
public NamedNode(final short nodeType, final QName qname) {
46+
protected NamedNode(final short nodeType, final QName qname) {
4747
this(null, nodeType, qname);
4848
}
4949

50-
public NamedNode(final Expression expression, final short nodeType, final QName qname) {
50+
protected NamedNode(final Expression expression, final short nodeType, final QName qname) {
5151
super(expression, nodeType);
5252
this.nodeName = qname;
5353
}
@@ -61,20 +61,20 @@ protected NamedNode(final Expression expression, final short nodeType, final Nod
6161
this.nodeName = qname;
6262
}
6363

64-
protected NamedNode(final NamedNode other) {
64+
protected NamedNode(final NamedNode<T> other) {
6565
this(null, other);
6666
}
6767

68-
protected NamedNode(final Expression expression, final NamedNode other) {
68+
protected NamedNode(final Expression expression, final NamedNode<T> other) {
6969
super(expression, other);
7070
this.nodeName = other.nodeName;
7171
}
7272

7373
/**
7474
* Extracts just the details of the NamedNode
7575
*/
76-
public NamedNode extract() {
77-
return new NamedNode(getExpression(), this) {
76+
public NamedNode<T> extract() {
77+
return new NamedNode<T>(getExpression(), this) {
7878
};
7979
}
8080

exist-core/src/main/java/org/exist/dom/persistent/NodeImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public abstract class NodeImpl<T extends NodeImpl> implements INode<DocumentImpl
3838

3939
private final Expression expression;
4040

41-
public NodeImpl() {
41+
protected NodeImpl() {
4242
this(null);
4343
}
4444

45-
public NodeImpl(final Expression expression) {
45+
protected NodeImpl(final Expression expression) {
4646
this.expression = expression;
4747
}
4848

exist-core/src/main/java/org/exist/dom/persistent/NodeProxy.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,11 @@ public NodeProxy(final NodeHandle n) {
228228
/**
229229
* Creates a new <code>NodeProxy</code> instance.
230230
*
231+
* @param expression the expression from which the node handle derives
231232
* @param n a <code>NodeHandle</code> value
232233
*/
233234
public NodeProxy(final Expression expression, final NodeHandle n) {
234-
this((expression == null && n != null && n instanceof NodeProxy) ? ((NodeProxy) n).getExpression() : expression, n.getOwnerDocument(), n.getNodeId(), n.getNodeType(), n.getInternalAddress());
235+
this((expression == null && n instanceof NodeProxy) ? ((NodeProxy) n).getExpression() : expression, n.getOwnerDocument(), n.getNodeId(), n.getNodeType(), n.getInternalAddress());
235236
if(n instanceof NodeProxy) {
236237
this.match = ((NodeProxy) n).match;
237238
this.context = ((NodeProxy) n).context;
@@ -250,6 +251,7 @@ public NodeProxy(final DocumentImpl doc) {
250251
/**
251252
* create a proxy to a document node
252253
*
254+
* @param expression the expression from which the document node derives
253255
* @param doc a <code>DocumentImpl</code> value
254256
*/
255257
public NodeProxy(final Expression expression, final DocumentImpl doc) {

exist-core/src/main/java/org/exist/dom/persistent/StoredNode.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ protected StoredNode(final Expression expression, final short nodeType) {
8585
/**
8686
* Creates a new <code>StoredNode</code> instance.
8787
*
88-
* @param expression the expression from which the node derives
8988
* @param nodeType a <code>short</code> value
9089
* @param nodeId a <code>NodeId</code> value
9190
*/

exist-core/src/main/java/org/exist/dom/persistent/TextImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static StoredNode deserialize(final byte[] data, final int start, final i
104104
if(pooled) {
105105
text = (TextImpl) NodePool.getInstance().borrowNode(Node.TEXT_NODE);
106106
} else {
107-
text = new TextImpl((doc != null) ? doc.getExpression() : null);
107+
text = new TextImpl(doc.getExpression());
108108
}
109109
int pos = start;
110110
pos += LENGTH_SIGNATURE_LENGTH;

0 commit comments

Comments
 (0)