You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by je...@apache.org on 2001/04/03 04:42:24 UTC

cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd Slide.java

jericho     01/04/02 19:42:24

  Modified:    src/webdav/client/src/org/apache/webdav/cmd Slide.java
  Log:
  - Fix wrong input processing.   Make input error checking robust.
  - Add the help message for the open command
  
  Revision  Changes    Path
  1.15      +32 -16    jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java
  
  Index: Slide.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Slide.java	2001/03/30 12:55:41	1.14
  +++ Slide.java	2001/04/03 02:42:24	1.15
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v 1.14 2001/03/30 12:55:41 jericho Exp $
  - * $Revision: 1.14 $
  - * $Date: 2001/03/30 12:55:41 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v 1.15 2001/04/03 02:42:24 jericho Exp $
  + * $Revision: 1.15 $
  + * $Date: 2001/04/03 02:42:24 $
    *
    * ====================================================================
    *
  @@ -257,32 +257,48 @@
               do {
                   System.out.print(getPrompt());
                   command = in.readLine();
  -                if (command == null || command.length() == 0)
  +                if (command == null) {
  +                    // Normally exit the program.
  +                    // Because the input by user is EOF.
  +                    System.exit(0);
  +                } else {
  +                    command = command.trim();
  +                }
  +                if (command.length() <= 0)
                       continue;
  -
  -                StringTokenizer st = new StringTokenizer(command.trim());
  +                
  +                StringTokenizer st = new StringTokenizer(command);
                   String todo = st.nextToken();
                   Stack params = new Stack();
  -
                   while (st.hasMoreTokens()) {
                       params.push(st.nextToken());
                   }
  -
  +                
                   if (todo.equalsIgnoreCase("open")) {
                       String inputUrl = null;
  -                    if (!params.empty()) {
  -                        inputUrl =  (String) params.pop();
  -                    } else {
  +                    switch (params.size()) {
  +                    case 0: 
                           System.out.print("Enter http URL: ");
                           inputUrl = in.readLine();
  -                        if (inputUrl != null) {
  +                        if (inputUrl == null) {
  +                            continue;
  +                        } else {
                               inputUrl = inputUrl.trim();
  -                            if (inputUrl.length() == 0)
  -                                // Do not go further.
  -                                continue;
                           }
  +                        if (inputUrl.length() <= 0)
  +                            // Do not go further.
  +                            continue;
  +                        break;
  +                    case 1:
  +                        inputUrl =  (String) params.pop();
  +                        break;
  +                    default:
  +                        System.err.println
  +                            ("[Help] open " +
  +                             "http://username:password@hostname:port/path");
  +                        continue;
                       }
  -
  +                    
                       try {
                           // Set up for processing WebDAV resources
                           httpURL = new HttpURL(inputUrl);