Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ public enum QueryLanguage {

QueryLanguage(String name) { this.name = name; }

/**
* Returns the canonical name of the query language.
*
* @return the language name as a string
*/
public String getName() { return name; }

@Override
public String toString() { return name; }
}
21 changes: 0 additions & 21 deletions src/main/java/fr/inria/corese/core/next/query/api/Transformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,4 @@ Query<?> compileQuery(String queryString, QueryLanguage queryLanguage)
Update compileUpdate(String updateString, QueryLanguage queryLanguage)
throws QuerySyntaxException;

/**
* Convenience method to compile a SPARQL query.
*
* @param queryString the SPARQL query text
* @return the compiled query
* @throws QuerySyntaxException if the query string is syntactically invalid
*/
default Query<?> compileSPARQL(String queryString) throws QuerySyntaxException {
return compileQuery(queryString, QueryLanguage.SPARQL);
}

/**
* Convenience method to compile a SPARQL UPDATE.
*
* @param updateString the SPARQL UPDATE text
* @return the compiled update
* @throws QuerySyntaxException if the update string is syntactically invalid
*/
default Update compileSPARQLUpdate(String updateString) throws QuerySyntaxException {
return compileUpdate(updateString, QueryLanguage.SPARQL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,6 @@ public int getColumn() {
return column;
}

/**
* Checks whether line information is available for this syntax error.
*
* @return {@code true} if the line number is known (>= 1), {@code false} otherwise
*/
public boolean hasLineInfo() {
return line >= 1;
}

/**
* Checks whether column information is available for this syntax error.
*
* @return {@code true} if the column number is known (>= 1), {@code false} otherwise
*/
public boolean hasColumnInfo() {
return column >= 1;
}

/**
* Formats the error message to include line and column information when available.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,4 @@ public QueryValidationException(String message) {
super(message);
}

/**
* Constructs a QueryValidationException with a detail message and cause.
*
* @param message the detail message explaining why the query is invalid
* @param cause the underlying cause of the validation failure
*/
public QueryValidationException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,4 @@ public UnsupportedQueryFeatureException(String message) {
super(message);
}

/**
* Constructs an UnsupportedQueryFeatureException with a detail message and cause.
*
* @param message the detail message explaining which query feature is not supported
* @param cause the underlying cause that exposed the unsupported feature
*/
public UnsupportedQueryFeatureException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import fr.inria.corese.core.next.data.api.base.io.FileFormat;

import java.util.List;
import java.util.Locale;
import java.util.Optional;

/**
* Describes the standard SPARQL result serialization formats.
Expand Down Expand Up @@ -51,47 +49,6 @@ public ResultFormat(
super(name, extensions, mimeTypes);
}

/**
* Finds a known SPARQL result format by its name (case-insensitive).
*
* @param name The name of the format (e.g., "XML").
* @return An Optional containing the matching ResultFormat if found.
*/
public static Optional<ResultFormat> byName(String name) {
String n = name.toLowerCase(Locale.ROOT);
return all().stream()
.filter(format -> format.getName().equalsIgnoreCase(n))
.findFirst();
}

/**
* Finds a known SPARQL result format by file extension (case-insensitive).
*
* @param extension The file extension (for example, {@code "srx"}).
* @return an optional containing the matching result format
*/
public static Optional<ResultFormat> byExtension(String extension) {
String ext = extension.toLowerCase(Locale.ROOT);
return all().stream()
.filter(format -> format.getExtensions().stream()
.anyMatch(e -> e.equalsIgnoreCase(ext)))
.findFirst();
}

/**
* Finds a known SPARQL result format by MIME type (case-insensitive).
*
* @param mimeType The MIME type (for example, {@code "application/sparql-results+json"}).
* @return an optional containing the matching result format
*/
public static Optional<ResultFormat> byMimeType(String mimeType) {
String mime = mimeType.toLowerCase(Locale.ROOT);
return all().stream()
.filter(format -> format.getMimeTypes().stream()
.anyMatch(m -> m.equalsIgnoreCase(mime)))
.findFirst();
}

/**
* Returns all known SPARQL result formats.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import fr.inria.corese.core.next.query.api.TupleQuery;

import java.util.Set;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

/**
* A set of variable bindings representing a single solution in a SPARQL
Expand Down Expand Up @@ -48,19 +44,4 @@ public interface BindingSet extends Iterable<Binding> {
*/
Value getValue(String name);

/**
* Returns a sequential {@link Stream} over the bindings.
*
* @return a sequential stream over the bindings in this result
* @throws IllegalStateException if this result has been closed
*/
default Stream<Binding> stream() {
return StreamSupport.stream(
Spliterators.spliteratorUnknownSize(
iterator(),
Spliterator.ORDERED | Spliterator.NONNULL
),
false
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import java.io.Closeable;
import java.util.*;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

/**
* Represents the result of evaluating a SPARQL CONSTRUCT or DESCRIBE query.
Expand Down Expand Up @@ -55,34 +53,6 @@ public Statement next() {
};
}

/**
* Returns all remaining statements as a {@link List}.
*
* @return a list containing all remaining statements (never {@code null})
* @throws IllegalStateException if this result has been closed
*/
default List<Statement> asList() {
List<Statement> list = new ArrayList<>();
this.forEach(list::add);
return list;
}

/**
* Returns a sequential {@link Stream} over the statements in this result.
*
* @return a sequential stream over the statements in this result
* @throws IllegalStateException if this result has been closed
*/
default Stream<Statement> stream() {
return StreamSupport.stream(
Spliterators.spliteratorUnknownSize(
iterator(),
Spliterator.ORDERED | Spliterator.NONNULL
),
false
);
}

/**
* Closes this result and releases any underlying resources such as
* I/O streams, network connections, or database cursors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ public BindingSet next() {
};
}

/**
* Returns all remaining results as a {@link List}.
*
* @return a list containing all remaining binding sets (never {@code null})
* @throws IllegalStateException if this result has been closed
*/
default List<BindingSet> asList() {
List<BindingSet> list = new ArrayList<>();
this.forEach(list::add);
return list;
}

/**
* Returns a sequential {@link Stream} over the query results.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ public List<PrefixDeclarationAst> getPrefixDeclaration() {
return this.prefixDeclarations;
}

// --- Abstract query creation class ---
public abstract QueryAst getResult();

// --- Pattern creation ---

protected boolean hasCurrentGroup() {
Expand Down Expand Up @@ -738,14 +735,6 @@ public TermAst termFromGraphTerm(SparqlParser.GraphTermContext ctx) {
return this.iri(ctx.getText());
}

public TermAst termFromGraphRef(SparqlParser.GraphRefContext ctx) {
if (ctx.iriRef() != null) {
return termFromIriRef(ctx.iriRef());
} else {
throw new QueryEvaluationException("Expecting an IRIRef in the Graph clause");
}
}

public List<TermAst> termListFromObjectList(SparqlParser.ObjectListContext ctx) {
List<TermAst> out = new ArrayList<>();
for (var obj : ctx.object_()) {
Expand Down Expand Up @@ -1578,17 +1567,6 @@ public TermAst termFromAggregate(SparqlParser.AggregateContext ctx) {
throw new QueryEvaluationException("Unsupported aggregate: " + ctx.getText());
}

public GraphRefAst graphRefFromGraphOrDefault(SparqlParser.GraphOrDefaultContext ctx) {
if (ctx.DEFAULT() != null) {
return GraphRefAsts.defaultGraph();
}
if(ctx.iriRef() != null) {
IriAst graphIri = (IriAst) termFromIriRef(ctx.iriRef());
return GraphRefAsts.graph(graphIri);
}
throw new QueryEvaluationException("Unexpected value for Graph reference or default " + ctx.getText());
}

public GraphRefAst graphRefFromGraphRef(SparqlParser.GraphRefContext ctx) {
if(ctx.iriRef() != null) {
IriAst graphIri = (IriAst) termFromIriRef(ctx.iriRef());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,6 @@ public void setProjectionAll() {
this.projection = ProjectionAsts.selectAll();
}

/**
* Sets explicit SELECT variables (e.g. SELECT ?s ?p). Variable names may include ? or $ prefix.
*/
public void setProjectionVariables(List<String> variableNames) {
setProjectionVariables(variableNames, List.of());
}

/**
* Sets explicit SELECT variables where some may be introduced by {@code (expr AS ?var)}.
* Variable names may include ? or $ prefix.
Expand Down Expand Up @@ -266,17 +259,6 @@ public void setProjectionVariables(
else this.projection = newProjection;
}

/**
* Sets the projection from an existing AST.
*/
public void setProjection(ProjectionAst projection) {
ProjectionAst effectiveProjection = projection != null ? projection : ProjectionAsts.selectAll();
if (hasCurrentSelect()) {
getCurrentSelectFrame().projection = effectiveProjection;
}
else this.projection = effectiveProjection;
}

public void addValues(List<ValueMappingAst> mappings) {
this.values.addAll(mappings);
}
Expand Down Expand Up @@ -472,13 +454,6 @@ private SolutionModifierAst buildSolutionModifier(SelectFrame frame) {
frame.offset);
}

public boolean isOrdered() {
if (hasCurrentSelect()) {
return !getCurrentSelectFrame().orderConditions.isEmpty();
}
return !this.orderConditions.isEmpty();
}

/**
* Set the order condition
* @param expr either a variable or a contraint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
* In {@link #enterSelectQuery(SparqlParser.SelectQueryContext)} we:
* 1. Call {@link SparqlQueryAstBuilder#enterSelectQuery()} to set query type.
* 2. Extract the projection from the parse context (grammar: {@code (var_+ | '*')}) and call
* {@link SparqlQueryAstBuilder#setProjectionAll()} or {@link SparqlQueryAstBuilder#setProjectionVariables(List)}.
* {@link SparqlQueryAstBuilder#setProjectionAll()}.
* <p>
* The WHERE clause is built by {@link BgpAstListener} (enter/exit GroupGraphPattern, TriplesBlock, addTriple).
* At {@link SparqlAstBuilder#getResult()}, the builder produces a {@link fr.inria.corese.core.next.query.impl.sparql.ast.SelectQueryAst}
* with both {@link fr.inria.corese.core.next.query.impl.sparql.ast.ProjectionAst} and the WHERE group.
* <p>
* Grammar {@code subSelect} (nested {@code SELECT} in a group) uses the same {@link SparqlAstBuilder} stack frames as a top-level SELECT.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import fr.inria.corese.core.next.query.impl.sparql.ast.ConstructQueryAst;
import fr.inria.corese.core.next.query.impl.sparql.ast.DescribeQueryAst;
import fr.inria.corese.core.next.query.impl.sparql.ast.GroupByAst;
import fr.inria.corese.core.next.query.impl.sparql.ast.GroupGraphPatternAst;
import fr.inria.corese.core.next.query.impl.sparql.ast.QueryAst;
import fr.inria.corese.core.next.query.impl.sparql.ast.SelectQueryAst;
import fr.inria.corese.core.next.query.impl.sparql.ast.SolutionModifierAst;
Expand Down Expand Up @@ -44,10 +43,6 @@ protected final Set<String> collectVisibleVariables(QueryAst queryAst) {
return variableScopeAnalyzer.collectVisibleVariables(queryAst);
}

protected final Set<String> collectVisibleVariables(GroupGraphPatternAst whereClause) {
return variableScopeAnalyzer.collectVisibleVariables(whereClause);
}

protected final Set<String> collectReferencedVariables(TermAst term) {
return variableScopeAnalyzer.collectReferencedVariables(term);
}
Expand Down Expand Up @@ -115,10 +110,6 @@ protected QueryDiagnostic buildOutOfScopeDiagnostic(String variableName, ScopeCl
return buildOutOfScopeDiagnostic(getDiagnosticSource(), variableName, clause.label());
}

protected QueryDiagnostic buildOutOfScopeDiagnostic(String variableName, String clause) {
return buildOutOfScopeDiagnostic(getDiagnosticSource(), variableName, clause);
}

public static QueryDiagnostic buildOutOfScopeDiagnostic(String source, String variableName, String clause) {
return new QueryDiagnostic(
QueryDiagnostic.Kind.SEMANTIC_ERROR,
Expand Down
Loading
Loading