001: /*
002: * LICENSE INFORMATION
003: * Copyright 2005-2007 by FZI (http://www.fzi.de).
004: * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
005: * <OWNER> = Max Völkel
006: * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
007: * <YEAR> = 2007
008: *
009: * Project information at http://semweb4j.org/rdf2go
010: */
011: package org.ontoware.rdf2go.model.impl;
012:
013: import org.ontoware.rdf2go.model.Statement;
014: import org.ontoware.rdf2go.model.node.Node;
015: import org.ontoware.rdf2go.model.node.Resource;
016: import org.ontoware.rdf2go.model.node.URI;
017:
018: /**
019: * StatementImpl is an implementation of Statement, so there are all necessary
020: * constructors, and methods for getting the type and the parts of the statement
021: *
022: * @author mvo
023: */
024:
025: public class StatementImpl extends AbstractStatement implements
026: Statement {
027:
028: protected Resource subject;
029:
030: protected URI predicate;
031:
032: private Node object;
033:
034: private URI context;
035:
036: /**
037: * builds a new statement
038: *
039: * @param subject
040: * The subject of this statement
041: * @param predicate
042: * The proerty of this statement
043: * @param object
044: * The object of this statement
045: */
046: public StatementImpl(URI context, Resource subject, URI predicate,
047: Node object) {
048: this .context = context;
049: this .subject = subject;
050: this .predicate = predicate;
051: this .object = object;
052: }
053:
054: /*
055: * (non-Javadoc)
056: *
057: * @see org.ontoware.rdf2go.Statement#getSubject()
058: */
059: public Resource getSubject() {
060: return this .subject;
061: }
062:
063: /*
064: * (non-Javadoc)
065: *
066: * @see org.ontoware.rdf2go.Statement#getPredicate()
067: */
068: public URI getPredicate() {
069: return this .predicate;
070: }
071:
072: /*
073: * (non-Javadoc)
074: *
075: * @see org.ontoware.rdf2go.Statement#getObject()
076: */
077: public Node getObject() {
078: return this .object;
079: }
080:
081: @Override
082: public String toString() {
083: return getSubject() + " - " + getPredicate() + " - "
084: + getObject();
085: }
086:
087: public URI getContext() {
088: return this .context;
089: }
090:
091: @Override
092: public int hashCode() {
093: return this .subject.hashCode() + this .predicate.hashCode()
094: + this .object.hashCode();
095: }
096:
097: @Override
098: public boolean equals(Object other) {
099: if (other instanceof Statement) {
100: Statement o = (Statement) other;
101: return this .getSubject().equals(o.getSubject())
102: && this .getPredicate().equals(o.getPredicate())
103: && this .getObject().equals(o.getObject());
104: }
105: return false;
106: }
107:
108: }
|