01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.ejb;
23:
24: import java.io.ObjectOutput;
25: import java.io.ObjectInput;
26: import java.io.IOException;
27:
28: /**
29: * ListCacheKey extends {@link CacheKey} and holds info about the List that the entity belongs to,
30: * it is used with CMP 2.0 for reading ahead.
31: *
32: * @author <a href="mailto:on@ibis.odessa.ua">Oleg Nitz</a>
33: * @version $Revision: 57209 $
34: */
35: public final class ListCacheKey extends CacheKey {
36: // Constants -----------------------------------------------------
37:
38: // Attributes ----------------------------------------------------
39:
40: /**
41: * The list id.
42: */
43: private long listId;
44:
45: /**
46: * The index of this entity in the list.
47: */
48: private int index;
49:
50: // Static --------------------------------------------------------
51:
52: // Public --------------------------------------------------------
53:
54: public ListCacheKey() {
55: // For externalization only
56: }
57:
58: /**
59: * @param listId The list id.
60: * @param index The index of this entity in the list.
61: */
62: public ListCacheKey(Object id, long listId, int index) {
63: super (id);
64: this .listId = listId;
65: this .index = index;
66: }
67:
68: public long getListId() {
69: return listId;
70: }
71:
72: public int getIndex() {
73: return index;
74: }
75:
76: // Z implementation ----------------------------------------------
77:
78: // Package protected ---------------------------------------------
79:
80: // Protected -----------------------------------------------------
81:
82: // Private -------------------------------------------------------
83:
84: public void writeExternal(ObjectOutput out) throws IOException {
85: super .writeExternal(out);
86: out.writeLong(listId);
87: out.writeInt(index);
88: }
89:
90: public void readExternal(ObjectInput in) throws IOException,
91: ClassNotFoundException {
92: super .readExternal(in);
93: listId = in.readLong();
94: index = in.readInt();
95: }
96:
97: // Inner classes -------------------------------------------------
98: }
|