axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/src/org/apache/axis/utils ClassUtils.java StringUtils.java
Date Mon, 01 Dec 2003 13:46:37 GMT
dims        2003/12/01 05:46:37

  Modified:    java/src/org/apache/axis/utils ClassUtils.java
                        StringUtils.java
  Log:
  Remove JDK1.4 specific code.
  
  Revision  Changes    Path
  1.9       +7 -4      ws-axis/java/src/org/apache/axis/utils/ClassUtils.java
  
  Index: ClassUtils.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/ClassUtils.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ClassUtils.java	30 Nov 2003 05:42:24 -0000	1.8
  +++ ClassUtils.java	1 Dec 2003 13:46:37 -0000	1.9
  @@ -251,7 +251,6 @@
        * <li>the system classloader
        * <li>the class "clazz" itself
        * </ol>
  -     * @todo we do not look at the context classloader: why is that? 
        * @param clazz class to use in the lookups
        * @param resource resource string to look for
        * @return input stream if found, or null
  @@ -266,6 +265,10 @@
               // Try the system class loader.
               myInputStream = ClassLoader.getSystemClassLoader().getResourceAsStream(resource);
           }
  +        if (myInputStream == null && Thread.currentThread().getContextClassLoader()
!= null) {
  +            // try the context class loader.
  +            myInputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
  +        }
           if (myInputStream == null) {
               // if not found in classpath fall back to default
               myInputStream = clazz.getResourceAsStream(resource);
  @@ -283,7 +286,7 @@
        * @param classpath  the classpath String
        * @param parent  the parent ClassLoader, or null if the default is to be
        *     used
  -     * @throws SecurityExcepiton if you don't have privilages to create
  +     * @throws SecurityException if you don't have privilages to create
        *         class loaders
        * @throws IllegalArgumentException if your classpath string is silly
        */
  @@ -291,7 +294,7 @@
                                                   ClassLoader parent)
               throws SecurityException
       {
  -        String[] names = classpath.split(System.getProperty("path.seperator"));
  +        String[] names = StringUtils.split(classpath, System.getProperty("path.separator").charAt(0));
   
           URL[] urls = new URL[names.length];
           try {
  @@ -302,7 +305,7 @@
             // I don't think this is possible, so I'm throwing this as an
             // un-checked exception
             throw (IllegalArgumentException) new IllegalArgumentException(
  -                  "Unable to parse classpath: " + classpath).initCause(e);
  +                  "Unable to parse classpath: " + classpath);
           }
   
           return new URLClassLoader(urls, parent);
  
  
  
  1.2       +61 -0     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringUtils.java	30 Nov 2003 07:20:05 -0000	1.1
  +++ StringUtils.java	1 Dec 2003 13:46:37 -0000	1.2
  @@ -55,8 +55,16 @@
   
   package org.apache.axis.utils;
   
  +import java.util.ArrayList;
  +import java.util.List;
  +
   public class StringUtils {
       /**
  +     * An empty immutable <code>String</code> array.
  +     */
  +    public static final String[] EMPTY_STRING_ARRAY = new String[0];
  +    
  +    /**
        * Tests if this string starts with the specified prefix (Ignoring whitespaces) 
        * @param prefix
        * @param string
  @@ -88,5 +96,58 @@
           if(index1 < length1 && index2 >= length2)
               return false;
           return true;
  +    }
  +
  +    /**
  +     * <p>Splits the provided text into an array, separator specified.
  +     * This is an alternative to using StringTokenizer.</p>
  +     *
  +     * <p>The separator is not included in the returned String array.
  +     * Adjacent separators are treated as one separator.</p>
  +     *
  +     * <p>A <code>null</code> input String returns <code>null</code>.</p>
  +     *
  +     * <pre>
  +     * StringUtils.split(null, *)         = null
  +     * StringUtils.split("", *)           = []
  +     * StringUtils.split("a.b.c", '.')    = ["a", "b", "c"]
  +     * StringUtils.split("a..b.c", '.')   = ["a", "b", "c"]
  +     * StringUtils.split("a:b:c", '.')    = ["a:b:c"]
  +     * StringUtils.split("a\tb\nc", null) = ["a", "b", "c"]
  +     * StringUtils.split("a b c", ' ')    = ["a", "b", "c"]
  +     * </pre>
  +     *
  +     * @param str  the String to parse, may be null
  +     * @param separatorChar  the character used as the delimiter,
  +     *  <code>null</code> splits on whitespace
  +     * @return an array of parsed Strings, <code>null</code> if null String
input
  +     */
  +    public static String[] split(String str, char separatorChar) {
  +        if (str == null) {
  +            return null;
  +        }
  +        int len = str.length();
  +        if (len == 0) {
  +            return EMPTY_STRING_ARRAY;
  +        }
  +        List list = new ArrayList();
  +        int i = 0, start = 0;
  +        boolean match = false;
  +        while (i < len) {
  +            if (str.charAt(i) == separatorChar) {
  +                if (match) {
  +                    list.add(str.substring(start, i));
  +                    match = false;
  +                }
  +                start = ++i;
  +                continue;
  +            }
  +            match = true;
  +            i++;
  +        }
  +        if (match) {
  +            list.add(str.substring(start, i));
  +        }
  +        return (String[]) list.toArray(new String[list.size()]);
       }
   }
  
  
  

Mime
View raw message