
com.weaverplatform.sp4rql.model.restriction.SingleTermRestriction Maven / Gradle / Ivy
package com.weaverplatform.sp4rql.model.restriction;
import com.weaverplatform.sp4rql.model.scope.ScopeSimple;
import com.weaverplatform.sp4rql.model.scope.Sp4rqlScope;
import com.weaverplatform.sp4rql.model.token.Sp4rqlToken;
import com.weaverplatform.sp4rql.model.token.VariableToken;
import com.weaverplatform.util.IndentStringBuilder;
import java.util.HashSet;
public class SingleTermRestriction implements Sp4rqlRestriction {
VariableToken variable;
private String alias;
private Sp4rqlScope scope;
private Sp4rqlToken graphToken;
public SingleTermRestriction(VariableToken variable) {
this.variable = variable;
}
@Override
public void setAlias(String alias) {
this.alias = alias;
}
@Override
public String getAlias() {
return alias;
}
@Override
public void setInScope(Sp4rqlScope scope) {
this.scope = scope;
this.graphToken = ((ScopeSimple) scope).getGraphSelector();
}
@Override
public Sp4rqlScope inScope() {
return scope;
}
public VariableToken getVariable() {
return variable;
}
public Sp4rqlToken getGraphToken() {
return graphToken;
}
@Override
public HashSet getExposedVariables() {
HashSet tokens = new HashSet<>();
tokens.add(variable);
if(graphToken != null && graphToken instanceof VariableToken) {
tokens.add((VariableToken) graphToken);
}
return tokens;
}
public SingleTermRestriction clone() {
SingleTermRestriction clone = new SingleTermRestriction(variable);
return clone;
}
public void buildString(IndentStringBuilder builder) {
variable.buildString(builder);
builder.append(" .");
builder.append(" # ");
builder.append(getAlias());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy