3 * Object to parse the reply from the server, so I don't have to think
4 * about it when I write code.
9 public class citReply {
10 public static final int LISTING_FOLLOWS=100, OK=200, MORE_DATA=300,
11 SEND_LISTING=400, ERROR=500, BINARY_FOLLOWS=600, SEND_BINARY=700,
19 public citReply( String line ) {
32 public void parseLine() {
34 res_code = Integer.parseInt( line.substring( 0, 3 ) );
35 } catch( Exception e ) {};
37 StringBuffer s = new StringBuffer();
39 if( (line.length() > 3) && (line.charAt( 3 ) == '*') )
42 for( int i = 4; i < line.length(); i++ ) {
43 char c = line.charAt( i );
45 args.addElement( s.toString() );
46 s = new StringBuffer();
51 if( s.length() != 0 ) args.addElement( s.toString() );
55 public boolean expressMessage() {
59 public boolean listingFollows() {
60 return res_code/100 == LISTING_FOLLOWS/100;
64 return res_code/100 == OK/100;
67 public boolean moreData() {
68 return res_code/100 == MORE_DATA/100;
71 public boolean sendListing() {
72 return res_code/100 == SEND_LISTING/100;
75 public boolean error() {
76 return res_code/100 == ERROR/100;
79 public boolean binaryFollows() {
80 return res_code/100 == BINARY_FOLLOWS/100;
83 public boolean sendBinary() {
84 return res_code/100 == SEND_BINARY/100;
87 public boolean startChatMode() {
88 return res_code/100 == START_CHAT_MODE/100;
91 public boolean addData( String s ) {
92 if( s.equals( "000" ) )
95 if( listing == null ) listing = new Vector();
96 listing.addElement( s );
100 public String getLine( int i ) {
101 if( listing == null ) return null;
103 if( (i<0) || (i>=listing.size()) ) return null;
105 return (String)listing.elementAt( i );
108 public String getData() {
109 if( data != null ) return data;
111 StringBuffer s = new StringBuffer();
113 for( Enumeration e=listing.elements(); e.hasMoreElements(); ) {
114 s.append( (String)e.nextElement() );
123 public String getArg( int i ) {
124 if( args == null ) return "";
126 if( (i<0) || (i>=args.size()) ) return "";
128 return (String)args.elementAt( i );