KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > kaha > impl > data > DataItem


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.kaha.impl.data;
19
20 import org.apache.activemq.kaha.StoreLocation;
21
22
23 /**
24  * A a wrapper for a data in the store
25  *
26  * @version $Revision: 1.2 $
27  */

28 public final class DataItem implements Item, StoreLocation{
29     
30     private int file=(int) POSITION_NOT_SET;
31     private long offset=POSITION_NOT_SET;
32     private int size;
33
34     public DataItem(){}
35     
36     DataItem(DataItem item) {
37         this.file = item.file;
38         this.offset = item.offset;
39         this.size = item.size;
40     }
41     
42     boolean isValid(){
43         return file != POSITION_NOT_SET;
44     }
45
46     /**
47      * @return
48      * @see org.apache.activemq.kaha.StoreLocation#getSize()
49      */

50     public int getSize(){
51         return size;
52     }
53
54     /**
55      * @param size The size to set.
56      */

57     public void setSize(int size){
58         this.size=size;
59     }
60
61     /**
62      * @return
63      * @see org.apache.activemq.kaha.StoreLocation#getOffset()
64      */

65     public long getOffset(){
66         return offset;
67     }
68
69     /**
70      * @param offset The offset to set.
71      */

72     public void setOffset(long offset){
73         this.offset=offset;
74     }
75
76     /**
77      * @return
78      * @see org.apache.activemq.kaha.StoreLocation#getFile()
79      */

80     public int getFile(){
81         return file;
82     }
83
84     /**
85      * @param file The file to set.
86      */

87     public void setFile(int file){
88         this.file=file;
89     }
90
91     /**
92      * @return a pretty print
93      */

94     public String JavaDoc toString(){
95         String JavaDoc result="offset = "+offset+", file = " + file + ", size = "+size;
96         return result;
97     }
98
99     public DataItem copy() {
100         return new DataItem(this);
101     }
102 }
103
Popular Tags