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.store.kahadaptor;
018
019 import java.io.DataInput;
020 import java.io.DataOutput;
021 import java.io.IOException;
022 import org.apache.activemq.kaha.Marshaller;
023 import org.apache.activemq.store.ReferenceStore.ReferenceData;
024
025 public class ReferenceRecordMarshaller implements Marshaller<ReferenceRecord> {
026
027 public ReferenceRecord readPayload(DataInput dataIn) throws IOException {
028 ReferenceRecord rr = new ReferenceRecord();
029 rr.setMessageId(dataIn.readUTF());
030 ReferenceData referenceData = new ReferenceData();
031 referenceData.setFileId(dataIn.readInt());
032 referenceData.setOffset(dataIn.readInt());
033 referenceData.setExpiration(dataIn.readLong());
034 rr.setData(referenceData);
035 return rr;
036 }
037
038 /**
039 * @param object
040 * @param dataOut
041 * @throws IOException
042 * @see org.apache.activemq.kaha.Marshaller#writePayload(java.lang.Object,
043 * java.io.DataOutput)
044 */
045 public void writePayload(ReferenceRecord rr, DataOutput dataOut) throws IOException {
046 dataOut.writeUTF(rr.getMessageId());
047 dataOut.writeInt(rr.getData().getFileId());
048 dataOut.writeInt(rr.getData().getOffset());
049 dataOut.writeLong(rr.getData().getExpiration());
050 }
051 }