Skip to content

Commit

Permalink
Use lambdas in lang/ParserSPARQL_N
Browse files Browse the repository at this point in the history
  • Loading branch information
afs committed Feb 3, 2024
1 parent 07c86d8 commit 5395541
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,27 @@ private interface Action { void exec(SPARQLParser10 parser) throws Exception ; }
protected Query parse$(final Query query, String queryString) {
query.setSyntax(Syntax.syntaxSPARQL_10);

Action action = new Action() {
@Override
public void exec(SPARQLParser10 parser) throws Exception {
parser.QueryUnit();
}
};

Action action = (SPARQLParser10 parser) ->
parser.QueryUnit();
perform(query, queryString, action);
return query;
}

public static Element parseElement(String string) {
final Query query = new Query();
Action action = new Action() {
@Override
public void exec(SPARQLParser10 parser) throws Exception {
Element el = parser.GroupGraphPattern();
query.setQueryPattern(el);
}
Action action = (SPARQLParser10 parser) ->{
Element el = parser.GroupGraphPattern();
query.setQueryPattern(el);
};
perform(query, string, action);
return query.getQueryPattern();
}

public static Template parseTemplate(String string) {
final Query query = new Query();
Action action = new Action() {
@Override
public void exec(SPARQLParser10 parser) throws Exception {
Template t = parser.ConstructTemplate();
query.setConstructTemplate(t);
}
Action action = (SPARQLParser10 parser) ->{
Template t = parser.ConstructTemplate();
query.setConstructTemplate(t);
};
perform(query, string, action);
return query.getConstructTemplate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,26 @@ private interface Action { void exec(SPARQLParser11 parser) throws Exception ; }
protected Query parse$(final Query query, String queryString) {
query.setSyntax(Syntax.syntaxSPARQL_11);

Action action = new Action() {
@Override
public void exec(SPARQLParser11 parser) throws Exception {
parser.QueryUnit();
}
};

Action action = (SPARQLParser11 parser) -> parser.QueryUnit();
perform(query, queryString, action);
return query;
}

public static Element parseElement(String string) {
final Query query = new Query();
Action action = new Action() {
@Override
public void exec(SPARQLParser11 parser) throws Exception {
Element el = parser.GroupGraphPattern();
query.setQueryPattern(el);
}
Action action = (SPARQLParser11 parser) -> {
Element el = parser.GroupGraphPattern();
query.setQueryPattern(el);
};
perform(query, string, action);
return query.getQueryPattern();
}

public static Template parseTemplate(String string) {
final Query query = new Query();
Action action = new Action() {
@Override
public void exec(SPARQLParser11 parser) throws Exception {
Template t = parser.ConstructTemplate();
query.setConstructTemplate(t);
}
Action action = (SPARQLParser11 parser) -> {
Template t = parser.ConstructTemplate();
query.setConstructTemplate(t);
};
perform(query, string, action);
return query.getConstructTemplate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,26 @@ private interface Action { void exec(SPARQLParser12 parser) throws Exception ; }
@Override
protected Query parse$(final Query query, String queryString) {
query.setSyntax(Syntax.syntaxSPARQL_12);

Action action = new Action() {
@Override
public void exec(SPARQLParser12 parser) throws Exception {
parser.QueryUnit();
}
};

Action action = (SPARQLParser12 parser) -> parser.QueryUnit();
perform(query, queryString, action);
return query;
}

public static Element parseElement(String string) {
final Query query = new Query();
Action action = new Action() {
@Override
public void exec(SPARQLParser12 parser) throws Exception {
Element el = parser.GroupGraphPattern();
query.setQueryPattern(el);
}
Action action = (SPARQLParser12 parser) -> {
Element el = parser.GroupGraphPattern();
query.setQueryPattern(el);
};
perform(query, string, action);
return query.getQueryPattern();
}

public static Template parseTemplate(String string) {
final Query query = new Query();
Action action = new Action() {
@Override
public void exec(SPARQLParser12 parser) throws Exception {
Template t = parser.ConstructTemplate();
query.setConstructTemplate(t);
}
Action action = (SPARQLParser12 parser) -> {
Template t = parser.ConstructTemplate();
query.setConstructTemplate(t);
};
perform(query, string, action);
return query.getConstructTemplate();
Expand Down

0 comments on commit 5395541

Please sign in to comment.