use of org.qi4j.api.query.grammar.ComparisonSpecification in project qi4j-sdk by Qi4j.
the class RdfQueryParserImpl method processFilter.
private void processFilter(final Specification<Composite> expression, boolean allowInline, StringBuilder builder) {
if (expression == null) {
return;
}
if (expression instanceof AndSpecification) {
final AndSpecification conjunction = (AndSpecification) expression;
int start = builder.length();
boolean first = true;
for (Specification<Composite> operand : conjunction.operands()) {
int size = builder.length();
processFilter(operand, allowInline, builder);
if (builder.length() > size) {
if (first) {
first = false;
} else {
builder.insert(size, " && ");
}
}
}
if (builder.length() > start) {
builder.insert(start, '(');
builder.append(')');
}
} else if (expression instanceof OrSpecification) {
final OrSpecification disjunction = (OrSpecification) expression;
int start = builder.length();
boolean first = true;
for (Specification<Composite> operand : disjunction.operands()) {
int size = builder.length();
processFilter(operand, false, builder);
if (builder.length() > size) {
if (first) {
first = false;
} else {
builder.insert(size, "||");
}
}
}
if (builder.length() > start) {
builder.insert(start, '(');
builder.append(')');
}
} else if (expression instanceof NotSpecification) {
builder.insert(0, "(!");
processFilter(((NotSpecification) expression).operand(), false, builder);
builder.append(")");
} else if (expression instanceof ComparisonSpecification) {
processComparisonPredicate(expression, allowInline, builder);
} else if (expression instanceof ContainsAllSpecification) {
processContainsAllPredicate((ContainsAllSpecification) expression, builder);
} else if (expression instanceof ContainsSpecification<?>) {
processContainsPredicate((ContainsSpecification<?>) expression, builder);
} else if (expression instanceof MatchesSpecification) {
processMatchesPredicate((MatchesSpecification) expression, builder);
} else if (expression instanceof PropertyNotNullSpecification<?>) {
processNotNullPredicate((PropertyNotNullSpecification) expression, builder);
} else if (expression instanceof PropertyNullSpecification<?>) {
processNullPredicate((PropertyNullSpecification) expression, builder);
} else if (expression instanceof AssociationNotNullSpecification<?>) {
processNotNullPredicate((AssociationNotNullSpecification) expression, builder);
} else if (expression instanceof AssociationNullSpecification<?>) {
processNullPredicate((AssociationNullSpecification) expression, builder);
} else if (expression instanceof ManyAssociationContainsSpecification<?>) {
processManyAssociationContainsPredicate((ManyAssociationContainsSpecification) expression, allowInline, builder);
} else {
throw new UnsupportedOperationException("Expression " + expression + " is not supported");
}
}
use of org.qi4j.api.query.grammar.ComparisonSpecification in project qi4j-sdk by Qi4j.
the class RdfQueryParserImpl2 method processFilter.
private void processFilter(final Specification<Composite> expression, boolean allowInline, StringBuilder builder) {
if (expression == null) {
return;
}
if (expression instanceof AndSpecification) {
final AndSpecification conjunction = (AndSpecification) expression;
int start = builder.length();
boolean first = true;
for (Specification<Composite> operand : conjunction.operands()) {
int size = builder.length();
processFilter(operand, allowInline, builder);
if (builder.length() > size) {
if (first) {
first = false;
} else {
builder.insert(size, " && ");
}
}
}
if (builder.length() > start) {
builder.insert(start, '(');
builder.append(')');
}
} else if (expression instanceof OrSpecification) {
final OrSpecification disjunction = (OrSpecification) expression;
int start = builder.length();
boolean first = true;
for (Specification<Composite> operand : disjunction.operands()) {
int size = builder.length();
processFilter(operand, false, builder);
if (builder.length() > size) {
if (first) {
first = false;
} else {
builder.insert(size, "||");
}
}
}
if (builder.length() > start) {
builder.insert(start, '(');
builder.append(')');
}
} else if (expression instanceof NotSpecification) {
builder.insert(0, "(!");
processFilter(((NotSpecification) expression).operand(), false, builder);
builder.append(")");
} else if (expression instanceof ComparisonSpecification) {
processComparisonPredicate(expression, allowInline, builder);
} else if (expression instanceof ContainsAllSpecification) {
processContainsAllPredicate((ContainsAllSpecification) expression, builder);
} else if (expression instanceof ContainsSpecification<?>) {
processContainsPredicate((ContainsSpecification<?>) expression, builder);
} else if (expression instanceof MatchesSpecification) {
processMatchesPredicate((MatchesSpecification) expression, builder);
} else if (expression instanceof PropertyNotNullSpecification<?>) {
processNotNullPredicate((PropertyNotNullSpecification) expression, builder);
} else if (expression instanceof PropertyNullSpecification<?>) {
processNullPredicate((PropertyNullSpecification) expression, builder);
} else if (expression instanceof AssociationNotNullSpecification<?>) {
processNotNullPredicate((AssociationNotNullSpecification) expression, builder);
} else if (expression instanceof AssociationNullSpecification<?>) {
processNullPredicate((AssociationNullSpecification) expression, builder);
} else if (expression instanceof ManyAssociationContainsSpecification<?>) {
processManyAssociationContainsPredicate((ManyAssociationContainsSpecification) expression, allowInline, builder);
} else {
throw new UnsupportedOperationException("Expression " + expression + " is not supported");
}
}
Aggregations