axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/utils JavaUtils.java
Date Fri, 08 Feb 2002 23:05:21 GMT
scheu       02/02/08 15:05:21

  Modified:    java/src/org/apache/axis/utils JavaUtils.java
  Log:
  Added the reverse of the getLoadableClassName called getTextClassName.
  
  Added support in convert() to convert between Hex/byte[] which among
  other things improves our interop.  (for echoHexBinary 4s4c returns
  the correct value but uses xsd:base64Binary which cause deserialization
  into a byte[].)
  
  Revision  Changes    Path
  1.27      +50 -0     xml-axis/java/src/org/apache/axis/utils/JavaUtils.java
  
  Index: JavaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- JavaUtils.java	8 Feb 2002 15:24:22 -0000	1.26
  +++ JavaUtils.java	8 Feb 2002 23:05:21 -0000	1.27
  @@ -69,6 +69,7 @@
   import java.util.Locale;
   import java.util.MissingResourceException;
   import java.util.ResourceBundle;
  +import org.apache.axis.encoding.Hex;
   
   /** Utility class to deal with Java language related issues, such
    * as type conversions.
  @@ -129,6 +130,16 @@
               argHeldType = getHolderValueType(arg.getClass());
           }
   
  +        // Convert between Axis special purpose Hex and byte[]
  +        if (arg instanceof Hex && 
  +            destClass == byte[].class) {
  +            return ((Hex) arg).getBytes();
  +        } else if (arg instanceof byte[] &&
  +                   destClass == Hex.class) {
  +            return new Hex((byte[]) arg);
  +        }
  +
  +
           // Return if no conversion is available
           if (!(arg instanceof List) && 
               ((destHeldType == null && argHeldType == null) ||
  @@ -319,6 +330,45 @@
           while (i > 0) {
               className = "[" + className;
               i = text.indexOf("]", i+1);
  +        }
  +        return className;
  +    }
  +
  +    /**
  +     * Converts text of the form
  +     * [LFoo to the Foo[]
  +     */
  +    public static String getTextClassName(String text) {
  +        if (text == null || 
  +            text.indexOf("[") != 0)
  +            return text;
  +        String className = "";
  +        int index = 0;
  +        while(index < text.length() &&
  +              text.charAt(index) == '[') {
  +            index ++;
  +            className += "[]";
  +        }
  +        if (index < text.length()) {
  +            if (text.charAt(index)== 'B')
  +                className = "byte" + className;
  +            else if (text.charAt(index) == 'C')
  +                className = "char" + className;
  +            else if (text.charAt(index) == 'D')
  +                className = "double" + className;
  +            else if (text.charAt(index) == 'F')
  +                className = "float" + className;
  +            else if (text.charAt(index) == 'I')
  +                className = "int" + className;
  +            else if (text.charAt(index) == 'J')
  +                className = "long" + className;
  +            else if (text.charAt(index) == 'S')
  +                className = "short" + className;
  +            else if (text.charAt(index) == 'Z')
  +                className = "boolean" + className;
  +            else {
  +                className = text.substring(index+1, text.indexOf(";")) + className;
  +            }
           }
           return className;
       }
  
  
  

Mime
View raw message