2
* SCCS: @(#)SyncMessage.java 1.1 (99/09/03)
4
* UniSoft Ltd., London, England
6
* Copyright (c) 1999 The Open Group
9
* No part of this source code may be reproduced, stored in a retrieval
10
* system, or transmitted, in any form or by any means, electronic,
11
* mechanical, photocopying, recording or otherwise, except as stated
12
* in the end-user licence agreement, without the prior permission of
13
* the copyright owners.
14
* A copy of the end-user licence agreement is contained in the file
15
* Licence which accompanies this distribution.
17
* Motif, OSF/1, UNIX and the "X" device are registered trademarks and
18
* IT DialTone and The Open Group are trademarks of The Open Group in
19
* the US and other countries.
21
* X/Open is a trademark of X/Open Company Limited in the UK and other
29
* The <code>SyncMessage</code> class provides the details of one message used
30
* during a TET sychronization event.
32
* @version @(#)SyncMessage.java 1.1 99/09/03 TETware release 3.7
33
* @author From JETpack 1.02 source
34
* @author Matthew Hails, UniSoft Ltd.
36
public class SyncMessage
38
static final String sccsid = "@(#)SyncMessage.java 1.1 (99/09/03) TETware release 3.7";
41
* Bit value for flags, indicating that the system is sending message
45
* Provided as public for backwards compatibility only; serves no
46
* useful purpose outside package.
48
public static final int TET_SMSNDMSG = 001;
51
* Bit value for flags, indicating that the system is receiving message
55
* Provided as public for backwards compatibility only; serves no
56
* useful purpose outside package.
58
public static final int TET_SMRCVMSG = 002;
61
* Bit value for flags, indicating that more than one system attempted
62
* to send message data.
65
* Provided as public for backwards compatibility only; serves no
66
* useful purpose outside package.
68
public static final int TET_SMDUP = 004;
71
* Bit value for flags, indicating that the message data was truncated.
74
* Provided as public for backwards compatibility only; serves no
75
* useful purpose outside package.
77
public static final int TET_SMTRUNC = 010;
80
* Maximum size of a sync message. Size must be expressable in 12 bits.
82
public static final int TET_SMMSGMAX = 1024;
95
* System ID of system that sent data.
100
* Construct an empty <code>SyncMessage</code>.
110
* Construct a <code>SyncMessage</code> which will be used for the
111
* transmission of a message.
113
* @param msg the message to send.
115
public SyncMessage(byte[] msg)
121
* Construct a <code>SyncMessage</code> which will be used for the
122
* reception of a message.
124
* @param msglen the size of the receive buffer to set up.
126
public SyncMessage(int msglen)
128
set_receive_length(msglen);
132
* Set up a <code>SyncMessage</code> for transmission of a message.
134
* @param msg the message to send.
136
public void set_message(byte[] msg)
139
flags = TET_SMSNDMSG;
144
* Retrieve the message length.
146
* @return the message length.
150
return (data == null) ? 0 : data.length;
154
* Set up a <code>SyncMessage</code> for reception of a message.
156
* @param msglen the size of the receive buffer to set up.
158
public void set_receive_length(int msglen)
161
data = new byte[msglen];
165
flags = TET_SMRCVMSG;
170
* Retrieve the message data.
172
* @return the message data (as a byte array), <code>null</code>
173
* if there is no message data.
175
public byte[] message()
181
* Was this synchronization message truncated?
183
* @return <code>true</code> if the message was truncated because
184
* the message was longer than the receive buffer or
185
* because the message was longer than the permitted
188
public boolean truncated()
190
return (flags & TET_SMTRUNC) != 0;
194
* Were there two senders during synchronization?
196
* @return <code>true</code> if there were two senders during
199
public boolean duplicated()
201
return (flags & TET_SMDUP) != 0;
205
* Was this message sent or does it contains message received from
208
* @return <code>true</code> if this message was sent during
211
public boolean sender()
213
return (flags & TET_SMSNDMSG) != 0;
217
* Get the value of the system ID of the sending system.
219
* @return the value of the system ID, or -1 if this message data
220
* was not used to receive data.
222
public int getSysID()
228
* Get the flags value.
236
* Set the fields of the message.
238
* @param data the message data.
239
* @param flags the message flags.
240
* @param sysID the system ID of the sending system.
242
void setFields(byte[] data, int flags, int sysID)