01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: *
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: /**
20: * @author Khen G. Kim
21: * @version $Revision: 1.3 $
22: */
23:
24: /**
25: * Created on 10.01.2004
26: */package org.apache.harmony.jpda.tests.framework.jdwp;
27:
28: import org.apache.harmony.jpda.tests.framework.jdwp.Packet;
29:
30: /**
31: * This class represents JDWP reply packet.
32: */
33: public class ReplyPacket extends Packet {
34:
35: private final int ERROR_CODE_INDEX = 9;
36:
37: private short error_code;
38:
39: /**
40: * A default constructor that creates an empty ReplyPacket with empty header
41: * and no data.
42: */
43: public ReplyPacket() {
44: super ();
45: }
46:
47: /**
48: * A constructor that creates ReplyPacket from array of bytes including
49: * header and data sections.
50: *
51: * @param p
52: * the JDWP packet, given as array of bytes.
53: */
54: public ReplyPacket(byte p[]) {
55: super (p);
56: error_code = (short) super .readFromByteArray(p,
57: ERROR_CODE_INDEX, Packet.SHORT_SIZE);
58: }
59:
60: /**
61: * Sets the error code value of the header of the ReplyPacket as short.
62: *
63: * @param val
64: * the error code.
65: */
66: public void setErrorCode(short val) {
67: error_code = val;
68: }
69:
70: /**
71: * Gets the error code value of the header of the ReplyPacket.
72: *
73: * @return the error code value of the header of the ReplyPacket.
74: */
75: public short getErrorCode() {
76: return error_code;
77: }
78:
79: /**
80: * Gets the representation of the ReplyPacket as array of bytes in the JDWP
81: * format including header and data sections.
82: *
83: * @return the representation of the ReplyPacket as array of bytes in the
84: * JDWP format.
85: */
86: public byte[] toBytesArray() {
87: byte res[] = super.toBytesArray();
88: super.writeAtByteArray(error_code, res, ERROR_CODE_INDEX,
89: Packet.SHORT_SIZE);
90: return res;
91: }
92: }
|