Added javadoc comments
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java
index 150f060..bf7ce85 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java
@@ -13,61 +13,118 @@
import de.ids_mannheim.korap.query.spans.AttributeSpans;
-/** Span enumerations of attributes (i.e. spans with prefix @, for example
- * @:class=header) commonly used to search elements with some specific
- * attribute(s). Negation allows for searching element <em>without</em> some
- * attribute(s).
+/**
+ * SpanAttributeQuery retrieves attribute spans, that are tokens annotated with
+ * prefix @, for example {@literal @}:class=header. SpanAttributeQueries are
+ * commonly used to search for elements or relations having some specific
+ * attribute(s).
*
- * @author margaretha
+ * Example: <br/>
+ * <br/>
+ *
+ * <pre>
+ * SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(new Term(
+ * "base", "@:class=title")), true);
+ * </pre>
+ *
+ * Negation enables searching for elements <em>without</em> some attribute(s).
+ * Example:
+ *
+ * <pre>
+ * SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(new Term(
+ * "base", "@:class=title")), true, true);
+ * </pre>
+ *
+ * @author margaretha
* */
-public class SpanAttributeQuery extends SimpleSpanQuery{
-
- boolean isNegation;
-
- public SpanAttributeQuery(SpanTermQuery firstClause, boolean collectPayloads) {
- super(firstClause, collectPayloads);
- }
-
- public SpanAttributeQuery(SpanTermQuery firstClause, boolean isNegation,
- boolean collectPayloads) {
- super(firstClause, collectPayloads);
- this.isNegation = isNegation;
- }
+public class SpanAttributeQuery extends SimpleSpanQuery {
- @Override
- public SimpleSpanQuery clone() {
- SpanAttributeQuery sq = new SpanAttributeQuery(
- (SpanTermQuery) this.firstClause.clone(),
- this.isNegation,
- this.collectPayloads);
- sq.setBoost(getBoost());
- return sq;
- }
+ boolean negation;
- @Override
- public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
- Map<Term, TermContext> termContexts) throws IOException {
- return new AttributeSpans(this, context, acceptDocs, termContexts);
- }
+ /**
+ * Constructs a SpanAttributeQuery based on the specified
+ * {@link SpanTermQuery} and set whether payloads are to be collected or
+ * not.
+ *
+ * @param firstClause a {@link SpanTermQuery}
+ * @param collectPayloads a boolean flag representing the value
+ * <code>true</code> if payloads are to be collected, otherwise
+ * <code>false</code>.
+ */
+ public SpanAttributeQuery(SpanTermQuery firstClause, boolean collectPayloads) {
+ super(firstClause, collectPayloads);
+ }
- @Override
- public String toString(String field) {
- StringBuilder sb = new StringBuilder();
- sb.append("spanAttribute(");
- sb.append(firstClause.toString(field));
- if (isNegation)
- sb.append( ", not");
- sb.append(")");
- sb.append(ToStringUtils.boost(getBoost()));
- return sb.toString();
- }
+ /**
+ * Constructs a SpanAttributeQuery based on the specified
+ * {@link SpanTermQuery}, which is also marked for negation/omission when
+ * matching to element/relation spans. Additionally set whether payloads are
+ * to be collected or not.
+ *
+ * @param firstClause a {@link SpanQuery}
+ * @param negation a boolean flag representing the value <code>true</code>
+ * if the attributes are to be omitted when matching with element or
+ * relation spans, otherwise <code>false</code>.
+ * @param collectPayloads a boolean flag representing the value
+ * <code>true</code> if payloads are to be collected, otherwise
+ * <code>false</code>.
+ */
+ public SpanAttributeQuery(SpanTermQuery firstClause, boolean negation,
+ boolean collectPayloads) {
+ super(firstClause, collectPayloads);
+ this.negation = negation;
+ }
- public boolean isNegation() {
- return isNegation;
- }
+ /** {@inheritDoc} */
+ @Override
+ public SimpleSpanQuery clone() {
+ SpanAttributeQuery sq = new SpanAttributeQuery(
+ (SpanTermQuery) this.firstClause.clone(), this.negation,
+ this.collectPayloads);
+ sq.setBoost(getBoost());
+ return sq;
+ }
- public void setNegation(boolean isNegation) {
- this.isNegation = isNegation;
- }
+ @Override
+ public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+ Map<Term, TermContext> termContexts) throws IOException {
+ return new AttributeSpans(this, context, acceptDocs, termContexts);
+ }
+
+ @Override
+ public String toString(String field) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("spanAttribute(");
+ sb.append(firstClause.toString(field));
+ if (negation)
+ sb.append(", not");
+ sb.append(")");
+ sb.append(ToStringUtils.boost(getBoost()));
+ return sb.toString();
+ }
+
+ /**
+ * Tells weather the attributes are to be omitted when matching to element
+ * or relation spans, or not.
+ *
+ * @return <code>true</code> if the attributes are to be omitted when
+ * matching to element or relation spans, <code>false</code>
+ * otherwise.
+ */
+ public boolean isNegation() {
+ return negation;
+ }
+
+ /**
+ * Sets true if the attributes are to be omitted when matching to element or
+ * relation spans, false otherwise.
+ *
+ * @param negation a boolean with value <code>true</code>, if the attributes
+ * are to be omitted when matching to element or relation spans,
+ * <code>false</code> otherwise.
+ */
+ public void setNegation(boolean negation) {
+ this.negation = negation;
+ }
}