Source code: com/wilko/jaim/GenericTocResponse.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 * GenericTocCommand.java
22 *
23 * Created on 4 May 2002, 12:07
24 */
25
26 package com.wilko.jaim;
27
28 /** A GenericTocResponse is used internally in the Response parsing and processing logic of {@link JaimConnection}
29 * @author paulw
30 * @version $Revision: 1.5 $
31 */
32 public class GenericTocResponse extends TocResponse implements TocResponseHandler {
33
34 /** Creates new GenericTocCommand */
35 public GenericTocResponse() {
36 this.cmd="";
37 }
38
39 /** Parse an incoming string
40 * @param str The response string to be parsed
41 */
42 public TocResponse parseString(String str)
43 {
44 GenericTocResponse tr=new GenericTocResponse();
45 tr.doParse(str);
46 return tr;
47 }
48
49 private void doParse(String str)
50 {
51 cmd=str;
52 }
53
54 /** Get a byte array that contains the response
55 * @return The response as an array of bytes
56 */
57 public byte[] getBytes() {
58 return(cmd.getBytes());
59 }
60
61 /** Convert this response to a string
62 * @return The response as a string
63 */
64 public String toString()
65 {
66 return(cmd);
67 }
68
69 /** Used in the response dispatching process
70 * @return The respnse type
71 */
72 public String getResponseType()
73 {
74 return("UNKNOWN");
75 }
76
77 /** Returns true if this response handler can handle the specified response.
78 * @param Response - the response string from TOC. This is the part of the response before the first ':'
79 * @return true if the response can be handled
80 */
81 public boolean canHandle(String Response) {
82 return(true);
83 }
84
85 }