1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.activemq.kaha.impl.data; 18 19 import org.apache.activemq.kaha.StoreLocation; 20 21 /** 22 * A a wrapper for a data in the store 23 * 24 * @version $Revision: 1.2 $ 25 */ 26 public final class DataItem implements Item, StoreLocation { 27 28 private int file = (int)POSITION_NOT_SET; 29 private long offset = POSITION_NOT_SET; 30 private int size; 31 32 public DataItem() { 33 } 34 35 DataItem(DataItem item) { 36 this.file = item.file; 37 this.offset = item.offset; 38 this.size = item.size; 39 } 40 41 boolean isValid() { 42 return file != POSITION_NOT_SET; 43 } 44 45 /** 46 * @return 47 * @see org.apache.activemq.kaha.StoreLocation#getSize() 48 */ 49 public int getSize() { 50 return size; 51 } 52 53 /** 54 * @param size The size to set. 55 */ 56 public void setSize(int size) { 57 this.size = size; 58 } 59 60 /** 61 * @return 62 * @see org.apache.activemq.kaha.StoreLocation#getOffset() 63 */ 64 public long getOffset() { 65 return offset; 66 } 67 68 /** 69 * @param offset The offset to set. 70 */ 71 public void setOffset(long offset) { 72 this.offset = offset; 73 } 74 75 /** 76 * @return 77 * @see org.apache.activemq.kaha.StoreLocation#getFile() 78 */ 79 public int getFile() { 80 return file; 81 } 82 83 /** 84 * @param file The file to set. 85 */ 86 public void setFile(int file) { 87 this.file = file; 88 } 89 90 /** 91 * @return a pretty print 92 */ 93 public String toString() { 94 String result = "offset = " + offset + ", file = " + file + ", size = " + size; 95 return result; 96 } 97 98 public DataItem copy() { 99 return new DataItem(this); 100 } 101 }