01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package com.sun.tck.wma.sms;
28:
29: import com.sun.tck.wma.BinaryMessage;
30: import com.sun.tck.wma.MessageConnection;
31:
32: /**
33: * Implements an instance of a binary message.
34: */
35: public class BinaryObject extends MessageObject implements
36: BinaryMessage {
37:
38: /** Buffer that will hold the data payload. */
39: private byte[] buffer;
40:
41: /**
42: * Construct a binary specific message.
43: * @param addr the destination address of the message.
44: */
45: public BinaryObject(String addr) {
46: super (MessageConnection.BINARY_MESSAGE, addr);
47: }
48:
49: /**
50: * Returns an array of bytes representing the payload data
51: * of the message, or <code>null</code> if it isn't set.
52: *
53: * <p>A reference to the byte array of this binary message
54: * is returned. It is the same for all calls to this method
55: * made before <code>setPayloadData</code> is called the
56: * next time.
57: *
58: * @return <code>null</code> if the data hasn't been set,
59: * or this message's payload data
60: * @see #setPayloadData
61: */
62: public byte[] getPayloadData() {
63: return buffer;
64: }
65:
66: /**
67: * Sets the payload data of this binary message. It may
68: * be set to <code>null</code>.
69: * <p>This method actually sets the reference to the byte array.
70: * Changes made to this array subsequently affect this
71: * <code>BinaryMessage</code> object's contents. Therefore, this array
72: * should not be reused by the applications until the message is sent and
73: * <code>MessageConnection.send</code> returned.
74: * </p>
75: * @param data payload data represented as a byte array
76: * @see #getPayloadData
77: */
78: public void setPayloadData(byte[] data) {
79: buffer = data;
80: }
81:
82: }
|