001: /**
002: *
003: * Java FTP client library.
004: *
005: * Copyright (C) 2000-2003 Enterprise Distributed Technologies Ltd
006: *
007: * www.enterprisedt.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
022: *
023: * Bug fixes, suggestions and comments should be should posted on
024: * http://www.enterprisedt.com/forums/index.php
025: *
026: * Change Log:
027: *
028: * $Log: FTPReply.java,v $
029: * Revision 1.6 2007/05/03 04:20:46 bruceb
030: * added rawReply
031: *
032: * Revision 1.5 2006/10/11 08:58:29 hans
033: * made cvsId final
034: *
035: * Revision 1.4 2005/06/03 11:26:25 bruceb
036: * comment change
037: *
038: * Revision 1.3 2004/08/31 10:46:11 bruceb
039: * data lines added
040: *
041: * Revision 1.2 2004/07/23 08:28:19 bruceb
042: * new constructor
043: *
044: * Revision 1.1 2002/11/19 22:01:25 bruceb
045: * changes for 1.2
046: *
047: *
048: */package com.enterprisedt.net.ftp;
049:
050: /**
051: * Encapsulates the FTP server reply
052: *
053: * @author Bruce Blackshaw
054: * @version $Revision: 1.6 $
055: */
056: public class FTPReply {
057:
058: /**
059: * Revision control id
060: */
061: public static final String cvsId = "@(#)$Id: FTPReply.java,v 1.6 2007/05/03 04:20:46 bruceb Exp $";
062:
063: /**
064: * Reply code
065: */
066: private String replyCode;
067:
068: /**
069: * Reply text
070: */
071: private String replyText;
072:
073: /**
074: * Raw reply
075: */
076: private String rawReply;
077:
078: /**
079: * Lines of data returned, e.g. FEAT
080: */
081: private String[] data;
082:
083: /**
084: * Constructor. Only to be constructed
085: * by this package, hence package access
086: *
087: * @param replyCode the server's reply code
088: * @param replyText the server's reply text
089: */
090: FTPReply(String replyCode, String replyText) {
091: this .replyCode = replyCode;
092: this .replyText = replyText;
093: rawReply = replyCode + " " + replyText;
094: }
095:
096: /**
097: * Constructor. Only to be constructed
098: * by this package, hence package access
099: *
100: * @param replyCode the server's reply code
101: * @param replyText the server's full reply text
102: * @param data data lines contained in reply text
103: */
104: FTPReply(String replyCode, String replyText, String[] data) {
105: this .replyCode = replyCode;
106: this .replyText = replyText;
107: this .data = data;
108: }
109:
110: /**
111: * Constructor. Only to be constructed
112: * by this package, hence package access
113: *
114: * @param rawReply the server's raw reply
115: */
116: FTPReply(String reply) {
117: // all reply codes are 3 chars long
118: this .rawReply = reply.trim();
119: replyCode = rawReply.substring(0, 3);
120: if (rawReply.length() > 3)
121: replyText = rawReply.substring(4);
122: else
123: replyText = "";
124: }
125:
126: /**
127: * Getter for raw reply
128: *
129: * @return server's raw reply
130: */
131: public String getRawReply() {
132: return rawReply;
133: }
134:
135: /**
136: * Getter for reply code
137: *
138: * @return server's reply code
139: */
140: public String getReplyCode() {
141: return replyCode;
142: }
143:
144: /**
145: * Getter for reply text
146: *
147: * @return server's reply text
148: */
149: public String getReplyText() {
150: return replyText;
151: }
152:
153: /**
154: * Getter for reply data lines
155: *
156: * @return array of data lines returned (if any). Null
157: * if no data lines
158: */
159: public String[] getReplyData() {
160: return data;
161: }
162:
163: }
|