Source code: org/activemq/message/CachedValue.java
1 /**
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * 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 **/
18
19 package org.activemq.message;
20
21 import java.io.DataInput;
22 import java.io.IOException;
23 import java.io.DataOutput;
24
25 /**
26 * Sent in receipt of a Packet
27 */
28
29 public class CachedValue extends AbstractPacket implements BodyPacket {
30
31 private Object value;
32
33
34 /**
35 * Return the type of Packet
36 *
37 * @return integer representation of the type of Packet
38 */
39
40 public int getPacketType() {
41 return CACHED_VALUE_COMMAND;
42 }
43
44
45 /**
46 * @return pretty print of a CachedValue
47 */
48 public String toString() {
49 return super.toString() + " CachedValue{ " +
50 "value = " + value +
51 " }";
52 }
53 /**
54 * @return Returns the value.
55 */
56 public Object getValue() {
57 return value;
58 }
59
60 /**
61 * @param value The value to set.
62 */
63 public void setValue(Object value) {
64 this.value = value;
65 }
66
67 public void writeBody(DataOutput dataOut) throws IOException {
68 String text = "";
69 if (value != null) {
70 text = value.toString();
71 }
72 dataOut.writeUTF(text);
73 }
74
75 public void readBody(DataInput dataIn) throws IOException {
76 setValue(dataIn.readUTF());
77 }
78 }