View Javadoc

1   /*
2    * $HeadURL: /cvsroot/insight/Insight/remote-protocol/src/com/mindtree/insight/remoteprotocol/PacketDataSizeOverLimitsException.java,v $
3    * $Date: 2005/08/09 18:39:17 $
4    * $Revision: 1.1 $
5    * $Author: m1001025 $
6    * 
7    * Copyright (c) 2005 MindTree Consulting Ltd. 
8    * 
9    * This file is part of Insight Remote Protocol Library.
10   * 
11   * Insight Remote Protocol Library is free software: you can redistribute it 
12   * and/or modify it under the terms of the GNU General Public License as 
13   * published by the Free Software Foundation, either version 3 of the License, 
14   * or (at your option) any later version.
15   * 
16   * Insight Remote Protocol Library is distributed in the hope that it will be 
17   * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
19   * Public License for more details.
20   * 
21   * You should have received a copy of the GNU General Public License along with 
22   * Insight Remote Protocol Library.  If not, see <http://www.gnu.org/licenses/>.
23   */
24  
25  package com.mindtree.techworks.insight.remoteprotocol.spi;
26  
27  import com.mindtree.techworks.insight.remoteprotocol.RemoteProtocolException;
28  
29  
30  /**
31   * This is the data content for packets where all the information is carried in
32   * the Header itself. One example of such a packet is the
33   * {@link com.mindtree.techworks.insight.remoteprotocol.spi.MessageType#SHUTDOWN_MESSAGE Shutdown Message}.
34   * 
35   * @see com.mindtree.techworks.insight.remoteprotocol.spi.PacketDataContent
36   * @author <a href="mailto:bindul_bhowmik@mindtree.com">Bindul Bhowmik</a>
37   * @version $Revision: 1.1 $ $Date: 2005/08/03 14:39:18 $
38   */
39  public class NullMessageDataContent extends PacketDataContent {
40  
41  	// -------------------------------------------------------------------------
42  	// Class Variables
43  	// -------------------------------------------------------------------------
44  
45  	/**
46  	 * The serial version UID for the serialized version.
47  	 */
48  	private static final long serialVersionUID = 4983089049003555547L;
49  
50  	// -------------------------------------------------------------------------
51  	// Constructors
52  	// -------------------------------------------------------------------------
53  
54  	/**
55  	 * Creates a new instance of NullMessageDataContent
56  	 * 
57  	 * @see PacketDataContent#PacketDataContent()
58  	 */
59  	public NullMessageDataContent () {
60  
61  		super();
62  
63  	}
64  
65  	/**
66  	 * Creates a new instance of NullMessageDataContent
67  	 * 
68  	 * @see PacketDataContent#PacketDataContent(byte[], PacketHeader)
69  	 * @param completePacketData The data for the complete packet.
70  	 * @param packetHeader The header for the packet
71  	 * @throws RemoteProtocolException If the length of the data in the packet
72  	 *             is greater than 0.
73  	 */
74  	public NullMessageDataContent (byte [] completePacketData,
75  			PacketHeader packetHeader) throws RemoteProtocolException {
76  
77  		super(completePacketData, packetHeader);
78  		if (this.getLength() != 0) {
79  			throw new RemoteProtocolException(
80  					"Incompatible message type: NullMessageDataContent "
81  							+ "cannot have any content.");
82  		}
83  	}
84  
85  	// -------------------------------------------------------------------------
86  	// Overridden methods from PacketDataContent
87  	// -------------------------------------------------------------------------
88  
89  	/**
90  	 * Overrides the superclasses setPacketData method. NullMessageDataContent
91  	 * is not supposed to have any data.
92  	 * 
93  	 * @see com.mindtree.techworks.insight.remoteprotocol.spi.PacketDataContent#setPacketData(byte[])
94  	 * @throws RemoteProtocolException if the <code>packetData</code> passed
95  	 *             in is not null.
96  	 */
97  	public void setPacketData (byte [] packetData)
98  			throws RemoteProtocolException {
99  
100 		if (null != packetData) {
101 			throw new RemoteProtocolException(
102 					"Incompatible message type: NullMessageDataContent "
103 							+ "cannot have any content.");
104 		}
105 	}
106 
107 
108 }