001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.activemq.kaha.impl.index;
018
019 import java.io.DataInput;
020 import java.io.DataOutput;
021 import java.io.Externalizable;
022 import java.io.IOException;
023 import java.io.ObjectInput;
024 import java.io.ObjectOutput;
025
026 import org.apache.activemq.kaha.Marshaller;
027
028 public class RedoStoreIndexItem implements Externalizable {
029
030 public static final Marshaller MARSHALLER = new Marshaller() {
031 public Object readPayload(DataInput in) throws IOException {
032 RedoStoreIndexItem item = new RedoStoreIndexItem();
033 item.readExternal(in);
034 return item;
035 }
036
037 public void writePayload(Object object, DataOutput out) throws IOException {
038 RedoStoreIndexItem item = (RedoStoreIndexItem)object;
039 item.writeExternal(out);
040 }
041 };
042
043 private static final long serialVersionUID = -4865508871719676655L;
044 private String indexName;
045 private IndexItem indexItem;
046 private long offset;
047
048 public RedoStoreIndexItem() {
049 }
050
051 public RedoStoreIndexItem(String indexName, long offset, IndexItem item) {
052 this.indexName = indexName;
053 this.offset = offset;
054 this.indexItem = item;
055 }
056
057 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
058 readExternal((DataInput)in);
059 }
060
061 public void readExternal(DataInput in) throws IOException {
062 // indexName = in.readUTF();
063 offset = in.readLong();
064 indexItem = new IndexItem();
065 indexItem.read(in);
066 }
067
068 public void writeExternal(ObjectOutput out) throws IOException {
069 writeExternal((DataOutput)out);
070 }
071
072 public void writeExternal(DataOutput out) throws IOException {
073 // out.writeUTF(indexName);
074 out.writeLong(offset);
075 indexItem.write(out);
076 }
077
078 public String getIndexName() {
079 return indexName;
080 }
081
082 public void setIndexName(String indexName) {
083 this.indexName = indexName;
084 }
085
086 public IndexItem getIndexItem() {
087 return indexItem;
088 }
089
090 public void setIndexItem(IndexItem item) {
091 this.indexItem = item;
092 }
093
094 public long getOffset() {
095 return offset;
096 }
097
098 public void setOffset(long offset) {
099 this.offset = offset;
100 }
101
102 }