Skip to content

Commit

Permalink
Merge branch 'Spanqit-1_1'
Browse files Browse the repository at this point in the history
  • Loading branch information
anqit committed Dec 5, 2017
2 parents 1537e8d + 0695828 commit c677043
Show file tree
Hide file tree
Showing 77 changed files with 1,972 additions and 510 deletions.
23 changes: 14 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.anqit.spanqit</groupId>
<artifactId>spanqit</artifactId>
<version>1.1-SNAPSHOT</version>
<version>1.1</version>

<build>
<plugins>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!--
<verbose>true</verbose>
<fork>true</fork>
<executable>${JAVA_1_8_HOME}/bin/javac</executable>
-->
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<show>private</show>
</configuration>
</plugin>
</plugins>
Expand Down
45 changes: 43 additions & 2 deletions src/main/java/com/anqit/spanqit/constraint/Aggregate.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package com.anqit.spanqit.constraint;

import com.anqit.spanqit.core.SpanqitStringUtils;
import com.anqit.spanqit.core.SpanqitUtils;

/**
* A SPARQL aggregate expression.
*
* @see <a href="https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#aggregates">
* SPARQL Aggregates</a>
*/
public class Aggregate extends Expression<Aggregate> {
private static final String DISTINCT = "DISTINCT";
private static final Object SEPARATOR = "SEPARATOR";
Expand All @@ -14,26 +20,61 @@ public class Aggregate extends Expression<Aggregate> {
super(aggregate);
}

/**
* Specify this aggregate expression to be distinct
*
* @return this aggregate instance
*/
public Aggregate distinct() {
return distinct(true);
}

/**
* Specify if this aggregate expression should be distinct or not
*
* @param isDistinct
* if this aggregate should be distinct
*
* @return this aggregate instance
*/
public Aggregate distinct(boolean isDistinct) {
this.isDistinct = isDistinct;

return this;
}

/**
* If this is a {@code count} aggregate expressions, specify that it should count all
*
* @return this aggregate instance
*/
public Aggregate countAll() {
return countAll(true);
}

/**
* If this is a {@code count} aggregate expressions, specify if it should count all
*
* @param countAll if this should count all arguments or not
*
* @return this aggregate instance
*/
public Aggregate countAll(boolean countAll) {
this.countAll = countAll;

return this;
}

/**
* If this is a {@code group_concat} aggregate expression, specify the separator to use
*
* @param separator the separator to use
*
* @return this aggregate instance
*
* @see <a href="https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#defn_aggGroupConcat">
* group_concat()</a>
*/
public Aggregate separator(String separator) {
this.separator = separator;

Expand Down Expand Up @@ -64,6 +105,6 @@ public String getQueryString() {
.append(" ").append("=").append(" ").append(separator);
}

return aggregate.append(SpanqitStringUtils.getParenthesizedString(params.toString())).toString();
return aggregate.append(SpanqitUtils.getParenthesizedString(params.toString())).toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/**
* Represents a SPARQL operation that takes exactly 2 arguments
*
* @author Ankit
*/
class BinaryOperation extends Operation<BinaryOperation> {
BinaryOperation(BinaryOperator operator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

/**
* The SPARQL binary operators
*
* @author Ankit
*
*/
enum BinaryOperator implements SparqlOperator {
EQUALS("="),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

/**
* The SPARQL connective operators
*
* @author Ankit
*
*/
enum ConnectiveOperator implements SparqlOperator {
// Logical
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/anqit/spanqit/constraint/Expression.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.anqit.spanqit.core.Groupable;
import com.anqit.spanqit.core.Orderable;
import com.anqit.spanqit.core.QueryElementCollection;
import com.anqit.spanqit.core.SpanqitStringUtils;
import com.anqit.spanqit.core.SpanqitUtils;

/**
* A SPARQL expression. Used by filters, having clauses, order and group by
Expand Down Expand Up @@ -36,7 +36,7 @@
* SPARQL Assignments</a>
*/
public abstract class Expression<T extends Expression<T>> extends
QueryElementCollection<ExpressionOperand> implements ExpressionOperand,
QueryElementCollection<Operand> implements Operand,
Orderable, Groupable, Assignable {
protected SparqlOperator operator;
private boolean parenthesize;
Expand All @@ -46,14 +46,14 @@ public abstract class Expression<T extends Expression<T>> extends
}

Expression(SparqlOperator operator, String delimeter) {
super(delimeter, new ArrayList<ExpressionOperand>());
super(delimeter, new ArrayList<Operand>());
this.operator = operator;
parenthesize(false);
}

@SuppressWarnings("unchecked")
T addOperand(ExpressionOperand... operands) {
for (ExpressionOperand operand : operands) {
T addOperand(Operand... operands) {
for (Operand operand : operands) {
elements.add(operand);
}

Expand Down Expand Up @@ -84,14 +84,14 @@ public T parenthesize(boolean parenthesize) {
return (T) this;
}

ExpressionOperand getOperand(int index) {
return ((ArrayList<ExpressionOperand>) elements).get(index);
Operand getOperand(int index) {
return ((ArrayList<Operand>) elements).get(index);
}

@Override
public String getQueryString() {
String queryString = super.getQueryString();

return parenthesize ? SpanqitStringUtils.getParenthesizedString(queryString) : queryString;
return parenthesize ? SpanqitUtils.getParenthesizedString(queryString) : queryString;
}
}
Loading

0 comments on commit c677043

Please sign in to comment.