axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/utils Options.java
Date Thu, 18 Oct 2001 13:42:08 GMT
dug         01/10/18 06:42:08

  Modified:    java/samples/addr Main.java
               java/src/org/apache/axis/utils Options.java
  Log:
  Fix a bug in Options where setting the defaultURL wasn't sticking.
  
  Revision  Changes    Path
  1.8       +1 -2      xml-axis/java/samples/addr/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/addr/Main.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Main.java	2001/10/18 13:28:36	1.7
  +++ Main.java	2001/10/18 13:42:08	1.8
  @@ -114,8 +114,7 @@
   
           AddressBookService abs = new AddressBookService();
           opts.setDefaultURL( abs.getAddress() );
  -
  -        URL serviceURL = new URL(abs.getAddress());
  +        URL serviceURL = new URL(opts.getURL());
   
           AddressBook ab1 = null;
           if (serviceURL == null) {
  
  
  
  1.18      +40 -15    xml-axis/java/src/org/apache/axis/utils/Options.java
  
  Index: Options.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Options.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Options.java	2001/10/05 13:06:22	1.17
  +++ Options.java	2001/10/18 13:42:08	1.18
  @@ -68,25 +68,19 @@
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.util.ArrayList;
  +import java.util.Vector;
   
   public class Options {
       static Category category =
               Category.getInstance(Options.class.getName());
   
  -    String  args[] = null ;
  +    String  args[]     = null ;
  +    Vector  usedArgs   = null ;
       URL     defaultURL = null ;
   
       //////////////////////////////////////////////////////////////////////////
       // SOASS (Start of Axis Specific Stuff)
   
  -    String  host ;      // -h    also -l (url)
  -    String  port ;      // -p
  -    String  servlet ;   // -s    also -f (file)
  -    String  protocol ;
  -
  -    String  user ;      // -u
  -    String  passwd ;    // -w
  -
       // EOASS
       //////////////////////////////////////////////////////////////////////////
   
  @@ -95,6 +89,7 @@
        */
       public Options(String _args[]) throws MalformedURLException {
           args = _args ;
  +        usedArgs = null ;
           defaultURL = new URL("http://localhost:8080/axis/servlet/AxisServlet");
           
           ///////////////////////////////////////////////////////////////////////
  @@ -150,14 +145,24 @@
           int  loop ;
           int  i ;
   
  +        for ( loop = 0 ; usedArgs != null && loop < usedArgs.size() ; loop++
) {
  +            String arg = (String) usedArgs.elementAt(loop);
  +            if ( arg.charAt(0) != '-' ) continue ;
  +            for ( i = 0 ; i < arg.length() ; i++ )
  +                if ( arg.charAt(i) == optChar ) value++ ;
  +        }
  +
           for ( loop = 0 ; loop < args.length ; loop++ ) {
               if ( args[loop] == null || args[loop].length() == 0 ) continue ;
               if ( args[loop].charAt(0) != '-' ) continue ;
  -            while ( args[loop] != null && (i = args[loop].indexOf(optChar)) !=
-1 ) {
  +            while (args[loop] != null && 
  +                   (i = args[loop].indexOf(optChar)) != -1) {
                   args[loop] = args[loop].substring(0, i) + args[loop].substring(i+1) ;
                   if ( args[loop].length() == 1 ) 
                       args[loop] = null ;
                   value++ ;
  +                if ( usedArgs == null ) usedArgs = new Vector();
  +                usedArgs.add( "-" + optChar );
               }
           }
           return( value );
  @@ -179,6 +184,13 @@
           int     loop ;
           int     i ;
   
  +        for ( loop = 0 ; usedArgs != null && loop < usedArgs.size() ; loop++
) {
  +            String arg = (String) usedArgs.elementAt(loop);
  +            if ( arg.charAt(0) != '-' || arg.charAt(1) != optChar )
  +                continue ;
  +            value = arg.substring(2);
  +        }
  +
           for ( loop = 0 ; loop < args.length ; loop++ ) {
               if ( args[loop] == null || args[loop].length() == 0 ) continue ;
               if ( args[loop].charAt(0) != '-' ) continue ;
  @@ -211,6 +223,10 @@
               // For now, keep looping to get that last on there
               // break ; 
           }
  +        if ( value != null ) {
  +            if ( usedArgs == null ) usedArgs = new Vector();
  +            usedArgs.add( "-" + optChar + value );
  +        }
           return( value );
       }
   
  @@ -256,6 +272,11 @@
       // SOASS
       public String getURL() throws MalformedURLException {
           String  tmp ;
  +        String  host = null ;      // -h    also -l (url)
  +        String  port = null ;      // -p
  +        String  servlet = null ;   // -s    also -f (file)
  +        String  protocol = null ;
  +
           URL     url = null ;
           
           // Just in case...
  @@ -298,17 +319,21 @@
       }
       
       public int getPort() {
  -        return Integer.parseInt(port);
  +        try {
  +            URL url = new URL(getURL());
  +            return( url.getPort() );
  +        }
  +        catch( Exception exp ) {
  +            return( -1 );
  +        }
       }
   
       public String getUser() {
  -        if ( user == null ) user = isValueSet( 'u' );
  -        return( user );
  +        return( isValueSet('u') );
       }
   
       public String getPassword() {
  -        if ( passwd == null ) passwd = isValueSet( 'w' );
  -        return( passwd );
  +        return( isValueSet('w') );
       }
       // EOASS
       //////////////////////////////////////////////////////////////////////////
  
  
  

Mime
View raw message