Source Code Cross Referenced for Reply.java in  » Net » DrFTPD » org » drftpd » commands » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » DrFTPD » org.drftpd.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of DrFTPD, Distributed FTP Daemon.
003:         *
004:         * DrFTPD is free software; you can redistribute it and/or modify
005:         * it under the terms of the GNU General Public License as published by
006:         * the Free Software Foundation; either version 2 of the License, or
007:         * (at your option) any later version.
008:         *
009:         * DrFTPD is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         * GNU General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU General Public License
015:         * along with DrFTPD; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:        package org.drftpd.commands;
019:
020:        import org.apache.log4j.Level;
021:        import org.apache.log4j.Logger;
022:
023:        import java.io.BufferedReader;
024:        import java.io.IOException;
025:
026:        import java.util.Iterator;
027:        import java.util.Vector;
028:
029:        /**
030:         * @author mog
031:         * @version $Id: Reply.java 1513 2006-10-13 22:41:08Z tdsoul $
032:         */
033:        public class Reply implements  Cloneable {
034:            private static final Logger logger = Logger.getLogger(Reply.class
035:                    .getName());
036:
037:            /** 150 File status okay; about to open data connection. */
038:            public static final String RESPONSE_150_OK = "150 File status okay; about to open data connection.\r\n";
039:
040:            /** 200 Command okay */
041:            public static final Reply RESPONSE_200_COMMAND_OK = new Reply(200,
042:                    "Command okay");
043:
044:            /** 202 Command not implemented, superfluous at this site. */
045:            public static final Reply RESPONSE_202_COMMAND_NOT_IMPLEMENTED = new Reply(
046:                    202, "Command not implemented, superfluous at this site.");
047:
048:            /** 215 NAME system type. */
049:            public static final Reply RESPONSE_215_SYSTEM_TYPE = new Reply(215,
050:                    "UNIX system type.");
051:
052:            /** 221 Service closing control connection. */
053:            public static final Reply RESPONSE_221_SERVICE_CLOSING = new Reply(
054:                    221, "Service closing control connection.");
055:
056:            /** 226 Closing data connection */
057:            public static final Reply RESPONSE_226_CLOSING_DATA_CONNECTION = new Reply(
058:                    226, "Closing data connection");
059:
060:            /** 230 User logged in, proceed. */
061:            public static final Reply RESPONSE_230_USER_LOGGED_IN = new Reply(
062:                    230, "User logged in, proceed.");
063:
064:            /** 250 Requested file action okay, completed. */
065:            public static final Reply RESPONSE_250_ACTION_OKAY = new Reply(250,
066:                    "Requested file action okay, completed.");
067:
068:            /** 331 User name okay, need password. */
069:            public static final Reply RESPONSE_331_USERNAME_OK_NEED_PASS = new Reply(
070:                    331, "User name okay, need password.");
071:
072:            /** 350 Requested file action pending further information. */
073:            public static final Reply RESPONSE_350_PENDING_FURTHER_INFORMATION = new Reply(
074:                    350, "Requested file action pending further information.");
075:
076:            /** 425 Can't open data connection. */
077:            public static final String RESPONSE_425_CANT_OPEN_DATA_CONNECTION = "425 Can't open data connection.\r\n";
078:
079:            /** 426 Connection closed; transfer aborted. */
080:            public static final Reply RESPONSE_426_CONNECTION_CLOSED_TRANSFER_ABORTED = new Reply(
081:                    426, "Connection closed; transfer aborted.");
082:
083:            /** 450 Requested file action not taken. */
084:            public static final Reply RESPONSE_450_REQUESTED_ACTION_NOT_TAKEN = new Reply(
085:                    450, "Requested file action not taken.");
086:
087:            /** 450 No transfer-slave(s) available
088:             * author <a href="mailto:drftpd@mog.se">Morgan Christiansson</a>
089:             */
090:            public static final Reply RESPONSE_450_SLAVE_UNAVAILABLE = new Reply(
091:                    450, "No transfer-slave(s) available");
092:
093:            /** 500 Syntax error, command unrecognized. */
094:            public static final Reply RESPONSE_500_SYNTAX_ERROR = new Reply(
095:                    500, "Syntax error, command unrecognized.");
096:
097:            /** 501 Syntax error in parameters or arguments */
098:            public static final Reply RESPONSE_501_SYNTAX_ERROR = new Reply(
099:                    501, "Syntax error in parameters or arguments");
100:
101:            /** 502 Command not implemented. */
102:            public static final Reply RESPONSE_502_COMMAND_NOT_IMPLEMENTED = new Reply(
103:                    502, "Command not implemented.");
104:
105:            /** 503 Bad sequence of commands. */
106:            public static final Reply RESPONSE_503_BAD_SEQUENCE_OF_COMMANDS = new Reply(
107:                    503, "Bad sequence of commands.");
108:
109:            /** 504 Command not implemented for that parameter. */
110:            public static final Reply RESPONSE_504_COMMAND_NOT_IMPLEMENTED_FOR_PARM = new Reply(
111:                    504, "Command not implemented for that parameter.");
112:
113:            /** 530 Access denied */
114:            public static final Reply RESPONSE_530_ACCESS_DENIED = new Reply(
115:                    530, "Access denied");
116:
117:            /** 530 Not logged in. */
118:            public static final Reply RESPONSE_530_NOT_LOGGED_IN = new Reply(
119:                    530, "Not logged in.");
120:            public static final Reply RESPONSE_530_SLAVE_UNAVAILABLE = new Reply(
121:                    530, "No transfer-slave(s) available");
122:
123:            /**
124:             * 550 Requested action not taken. File unavailable.
125:             * File unavailable (e.g., file not found, no access).
126:             */
127:            public static final Reply RESPONSE_550_REQUESTED_ACTION_NOT_TAKEN = new Reply(
128:                    550, "Requested action not taken. File unavailable.");
129:
130:            /** 553 Requested action not taken.
131:             * File name not allowed.
132:             */
133:            public static final Reply RESPONSE_553_REQUESTED_ACTION_NOT_TAKEN = new Reply(
134:                    553, "Requested action not taken.  File name not allowed");
135:
136:            /** 550 Requested action not taken.
137:             * File exists.
138:             */
139:            public static final Reply RESPONSE_553_REQUESTED_ACTION_NOT_TAKEN_FILE_EXISTS = new Reply(
140:                    550, "Requested action not taken. File exists.");
141:
142:            protected int _code;
143:            protected Vector<String> _lines = new Vector<String>();
144:            protected String _message;
145:
146:            public Reply() {
147:            }
148:
149:            public Reply(int code) {
150:                setCode(code);
151:            }
152:
153:            public Reply(int code, String response) {
154:                setCode(code);
155:                setMessage(response);
156:            }
157:
158:            public Reply addComment(BufferedReader in) throws IOException {
159:                String line;
160:
161:                while ((line = in.readLine()) != null) { //throws IOException
162:                    this .addComment(line);
163:                }
164:
165:                return this ;
166:            }
167:
168:            public Reply addComment(Object response) {
169:                String resp = String.valueOf(response);
170:
171:                if (resp.indexOf('\n') != -1) {
172:                    String[] lines = resp.split("\n");
173:
174:                    for (int i = 0; i < lines.length; i++) {
175:                        _lines.add(lines[i]);
176:                    }
177:                } else {
178:                    _lines.add(resp);
179:                }
180:                return this ;
181:            }
182:
183:            public Object clone() {
184:                try {
185:                    Reply r = (Reply) super .clone();
186:                    r._lines = (Vector) _lines.clone();
187:
188:                    return r;
189:                } catch (CloneNotSupportedException ex) {
190:                    throw new RuntimeException(ex);
191:                }
192:            }
193:
194:            public int getCode() {
195:                return _code;
196:            }
197:
198:            public void setCode(int code) {
199:                _code = code;
200:            }
201:
202:            public void setMessage(String response) {
203:                if (response == null)
204:                    response = "No text";
205:                int pos = response.indexOf('\n');
206:
207:                if (pos != -1) {
208:                    addComment(response.substring(pos + 1));
209:                    response = response.substring(0, pos);
210:                    logger.log(Level.DEBUG,
211:                            "Truncated response message with multiple lines: "
212:                                    + response);
213:                }
214:
215:                _message = response;
216:            }
217:
218:            public int size() {
219:                return _lines.size();
220:            }
221:
222:            public String toString() {
223:                StringBuffer sb = new StringBuffer();
224:
225:                //sb.append(code + "-");
226:                if ((_lines.size() == 0) && (_message == null)) {
227:                    setMessage("No text specified");
228:                }
229:
230:                for (Iterator iter = _lines.iterator(); iter.hasNext();) {
231:                    String comment = (String) iter.next();
232:
233:                    if (!iter.hasNext() && (_message == null)) {
234:                        sb.append(_code + "  " + comment + "\r\n");
235:                    } else {
236:                        sb.append(_code + "- " + comment + "\r\n");
237:                    }
238:                }
239:
240:                if (_message != null) {
241:                    sb.append(_code + " " + _message + "\r\n");
242:                }
243:
244:                return sb.toString();
245:            }
246:
247:            public String getMessage() {
248:                return _message;
249:            }
250:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.