KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb > ListCacheKey


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * 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 JavaDoc;
25 import java.io.ObjectInput JavaDoc;
26 import java.io.IOException JavaDoc;
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: 37459 $
34  */

35 public final class ListCacheKey
36 extends CacheKey
37 {
38    // Constants -----------------------------------------------------
39

40    // Attributes ----------------------------------------------------
41

42    /**
43     * The list id.
44     */

45    private long listId;
46
47    /**
48     * The index of this entity in the list.
49     */

50    private int index;
51
52    // Static --------------------------------------------------------
53

54    // Public --------------------------------------------------------
55

56    public ListCacheKey() {
57       // For externalization only
58
}
59
60    /**
61     * @param listId The list id.
62     * @param index The index of this entity in the list.
63     */

64    public ListCacheKey(Object JavaDoc id, long listId, int index) {
65       super(id);
66       this.listId = listId;
67       this.index = index;
68    }
69
70    public long getListId()
71    {
72       return listId;
73    }
74
75    public int getIndex()
76    {
77       return index;
78    }
79
80    // Z implementation ----------------------------------------------
81

82    // Package protected ---------------------------------------------
83

84    // Protected -----------------------------------------------------
85

86    // Private -------------------------------------------------------
87

88    public void writeExternal(ObjectOutput JavaDoc out)
89       throws IOException JavaDoc
90    {
91       super.writeExternal(out);
92       out.writeLong(listId);
93       out.writeInt(index);
94    }
95
96    public void readExternal(ObjectInput JavaDoc in)
97       throws IOException JavaDoc, ClassNotFoundException JavaDoc
98    {
99       super.readExternal(in);
100       listId = in.readLong();
101       index = in.readInt();
102    }
103
104    // Inner classes -------------------------------------------------
105
}
106
Popular Tags