KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > store > kahadaptor > ReferenceRecordMarshaller


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

14
15 package org.apache.activemq.store.kahadaptor;
16
17 import java.io.DataInput JavaDoc;
18 import java.io.DataOutput JavaDoc;
19 import java.io.IOException JavaDoc;
20 import org.apache.activemq.kaha.Marshaller;
21 import org.apache.activemq.store.ReferenceStore.ReferenceData;
22
23 public class ReferenceRecordMarshaller implements Marshaller<ReferenceRecord>{
24
25     public ReferenceRecord readPayload(DataInput JavaDoc dataIn) throws IOException JavaDoc{
26         ReferenceRecord rr=new ReferenceRecord();
27         rr.setMessageId(dataIn.readUTF());
28         ReferenceData referenceData = new ReferenceData();
29         referenceData.setFileId(dataIn.readInt());
30         referenceData.setOffset(dataIn.readInt());
31         referenceData.setExpiration(dataIn.readLong());
32         rr.setData(referenceData);
33         return rr;
34     }
35
36     /**
37      * @param object
38      * @param dataOut
39      * @throws IOException
40      * @see org.apache.activemq.kaha.Marshaller#writePayload(java.lang.Object, java.io.DataOutput)
41      */

42     public void writePayload(ReferenceRecord rr,DataOutput JavaDoc dataOut) throws IOException JavaDoc{
43         dataOut.writeUTF(rr.getMessageId());
44         dataOut.writeInt(rr.getData().getFileId());
45         dataOut.writeInt(rr.getData().getOffset());
46         dataOut.writeLong(rr.getData().getExpiration());
47     }
48 }
49
Popular Tags