Skip to content

Commit adefe70

Browse files
Reformat; add .editorconfig (#25)
Consistently make indentation 4 for all Java sources with spaces. Most files were already using indentation of 4, but with mixes of tabs and spaces.
1 parent a4fe77b commit adefe70

32 files changed

+1957
-1811
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
root = true
3+
4+
[*.java]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 4
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*]
12+
trim_trailing_whitespace = true
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.z3950.zing.cql;
22

3-
43
/**
54
* Represents an AND node in a CQL parse-tree.
65
*
@@ -9,26 +8,27 @@ public class CQLAndNode extends CQLBooleanNode {
98
/**
109
* Creates a new AND node with the specified left- and right-hand
1110
* sides and modifiers.
12-
* @param left the left-hand side of the AND
11+
*
12+
* @param left the left-hand side of the AND
1313
* @param right the right-hand side of the AND
14-
* @param ms the modifiers to apply to this AND
14+
* @param ms the modifiers to apply to this AND
1515
* @see ModifierSet
1616
* @see CQLNode
1717
* @see CQLBoolean
1818
* @see CQLBooleanNode
1919
*/
2020
public CQLAndNode(CQLNode left, CQLNode right, ModifierSet ms) {
21-
super(left, right, ms, CQLBoolean.AND);
22-
}
21+
super(left, right, ms, CQLBoolean.AND);
22+
}
2323

2424
// ### Too much code duplication here with OR and NOT
2525
@Override
2626
byte[] opType1() {
27-
byte[] op = new byte[5];
28-
putTag(CONTEXT, 46, CONSTRUCTED, op, 0); // Operator
29-
putLen(2, op, 2);
30-
putTag(CONTEXT, 0, PRIMITIVE, op, 3); // and
31-
putLen(0, op, 4);
32-
return op;
27+
byte[] op = new byte[5];
28+
putTag(CONTEXT, 46, CONSTRUCTED, op, 0); // Operator
29+
putLen(2, op, 2);
30+
putTag(CONTEXT, 0, PRIMITIVE, op, 3); // and
31+
putLen(0, op, 4);
32+
return op;
3333
}
3434
}

src/main/java/org/z3950/zing/cql/CQLBoolean.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* @author jakub
66
*/
77
public enum CQLBoolean {
8-
/** AND is the same as CQL's "and" */
9-
AND,
10-
/** OR is the same as CQL's "or" */
11-
OR,
12-
/** NOT is the same as CQL's "not" */
13-
NOT,
14-
/** PROX is the same as CQL's "prox" */
15-
PROX;
8+
/** AND is the same as CQL's "and" */
9+
AND,
10+
/** OR is the same as CQL's "or" */
11+
OR,
12+
/** NOT is the same as CQL's "not" */
13+
NOT,
14+
/** PROX is the same as CQL's "prox" */
15+
PROX;
1616
}

