QueryResult match = new QueryResult();
if(pattern.getSubject().isResourceField()) {
result = ((ResourceField)pattern.getSubject()).getResource().equals(triple.getSubject());
} else if(pattern.getSubject().isVariableField()) {
KiWiNode binding = match.getBindings().get(pattern.getSubject());
if(binding != null) {
result = binding.equals(triple.getSubject());
} else {
match.getBindings().put((VariableField) pattern.getSubject(), triple.getSubject());
}
}
if(result && pattern.getProperty().isResourceField()) {
result = ((ResourceField)pattern.getProperty()).getResource().equals(triple.getPredicate());
} else if(result && pattern.getProperty().isVariableField()) {
KiWiNode binding = match.getBindings().get(pattern.getProperty());
if(binding != null) {
result = binding.equals(triple.getPredicate());
} else {
match.getBindings().put((VariableField) pattern.getProperty(), triple.getPredicate());
}
}
if(result && pattern.getContext() != null && pattern.getContext().isResourceField()) {
result = ((ResourceField)pattern.getContext()).getResource().equals(triple.getContext());
} else if(result && pattern.getContext() != null && pattern.getContext().isVariableField()) {
KiWiNode binding = match.getBindings().get(pattern.getContext());
if(binding != null) {
result = binding.equals(triple.getContext());
} else {
match.getBindings().put((VariableField) pattern.getContext(), triple.getContext());
}
}
if(result && pattern.getObject().isResourceField()) {
result = ((ResourceField)pattern.getObject()).getResource().equals(triple.getObject());
} else if(result && pattern.getObject().isLiteralField()) {
result = ((LiteralField)pattern.getObject()).getLiteral().equals(triple.getObject());
} else if(result && pattern.getObject().isVariableField()) {
KiWiNode binding = match.getBindings().get(pattern.getObject());
if(binding != null) {
result = binding.equals(triple.getObject());
} else {
match.getBindings().put((VariableField) pattern.getObject(), triple.getObject());
}
}