01: /*
02: * LICENSE INFORMATION
03: * Copyright 2005-2007 by FZI (http://www.fzi.de).
04: * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
05: * <OWNER> = Max Völkel
06: * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
07: * <YEAR> = 2007
08: *
09: * Project information at http://semweb4j.org/rdf2go
10: */
11: package org.ontoware.rdf2go.model.impl;
12:
13: import org.ontoware.rdf2go.model.QuadPattern;
14: import org.ontoware.rdf2go.model.Statement;
15: import org.ontoware.rdf2go.model.node.NodeOrVariable;
16: import org.ontoware.rdf2go.model.node.ResourceOrVariable;
17: import org.ontoware.rdf2go.model.node.UriOrVariable;
18: import org.ontoware.rdf2go.model.node.Variable;
19:
20: /**
21: * A statement with variables
22: * @author voelkel
23: *
24: */
25: public class QuadPatternImpl extends TriplePatternImpl implements
26: QuadPattern {
27:
28: private UriOrVariable context;
29:
30: public QuadPatternImpl(UriOrVariable context,
31: ResourceOrVariable subject, UriOrVariable predicate,
32: NodeOrVariable object) {
33: super (subject, predicate, object);
34: this .context = context;
35: }
36:
37: public UriOrVariable getContext() {
38: return this .context;
39: }
40:
41: @Override
42: public boolean equals(Object o) {
43: return ((o instanceof Statement)
44: && (this .getContext().equals(((Statement) o)
45: .getContext()))
46: && (this .getSubject().equals(((Statement) o)
47: .getSubject()))
48: && (this .getPredicate().equals(((Statement) o)
49: .getPredicate())) && (this .getObject()
50: .equals(((Statement) o).getObject())));
51: }
52:
53: @Override
54: public int hashCode() {
55: return this .context.hashCode() + super .hashCode();
56: }
57:
58: @Override
59: public boolean matches(Statement statement) {
60: boolean matchesContext = statement.getContext().equals(
61: this .getContext())
62: || this .getContext() instanceof Variable;
63: return matchesContext && super.matches(statement);
64: }
65:
66: }
|