Skip to content

Improve whitespaces/indentation #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/main/java/org/z3950/zing/cql/CQLAndNode.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.z3950.zing.cql;


/**
* Represents an AND node in a CQL parse-tree.
*
Expand All @@ -18,17 +17,17 @@ public class CQLAndNode extends CQLBooleanNode {
* @see CQLBooleanNode
*/
public CQLAndNode(CQLNode left, CQLNode right, ModifierSet ms) {
super(left, right, ms, CQLBoolean.AND);
}
super(left, right, ms, CQLBoolean.AND);
}

// ### Too much code duplication here with OR and NOT
@Override
byte[] opType1() {
byte[] op = new byte[5];
putTag(CONTEXT, 46, CONSTRUCTED, op, 0); // Operator
putLen(2, op, 2);
putTag(CONTEXT, 0, PRIMITIVE, op, 3); // and
putLen(0, op, 4);
return op;
byte[] op = new byte[5];
putTag(CONTEXT, 46, CONSTRUCTED, op, 0); // Operator
putLen(2, op, 2);
putTag(CONTEXT, 0, PRIMITIVE, op, 3); // and
putLen(0, op, 4);
return op;
}
}
16 changes: 8 additions & 8 deletions src/main/java/org/z3950/zing/cql/CQLBoolean.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* @author jakub
*/
public enum CQLBoolean {
/** AND is the same as CQL's "and" */
AND,
/** OR is the same as CQL's "or" */
OR,
/** NOT is the same as CQL's "not" */
NOT,
/** PROX is the same as CQL's "prox" */
PROX;
/** AND is the same as CQL's "and" */
AND,
/** OR is the same as CQL's "or" */
OR,
/** NOT is the same as CQL's "not" */
NOT,
/** PROX is the same as CQL's "prox" */
PROX;
}
42 changes: 21 additions & 21 deletions src/main/java/org/z3950/zing/cql/CQLBooleanNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class CQLBooleanNode extends CQLNode {
public CQLBoolean getOperator() {
return operator;
}

private CQLNode left;

/**
Expand Down Expand Up @@ -45,25 +45,25 @@ public List<Modifier> getModifiers() {
}

protected CQLBooleanNode(CQLNode left, CQLNode right, ModifierSet ms, CQLBoolean operator) {
this.left = left;
this.right = right;
this.ms = ms;
this.left = left;
this.right = right;
this.ms = ms;
this.operator = operator;
}

@Override
public void traverse(CQLNodeVisitor visitor) {
visitor.onBooleanNodeStart(this);
left.traverse(visitor);
visitor.onBooleanNodeOp(this);
right.traverse(visitor);
visitor.onBooleanNodeEnd(this);
visitor.onBooleanNodeStart(this);
left.traverse(visitor);
visitor.onBooleanNodeOp(this);
right.traverse(visitor);
visitor.onBooleanNodeEnd(this);
}

@Override
void toXCQLInternal(XCQLBuilder b, int level,
List<CQLPrefix> prefixes, List<ModifierSet> sortkeys) {
b.indent(level).append("<triple>\n");
List<CQLPrefix> prefixes, List<ModifierSet> sortkeys) {
b.indent(level).append("<triple>\n");
renderPrefixes(b, level + 1, prefixes);
ms.toXCQLInternal(b, level + 1, "boolean", "value");
b.indent(level + 1).append("<leftOperand>\n");
Expand All @@ -78,17 +78,17 @@ void toXCQLInternal(XCQLBuilder b, int level,

@Override
public String toCQL() {
// ### We don't always need parens around the operands
return ("(" + left.toCQL() + ")" +
" " + ms.toCQL() + " " +
"(" + right.toCQL() + ")");
// ### We don't always need parens around the operands
return ("(" + left.toCQL() + ")" +
" " + ms.toCQL() + " " +
"(" + right.toCQL() + ")");
}

@Override
public String toPQF(Properties config) throws PQFTranslationException {
return ("@" + opPQF() +
" " + left.toPQF(config) +
" " + right.toPQF(config));
return ("@" + opPQF() +
" " + left.toPQF(config) +
" " + right.toPQF(config));
}

// represents the operation for PQF: overridden for CQLProxNode
Expand All @@ -97,13 +97,13 @@ public String toPQF(Properties config) throws PQFTranslationException {
@Override
public byte[] toType1BER(Properties config) throws PQFTranslationException {
System.out.println("in CQLBooleanNode.toType1BER(): PQF=" +
toPQF(config));
toPQF(config));
byte[] rpn1 = left.toType1BER(config);
byte[] rpn2 = right.toType1BER(config);
byte[] op = opType1();
byte[] rpnStructure = new byte[rpn1.length+rpn2.length+op.length+4];
// rpnRpnOp

// rpnRpnOp
int offset = putTag(CONTEXT, 1, CONSTRUCTED, rpnStructure, 0);

rpnStructure[offset++] = (byte)(0x80&0xff); // indefinite length
Expand Down
58 changes: 29 additions & 29 deletions src/main/java/org/z3950/zing/cql/CQLDefaultNodeVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@
* @author jakub
*/
public class CQLDefaultNodeVisitor implements CQLNodeVisitor {
@Override
public void onSortNode(CQLSortNode node) {
}

@Override
public void onPrefixNode(CQLPrefixNode node) {
}

@Override
public void onBooleanNodeStart(CQLBooleanNode node) {
}

@Override
public void onBooleanNodeOp(CQLBooleanNode node) {
}

@Override
public void onBooleanNodeEnd(CQLBooleanNode node) {
}
@Override
public void onTermNode(CQLTermNode node) {
}

@Override
public void onRelation(CQLRelation relation) {
}

@Override
public void onSortNode(CQLSortNode node) {
}

@Override
public void onPrefixNode(CQLPrefixNode node) {
}

@Override
public void onBooleanNodeStart(CQLBooleanNode node) {
}

@Override
public void onBooleanNodeOp(CQLBooleanNode node) {
}

@Override
public void onBooleanNodeEnd(CQLBooleanNode node) {
}

@Override
public void onTermNode(CQLTermNode node) {
}

@Override
public void onRelation(CQLRelation relation) {
}

}
Loading