KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > db > impl > DBIDInt


1 /*
2  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3  * All rights reserved.
4  * [See end of file]
5  */

6
7 //=======================================================================
8
// Package
9
package com.hp.hpl.jena.db.impl;
10
11
12 //=======================================================================
13
// Imports
14

15
16 //=======================================================================
17
/**
18 * Interface for database identifiers.
19 * Most RDF entities (resources, literals, statements) have an associated
20 * database index. These are cached using RDB-specific variants of the jena
21 * "impl" classes. This can avoid some redundant database lookup.
22 * <p>
23 * This variant just uses integers allocated by the database driver as indices.
24 * This would be sufficient for databases up to 4x10^9 statements.
25 *
26 * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
27 * @version $Revision: 1.4 $ on $Date: 2005/02/21 12:02:43 $
28 */

29
30 public class DBIDInt implements IDBID {
31
32     /** The index */
33     protected Integer JavaDoc m_dbid;
34
35     /** constructor */
36     public DBIDInt(int id) {
37         m_dbid = new Integer JavaDoc(id);
38     }
39
40     /** constructor */
41     public DBIDInt(Integer JavaDoc id) {
42         m_dbid = id;
43     }
44
45     /** get the identifier as an Integer, fits calling signature of our generic sql interface. */
46     public Object JavaDoc getID() {
47         return m_dbid;
48     }
49
50     /** get the identifier as a plain int */
51     public int getIntID() {
52         return m_dbid.intValue();
53     }
54
55     /** Hash is based on the underlying object */
56     public int hashCode() {
57         return m_dbid.hashCode();
58     }
59
60     /** Equality is based on the underlying object */
61     public boolean equals(Object JavaDoc obj) {
62         if (obj instanceof DBIDInt) {
63             return getIntID() == ((DBIDInt)obj).getIntID();
64         } else {
65             return false;
66         }
67     }
68 }
69
70 /*
71  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
72  * All rights reserved.
73  *
74  * Redistribution and use in source and binary forms, with or without
75  * modification, are permitted provided that the following conditions
76  * are met:
77  * 1. Redistributions of source code must retain the above copyright
78  * notice, this list of conditions and the following disclaimer.
79  * 2. Redistributions in binary form must reproduce the above copyright
80  * notice, this list of conditions and the following disclaimer in the
81  * documentation and/or other materials provided with the distribution.
82  * 3. The name of the author may not be used to endorse or promote products
83  * derived from this software without specific prior written permission.
84
85  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
86  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
87  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
88  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
89  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
90  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
91  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
92  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
93  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
94  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
95  */

96
97
Popular Tags