src/main/java/org/z3950/zing/cql/CQLBooleanNode.java

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ public abstract class CQLBooleanNode extends CQLNode {
1313
public CQLBoolean getOperator() {
1414
return operator;
1515
}
16-
16+
1717
private CQLNode left;
1818

1919
/**
2020
* The root of a parse-tree representing the left-hand side.
21+
*
2122
* @return the left operand of this boolean node
2223
*/
2324
public CQLNode getLeftOperand() {
@@ -28,6 +29,7 @@ public CQLNode getLeftOperand() {
2829

2930
/**
3031
* The root of a parse-tree representing the right-hand side.
32+
*
3133
* @return the right operand of this boolean node
3234
*/
3335
public CQLNode getRightOperand() {
@@ -38,32 +40,33 @@ public CQLNode getRightOperand() {
3840

3941
/**
4042
* The set of modifiers that are applied to this boolean.
43+
*
4144
* @return a list of Modifier objects, which may be empty.
4245
*/
4346
public List<Modifier> getModifiers() {
4447
return ms.getModifiers();
4548
}
4649

4750
protected CQLBooleanNode(CQLNode left, CQLNode right, ModifierSet ms, CQLBoolean operator) {
48-
this.left = left;
49-
this.right = right;
50-
this.ms = ms;
51+
this.left = left;
52+
this.right = right;
53+
this.ms = ms;
5154
this.operator = operator;
5255
}
5356

5457
@Override
5558
public void traverse(CQLNodeVisitor visitor) {
56-
visitor.onBooleanNodeStart(this);
57-
left.traverse(visitor);
58-
visitor.onBooleanNodeOp(this);
59-
right.traverse(visitor);
60-
visitor.onBooleanNodeEnd(this);
59+
visitor.onBooleanNodeStart(this);
60+
left.traverse(visitor);
61+
visitor.onBooleanNodeOp(this);
62+
right.traverse(visitor);
63+
visitor.onBooleanNodeEnd(this);
6164
}
6265

6366
@Override
6467
void toXCQLInternal(XCQLBuilder b, int level,
65-
List<CQLPrefix> prefixes, List<ModifierSet> sortkeys) {
66-
b.indent(level).append("<triple>\n");
68+
List<CQLPrefix> prefixes, List<ModifierSet> sortkeys) {
69+
b.indent(level).append("<triple>\n");
6770
renderPrefixes(b, level + 1, prefixes);
6871
ms.toXCQLInternal(b, level + 1, "boolean", "value");
6972
b.indent(level + 1).append("<leftOperand>\n");
@@ -78,35 +81,37 @@ void toXCQLInternal(XCQLBuilder b, int level,
7881

7982
@Override
8083
public String toCQL() {
81-
// ### We don't always need parens around the operands
82-
return ("(" + left.toCQL() + ")" +
83-
" " + ms.toCQL() + " " +
84-
"(" + right.toCQL() + ")");
84+
// ### We don't always need parens around the operands
85+
return ("(" + left.toCQL() + ")" +
86+
" " + ms.toCQL() + " " +
87+
"(" + right.toCQL() + ")");
8588
}
8689

8790
@Override
8891
public String toPQF(Properties config) throws PQFTranslationException {
89-
return ("@" + opPQF() +
90-
" " + left.toPQF(config) +
91-
" " + right.toPQF(config));
92+
return ("@" + opPQF() +
93+
" " + left.toPQF(config) +
94+
" " + right.toPQF(config));
9295
}
9396

9497
// represents the operation for PQF: overridden for CQLProxNode
95-
String opPQF() { return ms.getBase(); }
98+
String opPQF() {
99+
return ms.getBase();
100+
}
96101

97102
@Override
98103
public byte[] toType1BER(Properties config) throws PQFTranslationException {
99104
System.out.println("in CQLBooleanNode.toType1BER(): PQF=" +
100-
toPQF(config));
105+
toPQF(config));
101106
byte[] rpn1 = left.toType1BER(config);
102107
byte[] rpn2 = right.toType1BER(config);
103108
byte[] op = opType1();
104-
byte[] rpnStructure = new byte[rpn1.length+rpn2.length+op.length+4];
105-
106-
// rpnRpnOp
109+
byte[] rpnStructure = new byte[rpn1.length + rpn2.length + op.length + 4];
110+
111+
// rpnRpnOp
107112
int offset = putTag(CONTEXT, 1, CONSTRUCTED, rpnStructure, 0);
108113

109-
rpnStructure[offset++] = (byte)(0x80&0xff); // indefinite length
114+
rpnStructure[offset++] = (byte) (0x80 & 0xff); // indefinite length
110115
System.arraycopy(rpn1, 0, rpnStructure, offset, rpn1.length);
111116
offset += rpn1.length;
112117
System.arraycopy(rpn2, 0, rpnStructure, offset, rpn2.length);

src/main/java/org/z3950/zing/cql/CQLDefaultNodeVisitor.java

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,37 @@
22

33
/**
44
* Query tree visitor with default (no-op) implementation
5+
*
56
* @author jakub
67
*/
78
public class CQLDefaultNodeVisitor implements CQLNodeVisitor {
8-
9-
@Override
10-
public void onSortNode(CQLSortNode node) {
11-
}
12-
13-
@Override
14-
public void onPrefixNode(CQLPrefixNode node) {
15-
}
16-
17-
@Override
18-
public void onBooleanNodeStart(CQLBooleanNode node) {
19-
}
20-
21-
@Override
22-
public void onBooleanNodeOp(CQLBooleanNode node) {
23-
}
24-
25-
@Override
26-
public void onBooleanNodeEnd(CQLBooleanNode node) {
27-
}
28-
29-
@Override
30-
public void onTermNode(CQLTermNode node) {
31-
}
32-
33-
@Override
34-
public void onRelation(CQLRelation relation) {
35-
}
36-
9+
10+
@Override
11+
public void onSortNode(CQLSortNode node) {
12+
}
13+
14+
@Override
15+
public void onPrefixNode(CQLPrefixNode node) {
16+
}
17+
18+
@Override
19+
public void onBooleanNodeStart(CQLBooleanNode node) {
20+
}
21+
22+
@Override
23+
public void onBooleanNodeOp(CQLBooleanNode node) {
24+
}
25+
26+
@Override
27+
public void onBooleanNodeEnd(CQLBooleanNode node) {
28+
}
29+
30+
@Override
31+
public void onTermNode(CQLTermNode node) {
32+
}
33+
34+
@Override
35+
public void onRelation(CQLRelation relation) {
36+
}
37+
3738
}

0 commit comments

Comments
 (0)