Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/wilko/jaim/GotoTocResponse.java


1   /* 
2    *   (C) 2002 Paul Wilkinson  wilko@users.sourceforge.net
3    *
4    *   This program is free software; you can redistribute it and/or modify
5    *   it under the terms of the GNU General Public License as published by
6    *   the Free Software Foundation; either version 2 of the License, or
7    *   (at your option) any later version.
8    *
9    *   This program is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   *   GNU General Public License for more details.
13   *
14   *   You should have received a copy of the GNU General Public License
15   *   along with this program; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17   *
18   */
19  
20  /*
21   * TocIMResponse.java
22   *
23   * Created on 4 May 2002, 14:38
24   */
25  
26  package com.wilko.jaim;
27  
28  /** This response is delivered to a {@link JaimEventListener } when a GOTO response is received from TOC
29   * @author paulw
30   * @version $Revision: 1.3 $
31   */
32  public class GotoTocResponse extends TocResponse implements TocResponseHandler {
33  
34      String windowName;
35      boolean autoResponse;
36      String URL;
37      
38      public static final String RESPONSE_TYPE="GOTO_URL";
39      
40      /** Creates new GotoTocResponse */
41      public GotoTocResponse() {
42          windowName="";
43          URL="";
44      }
45      
46      /** Obtain the suggested window name for this URL
47       * @return The window name
48       */    
49      public String getWindowName()
50      {
51          return(windowName);
52      }
53      
54      /** Obtain the URL
55       * @return The URL
56       */    
57      public String getURL()
58      {
59          return(URL);
60      }
61      
62    
63  
64      /** Parse an incoming  response string
65       * @param str The string to be parsed
66       */    
67      public TocResponse parseString(java.lang.String str) {
68          GotoTocResponse tr=new GotoTocResponse();
69          tr.doParse(str);
70          return(tr);
71      }
72      
73      private void doParse(String str)
74      {
75          cmd=str;
76          int colonPos=str.indexOf(':');
77          if (colonPos!=-1)
78          {
79              str=str.substring(colonPos+1);
80              colonPos=str.indexOf(':');
81              if (colonPos != -1)
82              {
83                  windowName=str.substring(0,colonPos);
84                  URL=str.substring(colonPos+1);
85                  
86              }
87          }
88              
89      }
90      
91      /** Obtain the response type for response dispatching purposes
92       * @return The response type
93       */    
94      public String getResponseType() {
95          return(RESPONSE_TYPE);
96      }
97      
98      /** Returns true if this response handler can handle the specified response.
99       * @param Response - the response string from TOC.  This is the part of the response before the first ':'
100      * @return true if the response can be handled
101      */
102     public boolean canHandle(String Response) {
103         return (Response.equalsIgnoreCase(RESPONSE_TYPE));
104     }
105     
106 }