01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.model.impl;
07:
08: import org.openrdf.model.Resource;
09: import org.openrdf.model.URI;
10: import org.openrdf.model.Value;
11:
12: /**
13: * An extension of {@link StatementImpl} that adds a context field.
14: */
15: public class ContextStatementImpl extends StatementImpl {
16:
17: /*-----------*
18: * Constants *
19: *-----------*/
20:
21: private static final long serialVersionUID = -4747275587477906748L;
22:
23: /**
24: * The statement's context, if applicable.
25: */
26: private final Resource context;
27:
28: /*--------------*
29: * Constructors *
30: *--------------*/
31:
32: /**
33: * Creates a new Statement with the supplied subject, predicate and object
34: * for the specified associated context.
35: *
36: * @param subject
37: * The statement's subject, must not be <tt>null</tt>.
38: * @param predicate
39: * The statement's predicate, must not be <tt>null</tt>.
40: * @param object
41: * The statement's object, must not be <tt>null</tt>.
42: * @param context
43: * The statement's context, <tt>null</tt> to indicate no context is
44: * associated.
45: */
46: public ContextStatementImpl(Resource subject, URI predicate,
47: Value object, Resource context) {
48: super (subject, predicate, object);
49: this .context = context;
50: }
51:
52: /*---------*
53: * Methods *
54: *---------*/
55:
56: @Override
57: public Resource getContext() {
58: return context;
59: }
60:
61: @Override
62: public String toString() {
63: StringBuilder sb = new StringBuilder(256);
64:
65: sb.append(super .toString());
66: sb.append(" [").append(getContext()).append("]");
67:
68: return sb.toString();
69: }
70: }
|