View Javadoc

1   /*
2    * Copyright (c) 2005 The University of Reading
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    * 1. Redistributions of source code must retain the above copyright
9    *    notice, this list of conditions and the following disclaimer.
10   * 2. Redistributions in binary form must reproduce the above copyright
11   *    notice, this list of conditions and the following disclaimer in the
12   *    documentation and/or other materials provided with the distribution.
13   * 3. Neither the name of the University of Reading, nor the names of the
14   *    authors or contributors may be used to endorse or promote products
15   *    derived from this software without specific prior written permission.
16   * 
17   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18   * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20   * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27   */
28  
29  package uk.ac.rdg.resc.jstyx.messages;
30  
31  import uk.ac.rdg.resc.jstyx.StyxUtils;
32  
33  /***
34   * Message sent to enquire about the attributes of a file on a Styx server
35   *
36   * @author Jon Blower
37   * $Revision: 507 $
38   * $Date: 2005-12-01 08:21:56 +0000 (Thu, 01 Dec 2005) $
39   * $Log$
40   * Revision 1.5  2005/12/01 08:21:56  jonblower
41   * Fixed javadoc comments
42   *
43   * Revision 1.4  2005/03/15 09:01:48  jonblower
44   * Message type now stored as short, not int
45   *
46   * Revision 1.3  2005/03/11 14:02:16  jonblower
47   * Merged MINA-Test_20059309 into main line of development
48   *
49   * Revision 1.2.2.1  2005/03/10 11:50:59  jonblower
50   * Changed to fit with MINA framework
51   *
52   * Revision 1.2  2005/02/24 07:44:44  jonblower
53   * Added getFriendlyString()
54   *
55   * Revision 1.1.1.1  2005/02/16 18:58:29  jonblower
56   * Initial import
57   *
58   */
59  public class TstatMessage extends StyxMessage
60  {
61      
62      private long fid; // The fid of the file
63      
64      /*** 
65       * Creates a new TstatMessage. This constructor will be called by the
66       * MessageRecognizer.
67       * @param length The total length of the message (including all header info)
68       * @param type The type of the message (a number between 100 and 127)
69       * @param tag The tag that identifies this message
70       */
71      public TstatMessage(int length, short type, int tag)
72      {
73          super(length, type, tag);
74          this.name = "Tstat";
75      }
76      
77      /***
78       * This constructor should be called when constructing a TstatMessage from
79       * scratch
80       */
81      public TstatMessage(long fid)
82      {
83          this(0, (short)124, 0);
84          this.fid = fid;
85          this.length = StyxUtils.HEADER_LENGTH + 4;
86      }
87      
88      protected final void decodeBody(StyxBuffer buf)
89      {
90          // Read the fid of the file to enquire about
91          this.fid = buf.getUInt();
92      }
93      
94      protected final void encodeBody(StyxBuffer buf)
95      {
96          // Write the fid of the file to enquire about
97          buf.putUInt(this.fid);
98      }
99      
100     /***
101      * @return The requested maximum size of a message that will 
102      * be sent on this connection by either party
103      */
104     public long getFid()
105     {
106         return this.fid;
107     }
108     
109     /***
110      * Sets the fid for this TstatMessage
111      * @param fid the fid
112      */
113     public void setFid(long fid)
114     {
115         this.fid = fid;
116     }
117     
118     protected String getElements()
119     {
120         return ", " + this.fid;
121     }
122     
123     public String toFriendlyString()
124     {
125         return "fid: " + this.fid;
126     }
127     
128 }