Format
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
index a11a7cd..0433b2f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
@@ -46,17 +46,16 @@
* */
public class SpanRelationQuery extends SpanWithIdQuery {
- private String type;
+ private String type;
- /**
- * Constructs a SpanRelationQuery based on the given span query.
- *
- * @param firstClause
- * a SpanQuery.
- * @param collectPayloads
- * a boolean flag representing the value <code>true</code> if
- * payloads are to be collected, otherwise <code>false</code>.
- */
+ /**
+ * Constructs a SpanRelationQuery based on the given span query.
+ *
+ * @param firstClause a SpanQuery.
+ * @param collectPayloads
+ * a boolean flag representing the value <code>true</code> if
+ * payloads are to be collected, otherwise <code>false</code>.
+ */
public SpanRelationQuery(SpanQuery firstClause, boolean collectPayloads) {
super(firstClause, collectPayloads);
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
index d4d66eb..4d5c011 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
@@ -18,9 +18,10 @@
import de.ids_mannheim.korap.query.spans.TermSpansWithId;
/**
- * Enumeration of spans (e.g. element or relation spans) having some specific
- * attribute(s) or <em>not</em> having some attribute(s). It is necessary that
- * the spans have ids to be able to identify to which span an attribute belongs. <br />
+ * Enumeration of spans (e.g. element or relation spans) having some
+ * specific attribute(s) or <em>not</em> having some attribute(s). It
+ * is necessary that the spans have ids to be able to identify to
+ * which span an attribute belongs. <br />
* <br />
*
* In the example below, the SpanWithAttributeQuery retrieves
@@ -39,59 +40,69 @@
*/
public class SpanWithAttributeQuery extends SpanWithIdQuery {
- public boolean isMultipleAttributes;
+ public boolean isMultipleAttributes;
private String type;
- /**
- * Constructs a SpanWithAttributeQuery for any arbitrary SpansWithId (e.g.
- * elements, relations) having the specified {@link SpanAttributeQuery}.
- *
- * @param attributeQuery a SpanAttributeQuery
- * @param collectPayloads a boolean flag representing the value
- * <code>true</code> if payloads are to be collected, otherwise
- * <code>false</code>.
- */
- public SpanWithAttributeQuery(SpanAttributeQuery attributeQuery,
- boolean collectPayloads) {
- super(attributeQuery, collectPayloads);
- type = "spanWithAttribute";
- }
+ /**
+ * Constructs a SpanWithAttributeQuery for any arbitrary
+ * SpansWithId (e.g. elements, relations) having the specified
+ * {@link SpanAttributeQuery}.
+ *
+ * @param attributeQuery
+ * a SpanAttributeQuery
+ * @param collectPayloads
+ * a boolean flag representing the value
+ * <code>true</code> if payloads are to be collected,
+ * otherwise <code>false</code>.
+ */
+ public SpanWithAttributeQuery (SpanAttributeQuery attributeQuery,
+ boolean collectPayloads) {
+ super(attributeQuery, collectPayloads);
+ type = "spanWithAttribute";
+ }
- public SpanWithAttributeQuery(List<SpanQuery> attributeQueries,
- boolean collectPayloads) {
- super(attributeQueries, collectPayloads);
- isMultipleAttributes = true;
- type = "spanWithAttribute";
- }
+ public SpanWithAttributeQuery (List<SpanQuery> attributeQueries,
+ boolean collectPayloads) {
+ super(attributeQueries, collectPayloads);
+ isMultipleAttributes = true;
+ type = "spanWithAttribute";
+ }
/**
- * Constructs a SpanWithAttributeQuery for the specified SpanWithIdQuery and
- * SpanAttributeQuery retrieving spans having a specific attribute.
+ * Constructs a SpanWithAttributeQuery for the specified
+ * SpanWithIdQuery and SpanAttributeQuery retrieving spans having
+ * a specific attribute.
*
- * If the SpanWithIdQuery is a SpanAttributeQuery, this will return arbitrary
- * elements with two specified attributes (i.e. and relation between the two
- * attributes).
+ * If the SpanWithIdQuery is a SpanAttributeQuery, this will
+ * return arbitrary elements with two specified attributes (i.e.
+ * and relation between the two attributes).
*
- * @param firstClause a SpanWithIdQuery
- * @param secondClause a SpanAttributeQuery
- * @param collectPayloads a boolean flag representing the value
- * <code>true</code> if payloads are to be collected, otherwise
- * <code>false</code>.
+ * @param firstClause
+ * a SpanWithIdQuery
+ * @param secondClause
+ * a SpanAttributeQuery
+ * @param collectPayloads
+ * a boolean flag representing the value
+ * <code>true</code> if payloads are to be collected,
+ * otherwise <code>false</code>.
*/
- public SpanWithAttributeQuery(SpanWithIdQuery firstClause,
+ public SpanWithAttributeQuery (SpanWithIdQuery firstClause,
SpanAttributeQuery secondClause, boolean collectPayloads) {
super(firstClause, secondClause, collectPayloads);
setType();
}
/**
- * @param firstClause a SpanWithIdQuery
- * @param secondClauses a list of SpanAttributeQueries
- * @param collectPayloads a boolean flag representing the value
- * <code>true</code> if payloads are to be collected, otherwise
- * <code>false</code>.
+ * @param firstClause
+ * a SpanWithIdQuery
+ * @param secondClauses
+ * a list of SpanAttributeQueries
+ * @param collectPayloads
+ * a boolean flag representing the value
+ * <code>true</code> if payloads are to be collected,
+ * otherwise <code>false</code>.
*/
- public SpanWithAttributeQuery(SpanWithIdQuery firstClause,
+ public SpanWithAttributeQuery (SpanWithIdQuery firstClause,
List<SpanQuery> secondClauses, boolean collectPayloads) {
super(firstClause, secondClauses, collectPayloads);
isMultipleAttributes = true;
@@ -108,104 +119,106 @@
}
/**
- * Sets the type of the query based of the class of the firstClause / first
- * span.
+ * Sets the type of the query based of the class of the
+ * firstClause / first span.
*
*/
public void setType() {
if (SpanElementQuery.class.isInstance(firstClause)) {
type = "spanElementWithAttribute";
- } else if (SpanRelationQuery.class.isInstance(firstClause)) {
+ }
+ else if (SpanRelationQuery.class.isInstance(firstClause)) {
type = "spanRelationWithAttribute";
- } else if (SpanTermWithIdQuery.class.isInstance(firstClause)) {
+ }
+ else if (SpanTermWithIdQuery.class.isInstance(firstClause)) {
type = "spanTermWithAttribute";
}
}
@Override
public SimpleSpanQuery clone() {
- if (secondClause != null) {
- if (isMultipleAttributes) {
- return new SpanWithAttributeQuery(
- (SpanWithIdQuery) firstClause.clone(), cloneClauseList(),
- collectPayloads);
- }
- else {
- return new SpanWithAttributeQuery(
- (SpanWithIdQuery) firstClause.clone(),
- (SpanAttributeQuery) secondClause.clone(),
- collectPayloads);
+ if (secondClause != null) {
+ if (isMultipleAttributes) {
+ return new SpanWithAttributeQuery(
+ (SpanWithIdQuery) firstClause.clone(),
+ cloneClauseList(), collectPayloads);
+ }
+ else {
+ return new SpanWithAttributeQuery(
+ (SpanWithIdQuery) firstClause.clone(),
+ (SpanAttributeQuery) secondClause.clone(),
+ collectPayloads);
}
}
else {
- if (isMultipleAttributes) {
- return new SpanWithAttributeQuery(cloneClauseList(),
- collectPayloads);
- }
- else {
- return new SpanWithAttributeQuery(
- (SpanAttributeQuery) firstClause.clone(),
- collectPayloads);
- }
- }
+ if (isMultipleAttributes) {
+ return new SpanWithAttributeQuery(cloneClauseList(),
+ collectPayloads);
+ }
+ else {
+ return new SpanWithAttributeQuery(
+ (SpanAttributeQuery) firstClause.clone(),
+ collectPayloads);
+ }
+ }
}
- private List<SpanQuery> cloneClauseList() {
- List<SpanQuery> clauseList = new ArrayList<SpanQuery>();
- SpanAttributeQuery saq;
- for (SpanQuery q : this.clauseList) {
- saq = (SpanAttributeQuery) q;
- clauseList.add(saq.clone());
- }
- return clauseList;
- }
+ private List<SpanQuery> cloneClauseList() {
+ List<SpanQuery> clauseList = new ArrayList<SpanQuery>();
+ SpanAttributeQuery saq;
+ for (SpanQuery q : this.clauseList) {
+ saq = (SpanAttributeQuery) q;
+ clauseList.add(saq.clone());
+ }
+ return clauseList;
+ }
@Override
public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
Map<Term, TermContext> termContexts) throws IOException {
- if (type.equals("spanWithAttribute")) {
- return new SpansWithAttribute(this, context, acceptDocs,
- termContexts);
- }
+ if (type.equals("spanWithAttribute")) {
+ return new SpansWithAttribute(this, context, acceptDocs,
+ termContexts);
+ }
Spans spans = this.getFirstClause().getSpans(context, acceptDocs,
termContexts);
- if (type.equals("spanElementWithAttribute")) {
+ if (type.equals("spanElementWithAttribute")) {
return new SpansWithAttribute(this, (ElementSpans) spans, context,
acceptDocs, termContexts);
- }
+ }
else if (type.equals("spanRelationWithAttribute")) {
return new SpansWithAttribute(this, (RelationSpans) spans, context,
acceptDocs, termContexts);
}
- else if (type.equals("spanTermWithAttribute")){
- return new SpansWithAttribute(this, (TermSpansWithId) spans, context,
- acceptDocs, termContexts);
+ else if (type.equals("spanTermWithAttribute")) {
+ return new SpansWithAttribute(this, (TermSpansWithId) spans,
+ context, acceptDocs, termContexts);
}
else {
- throw new IllegalArgumentException("Span query type: " + type
- + "is unknown.");
- }
+ throw new IllegalArgumentException("Span query type: " + type
+ + "is unknown.");
+ }
}
@Override
public String toString(String field) {
- boolean isFirstClassNull = true;
+ boolean isFirstClassNull = true;
StringBuilder sb = new StringBuilder();
sb.append(type);
sb.append("(");
- if (firstClause != null) {
- sb.append(firstClause.toString(field));
- isFirstClassNull = false;
- }
- if (secondClause !=null){
- sb.append(", ");
+ if (firstClause != null) {
+ sb.append(firstClause.toString(field));
+ isFirstClassNull = false;
+ }
+ if (secondClause != null) {
+ sb.append(", ");
sb.append(secondClause.toString(field));
}
- else if (isMultipleAttributes) {
- if (!isFirstClassNull) sb.append(", ");
+ else if (isMultipleAttributes) {
+ if (!isFirstClassNull) sb.append(", ");
sb.append("[");
SpanQuery sq;
@@ -213,13 +226,12 @@
sq = clauseList.get(i);
sb.append(sq.toString(field));
- if (i < clauseList.size() - 1)
- sb.append(", ");
+ if (i < clauseList.size() - 1) sb.append(", ");
}
sb.append("]");
- }
- sb.append(")");
+ }
+ sb.append(")");
return sb.toString();
}
}