You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ga...@apache.org on 2004/11/14 06:03:54 UTC

cvs commit: ws-axis/java/src/org/apache/axis/utils StringUtils.java

gawor       2004/11/13 21:03:54

  Modified:    java/src/org/apache/axis/i18n resource.properties
               java/src/org/apache/axis/transport/http
                        SimpleAxisServer.java
               java/src/org/apache/axis/utils StringUtils.java
  Log:
  fixed resource issues (tests were failing), optimized StringUtils.strip() to do substring ones
  
  Revision  Changes    Path
  1.98      +2 -1      ws-axis/java/src/org/apache/axis/i18n/resource.properties
  
  Index: resource.properties
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/i18n/resource.properties,v
  retrieving revision 1.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- resource.properties	12 Nov 2004 15:44:23 -0000	1.97
  +++ resource.properties	14 Nov 2004 05:03:53 -0000	1.98
  @@ -611,7 +611,8 @@
   
   setValueInTarget00=Set value {0} in target {1}
   somethingWrong00=Sorry, something seems to have gone wrong... here are the details:
  -start00=starting up {0} on port {1} ({2}) 
  +start00=starting up {0} on port {1}
  +start01=starting up {0} on port {1} ({2}) 
   startElem00=Start element {0}
   startPrefix00=Start prefix mapping ''{0}'' -> ''{1}''
   stackFrame00=Stack frame marker
  
  
  
  1.87      +1 -1      ws-axis/java/src/org/apache/axis/transport/http/SimpleAxisServer.java
  
  Index: SimpleAxisServer.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/http/SimpleAxisServer.java,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- SimpleAxisServer.java	12 Nov 2004 15:44:23 -0000	1.86
  +++ SimpleAxisServer.java	14 Nov 2004 05:03:54 -0000	1.87
  @@ -224,7 +224,7 @@
        * Axis engine for processing.
        */
       public void run() {
  -        log.info(Messages.getMessage("start00", "SimpleAxisServer",
  +        log.info(Messages.getMessage("start01", "SimpleAxisServer",
                   new Integer(getServerSocket().getLocalPort()).toString(),getCurrentDirectory()));
   
           // Accept and process requests from the socket
  
  
  
  1.6       +28 -11    ws-axis/java/src/org/apache/axis/utils/StringUtils.java
  
  Index: StringUtils.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/StringUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StringUtils.java	27 Jun 2004 22:49:17 -0000	1.5
  +++ StringUtils.java	14 Nov 2004 05:03:54 -0000	1.6
  @@ -194,11 +194,19 @@
        * @return the stripped String, <code>null</code> if null String input
        */
       public static String strip(String str, String stripChars) {
  -        if (isEmpty(str)) {
  +        if (str == null) {
               return str;
           }
  -        str = stripStart(str, stripChars);
  -        return stripEnd(str, stripChars);
  +        int len = str.length();
  +        if (len == 0) {
  +            return str;
  +        }
  +        int start = getStripStart(str, stripChars);
  +        if (start == len) {
  +            return "";
  +        }
  +        int end = getStripEnd(str, stripChars);
  +        return (start == 0 && end == len) ? str : str.substring(start, end);
       }
   
       /**
  @@ -226,9 +234,14 @@
        * @return the stripped String, <code>null</code> if null String input
        */
       public static String stripStart(String str, String stripChars) {
  +        int start = getStripStart(str, stripChars);
  +        return (start <= 0) ? str : str.substring(start);
  +    }
  +
  +    private static int getStripStart(String str, String stripChars) {
           int strLen;
           if (str == null || (strLen = str.length()) == 0) {
  -            return str;
  +            return -1;
           }
           int start = 0;
           if (stripChars == null) {
  @@ -236,13 +249,13 @@
                   start++;
               }
           } else if (stripChars.length() == 0) {
  -            return str;
  +            return start;
           } else {
               while ((start != strLen) && (stripChars.indexOf(str.charAt(start)) != -1)) {
                   start++;
               }
           }
  -        return str.substring(start);
  +        return start;
       }
   
       /**
  @@ -270,22 +283,26 @@
        * @return the stripped String, <code>null</code> if null String input
        */
       public static String stripEnd(String str, String stripChars) {
  +        int end = getStripEnd(str, stripChars);
  +        return (end < 0) ? str : str.substring(0, end);
  +    }
  +
  +    private static int getStripEnd(String str, String stripChars) {
           int end;
           if (str == null || (end = str.length()) == 0) {
  -            return str;
  +            return -1;
           }
  -
           if (stripChars == null) {
               while ((end != 0) && Character.isWhitespace(str.charAt(end - 1))) {
                   end--;
               }
           } else if (stripChars.length() == 0) {
  -            return str;
  +            return end;
           } else {
               while ((end != 0) && (stripChars.indexOf(str.charAt(end - 1)) != -1)) {
                   end--;
               }
           }
  -        return str.substring(0, end);
  +        return end;
       }
  -}
  \ No newline at end of file
  +}