01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.query.impl;
07:
08: import org.openrdf.query.Binding;
09:
10: import org.openrdf.model.Value;
11:
12: /**
13: * An implementation of the {@link Binding} interface.
14: */
15: public class BindingImpl implements Binding {
16:
17: private String name;
18:
19: private Value value;
20:
21: /**
22: * Creates a binding object with the supplied name and value.
23: *
24: * @param name
25: * The binding's name.
26: * @param value
27: * The binding's value.
28: */
29: public BindingImpl(String name, Value value) {
30: assert name != null : "name must not be null";
31: assert value != null : "value must not be null";
32:
33: this .name = name;
34: this .value = value;
35: }
36:
37: public String getName() {
38: return name;
39: }
40:
41: public Value getValue() {
42: return value;
43: }
44:
45: @Override
46: public boolean equals(Object o) {
47: if (o instanceof Binding) {
48: Binding other = (Binding) o;
49:
50: return name.equals(other.getName())
51: && value.equals(other.getValue());
52: }
53:
54: return false;
55: }
56:
57: @Override
58: public int hashCode() {
59: return name.hashCode() ^ value.hashCode();
60: }
61:
62: @Override
63: public String toString() {
64: return name + "=" + value.toString();
65: }
66: }
|