View Javadoc
1   //////////////////////////////////////////////////////////////////////////////
2   // dexterIM - Instant Messaging Framework
3   // Copyright (C) 2003  Christoph Walcher
4   //
5   // This program is free software; you can redistribute it and/or modify
6   // it under the terms of the GNU General Public License as published by
7   // the Free Software Foundation; either version 2 of the License, or
8   // (at your option) any later version.
9   //
10  // This program is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  // GNU General Public License for more details.
14  //
15  // You should have received a copy of the GNU General Public License
16  // along with this program; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  //////////////////////////////////////////////////////////////////////////////
19  package net.sf.dexterim.msn.message;
20  
21  import net.sf.dexterim.msn.MsnConnection;
22  
23  /***
24   *
25   * @author  Christoph Walcher
26   */
27  public class NewServerMessage extends SingleLineMessage {
28    private String host;
29    private int port;
30  
31    /*** Creates a new instance of NewServerMessage */
32    public NewServerMessage() {
33    }
34  
35    /*** Parses New Server Messages of the form XFR 2 NS 207.46.106.145:1863 0 207.46.104.20:1863
36    *
37    */
38    public net.sf.dexterim.msn.message.MsnMessage addLine(String line)
39      throws net.sf.dexterim.msn.message.MessageFormatException {
40      java.util.StringTokenizer st = new java.util.StringTokenizer(line);
41  
42      // skip tokens
43      for (int i = 0; i < 3; i++) {
44        st.nextToken();
45      }
46  
47      String temp = st.nextToken();
48      int i = temp.indexOf(":");
49  
50      if (i < 0) {
51        throw new net.sf.dexterim.msn.message.MessageFormatException(
52          "No new Host:Port combination received!");
53      }
54      else {
55        host = temp.substring(0, i);
56        port = Integer.parseInt(temp.substring(i + 1));
57      }
58  
59      return this;
60    }
61  
62    /*** Getter for property host.
63    * @return Value of property host.
64    *
65    */
66    public java.lang.String getHost() {
67      return host;
68    }
69  
70    /*** Getter for property port.
71    * @return Value of property port.
72    *
73    */
74    public int getPort() {
75      return port;
76    }
77  
78    /* (non-Javadoc)
79     * @see net.sf.dexterim.msn.message.MsnMessage#process(net.sf.dexterim.msn.MsnConnection)
80     */
81    public void process(MsnConnection connection) {
82      // TODO Auto-generated method stub
83      
84    }
85  }