Hi there,

it turned out that using the TypeConvertor the conversion from String.class to Object.class would not be carried out, hence I added the appropriate statement in:

   org.apache.bsf.util.type.TypeConvertorRegistry.java

What follows is a "svn diff" which has the same format as a "diff -u". Most of the shown changes are reformat-changes, the only really new change is tagged with "// rgf, 2005-07-30" on the side:

--------------- cut here ---------------
--- TypeConvertorRegistry.java    2005-06-12 01:10:23.287972000 +0200
+++ tmp\TypeConvertorRegistry.java    2005-07-30 18:42:08.267929600 +0200
@@ -63,7 +63,7 @@
 * The <em>TypeConvertorRegistry</em> is the registry of type convertors.
 * It has lookup and register capabilities based on the types to be
 * converted as well as by some object key.
- *
+ *
 * @author   Sanjiva Weerawarana
 * @author   Matthew J. Duftler
 * @see      TypeConvertorRegistry
@@ -79,7 +79,7 @@
      public Object convert (Class from, Class to, Object obj) {
          return obj;
      }
- +
      public String getCodeGenString() {
        return "(Class from, Class to, Object obj) {\n" +
               "return obj;\n" +
@@ -102,6 +102,7 @@
    register (float.class, Float.class, tc);
    register (Double.class, double.class, tc);
    register (double.class, Double.class, tc);
+        register (String.class, Object.class, tc); // rgf, 2005-07-30

    // object to string: the registry special cases this one as the backup
    // if the target is string and there is no special convertor available
@@ -110,7 +111,7 @@
      public Object convert (Class from, Class to, Object obj) {
          return (obj == null) ? "(null)" : obj.toString ();
      }
- +
        public String getCodeGenString() {
        return "(Class from, Class to, Object obj) {\n" +
               "return (obj == null) ? \"(null)\" : obj.toString ();\n" +
@@ -118,7 +119,7 @@
        }
    };
    register (Object.class, String.class, tc);
- +
    // convert strings to various primitives (both their object versions
    // and wrappers for primitive versions)
    tc = new TypeConvertor () {
@@ -144,7 +145,7 @@
          return null;
        }
      }
- +
        public String getCodeGenString() {
        return "(Class from, Class to, Object obj) {\n" +
               "String str = (String) obj;\n" +
@@ -192,7 +193,7 @@
      public Object convert (Class from, Class to, Object obj) {
          return Font.decode ((String) obj);
      }
- +
      public String getCodeGenString() {
        return "(Class from, Class to, Object obj) {\n" +
               "return Font.decode ((String) obj);\n" +
@@ -206,7 +207,7 @@
      public Object convert (Class from, Class to, Object obj) {
          return Color.decode ((String) obj);
      }
- +
        public String getCodeGenString() {
        return "(Class from, Class to, Object obj) {\n" +
               "return Color.decode ((String) obj);\n" +
@@ -214,6 +215,7 @@
        }
    };
    register (String.class, Color.class, tc);
+
  }
  // lookup a convertor
  public TypeConvertor lookup (Class from, Class to) {
--------------- cut here ---------------

If no one objects, I will check it in in a week.

Regards,

---rony

Reply via email to