01: /*
02: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: * All rights reserved.
04: * [See end of file]
05: */
06:
07: //=======================================================================
08: // Package
09: package com.hp.hpl.jena.db.impl;
10:
11: //=======================================================================
12: // Imports
13:
14: //=======================================================================
15: /**
16: * Interface for database identifiers.
17: * Most RDF entities (resources, literals, statements) have an associated
18: * database index. These are cached using RDB-specific variants of the jena
19: * "impl" classes. This can avoid some redundant database lookup.
20: * <p>
21: * This variant just uses integers allocated by the database driver as indices.
22: * This would be sufficient for databases up to 4x10^9 statements.
23: *
24: * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
25: * @version $Revision: 1.7 $ on $Date: 2008/01/02 12:08:24 $
26: */
27:
28: public class DBIDInt implements IDBID {
29:
30: /** The index */
31: protected Integer m_dbid;
32:
33: /** constructor */
34: public DBIDInt(int id) {
35: m_dbid = new Integer(id);
36: }
37:
38: /** constructor */
39: public DBIDInt(Integer id) {
40: m_dbid = id;
41: }
42:
43: /** get the identifier as an Integer, fits calling signature of our generic sql interface. */
44: public Object getID() {
45: return m_dbid;
46: }
47:
48: /** get the identifier as a plain int */
49: public int getIntID() {
50: return m_dbid.intValue();
51: }
52:
53: /** Hash is based on the underlying object */
54: public int hashCode() {
55: return m_dbid.hashCode();
56: }
57:
58: /** Equality is based on the underlying object */
59: public boolean equals(Object obj) {
60: if (obj instanceof DBIDInt) {
61: return getIntID() == ((DBIDInt) obj).getIntID();
62: } else {
63: return false;
64: }
65: }
66: }
67:
68: /*
69: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
70: * All rights reserved.
71: *
72: * Redistribution and use in source and binary forms, with or without
73: * modification, are permitted provided that the following conditions
74: * are met:
75: * 1. Redistributions of source code must retain the above copyright
76: * notice, this list of conditions and the following disclaimer.
77: * 2. Redistributions in binary form must reproduce the above copyright
78: * notice, this list of conditions and the following disclaimer in the
79: * documentation and/or other materials provided with the distribution.
80: * 3. The name of the author may not be used to endorse or promote products
81: * derived from this software without specific prior written permission.
82:
83: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
84: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
85: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
86: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
87: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
88: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
89: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
90: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
92: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93: */
|