Ok, these are my comments.

First of all, I think this is on the right track, mostly.

The main thing I am thinking is that we should not change the public API
to include information about the user class, since this is a
code-generation hint, if you want (valuable nevertheless, same as the
extension interfaces feature). I feel like there's already too much Java
type information in the Schema API. What I would do is perhaps add one
more constant to SchemaProperty.java, say JAVA_USER (or JAVA_CUSTOM).
Other than that, I would not expose anything else. SchemaTypeImpl can of
course, still contain the extra methods (except for isUserType() and
setUserType(boolean) which are not needed). That should also save you
from having to make any changes to SchemaTypeSystemImpl at all.

In StscJavaizer.java, I would put the new code into its own method, to
keep the main loop simple.

In SchemaTypeCodePrinter.java, it seems that there should be a more
"compact" way to set the "user types", we can leave this for last.

Oh, and also, the Wiki presentation of the feature is great, but it's
missing a description of the methods in the handler class. I had to look
at the code to figure out that the method name is "encode/decode" +
unqualified name of the user type. Maybe encode/decode would suffice?
Anyway, it has to be documented.

Thank you for your effort,
Radu

On Tue, 2009-03-17 at 16:45 -0700, Radu Preotiuc wrote:
> Thanks, Wesley,
> 
> Right now I am in the middle of a different change, once I am done with
> that I will review this one. One thing that I can already say is that
> you should not have worried about changing the NS of the config file, if
> your change is just additive, we have taken the approach of keeping the
> NS the same.
> 
> Radu
> 
> On Sun, 2009-03-15 at 03:56 -0400, Wesley Leggette wrote:
> > # HG changeset patch
> > # User Wesley Leggette <wlegge...@cleversafe.com>
> > # Date 1237102712 18000
> > # Node ID e1f81e39f7c7384d1624f0d3a7ad54385c6eb071
> > # Parent  0ca486927c710176c119f85cffec2c793fdb7674
> > Added custom user type support.
> > 
> > diff -r 0ca486927c71 -r e1f81e39f7c7 src/configschema/schema/xmlconfig.xsd
> > --- a/src/configschema/schema/xmlconfig.xsd Sun Mar 15 02:01:12 2009 -0500
> > +++ b/src/configschema/schema/xmlconfig.xsd Sun Mar 15 02:38:32 2009 -0500
> > @@ -13,8 +13,8 @@
> >       limitations under the License. -->
> >  <xs:schema
> >     xmlns:xs="http://www.w3.org/2001/XMLSchema";
> > -   xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config";
> > -   targetNamespace="http://xml.apache.org/xmlbeans/2004/02/xbean/config";
> > +   xmlns:xb="http://xml.apache.org/xmlbeans/2009/03/xbean/config";
> > +   targetNamespace="http://xml.apache.org/xmlbeans/2009/03/xbean/config";
> >     elementFormDefault="qualified">
> >  
> >    <xs:import namespace="http://www.w3.org/2001/XMLSchema"/>
> > @@ -58,6 +58,15 @@
> >            </xs:annotation>
> >          </xs:element>
> >  
> > +        <xs:element name="usertype" type="xb:usertypeconfig">
> > +          <xs:annotation>
> > +              <xs:documentation>
> > +                  Specifies a custom java type mapping for a derived 
> > simple type.
> > +                  A static handler must be specified that converts between 
> > the
> > +                  custom java type and the built-in simple type it derives 
> > from.
> > +              </xs:documentation>
> > +          </xs:annotation>
> > +        </xs:element>
> >        </xs:choice>
> >      </xs:complexType>
> >    </xs:element>
> > @@ -172,6 +181,30 @@
> >      </xs:union>
> >     </xs:simpleType>
> >  
> > +    <xs:complexType name="usertypeconfig">
> > +       <xs:sequence>
> > +           <xs:choice>
> > +               <xs:element name="staticHandler" type="xs:string">
> > +                   <xs:annotation>
> > +                       <xs:documentation>
> > +                           The name of the handler class for this user 
> > type.
> > +                           The handler must contain public static methods 
> > for
> > +                           translating the user type to and from the 
> > derived simple type.
> > +                           Example:
> > +                           - qname example:uuid restricts xs:string
> > +                           - javaname is java.util.UUID
> > +                           - handler interface must have signatures:
> > +                                public String encodeUuid(UUID obj)
> > +                                public UUID decodeUuid(String enc)
> > +                       </xs:documentation>
> > +                   </xs:annotation>
> > +               </xs:element>
> > +           </xs:choice>
> > +       </xs:sequence>
> > +       <xs:attribute name="name" type="xs:QName"/>
> > +       <xs:attribute name="javaname" type="xs:string"/>
> > +    </xs:complexType>
> > +
> >      <xs:complexType name="extensionconfig">
> >         <xs:sequence>
> >            <xs:element name="interface" minOccurs="0" maxOccurs="unbounded" 
> > >
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/configschema/schema/xmlconfig.xsdconfig
> > --- a/src/configschema/schema/xmlconfig.xsdconfig   Sun Mar 15 02:01:12 
> > 2009 -0500
> > +++ b/src/configschema/schema/xmlconfig.xsdconfig   Sun Mar 15 02:38:32 
> > 2009 -0500
> > @@ -10,7 +10,7 @@
> >       limitations under the License. -->
> >  <xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config";>
> >  
> > -  <xb:namespace uri="http://xml.apache.org/xmlbeans/2004/02/xbean/config";>
> > +  <xb:namespace uri="http://xml.apache.org/xmlbeans/2009/03/xbean/config";>
> >      <xb:package>org.apache.xmlbeans.impl.xb.xmlconfig</xb:package>
> >    </xb:namespace>
> >  
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java
> > --- 
> > a/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java   
> >     Sun Mar 15 02:01:12 2009 -0500
> > +++ 
> > b/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeCodePrinter.java   
> >     Sun Mar 15 02:38:32 2009 -0500
> > @@ -17,6 +17,7 @@
> >  
> >  import java.io.Writer;
> >  import java.io.IOException;
> > +import java.lang.reflect.InvocationTargetException;
> >  import java.nio.charset.CharacterCodingException;
> >  import java.nio.charset.Charset;
> >  import java.nio.charset.CharsetEncoder;
> > @@ -1011,12 +1012,19 @@
> >  
> >      String javaTypeForProperty(SchemaProperty sProp)
> >      {
> > +           // TODO: This is where to insert handler-specific type
> > +
> >          // The type to use is the XML object....
> >          if (sProp.getJavaTypeCode() == SchemaProperty.XML_OBJECT)
> >          {
> >              SchemaType sType = sProp.javaBasedOnType();
> >              return findJavaType(sType).replace('$', '.');
> >          }
> > +
> > +        if (sProp.getType().isUserType())
> > +        {
> > +           return sProp.getType().getUserTypeName();
> > +        }
> >  
> >          switch (sProp.getJavaTypeCode())
> >          {
> > @@ -1635,6 +1643,19 @@
> >              emit("return target.getObjectValue();"); break;
> >          }
> >      }
> > +
> > +    private void printJGetUserTypeValue(String propertyName, SchemaType 
> > type)
> > +           throws IOException
> > +    {
> > +           emit("return (" + type.getUserTypeName() + ") 
> > userTypeGetterHelper(target);");
> > +   }
> > +
> > +    private void printJSetUserTypeValue(String safeVarName, SchemaType 
> > type)
> > +           throws IOException
> > +   {
> > +           emit("userTypeSetterHelper(" + safeVarName + ", target, " +
> > +                           type.getUserTypeName() + ".class);");
> > +   }
> >  
> >      String jsetMethod(int javaType) throws IOException
> >      {
> > @@ -1868,6 +1889,8 @@
> >                         String xtype)
> >          throws IOException
> >      {
> > +           // TODO: THIS IS WHERE TO PUT EXTERNAL GET TARGET HANDLER
> > +
> >          assert setIdentifier != null && identifier != null;
> >  
> >          emit(xtype + " target = null;");
> > @@ -1986,6 +2009,8 @@
> >          boolean xmltype = (javaType == SchemaProperty.XML_OBJECT);
> >          String jtargetType = (isunion || !xmltype) ? 
> > "org.apache.xmlbeans.SimpleValue" : xtype;
> >  
> > +        // TODO: there is if(singleton), if(optional), etc. Maybe a 
> > if(external_handler)?
> > +
> >          if (singleton)
> >          {
> >              // Value getProp()
> > @@ -2009,8 +2034,15 @@
> >              makeMissingValue(javaType);
> >              endBlock();
> >  
> > -
> > -            printJGetValue(javaType, type);
> > +            if (prop.getType().isUserType())
> > +            {
> > +                   printJGetUserTypeValue(propertyName, prop.getType());
> > +            }
> > +            else
> > +            {
> > +                   printJGetValue(javaType, type);
> > +            }
> > +
> >  
> >              emitImplementationPostamble();
> >  
> > @@ -2023,6 +2055,7 @@
> >                  emit("public " + xtype + " xget" + propertyName + "()");
> >                  startBlock();
> >                  emitImplementationPreamble();
> > +                // TODO: This is where we could choose to emit a get 
> > handler target instead
> >                  emitGetTarget(setIdentifier, identifier, isAttr, "0", 
> > NOTHING, xtype);
> >  
> >                  if (isAttr && (prop.hasDefault() == 
> > SchemaProperty.CONSISTENTLY ||
> > @@ -2046,6 +2079,7 @@
> >                  emit("public boolean isNil" + propertyName + "()");
> >                  startBlock();
> >                  emitImplementationPreamble();
> > +                // TODO: This is where we could choose to emit a get 
> > handler target instead
> >                  emitGetTarget(setIdentifier, identifier, isAttr, "0", 
> > NOTHING, xtype);
> >  
> >                  emit("if (target == null) return false;");
> > @@ -2194,7 +2228,7 @@
> >          }
> >      }
> >  
> > -    void printSetterImpls(QName qName, boolean isAttr,
> > +   void printSetterImpls(QName qName, SchemaProperty prop, boolean isAttr,
> >                         String propertyName, int javaType, String type, 
> > String xtype,
> >                         boolean nillable, boolean optional, boolean 
> > several, boolean singleton,
> >                         boolean isunion, String identifier, String 
> > setIdentifier, SchemaType sType)
> > @@ -2227,6 +2261,15 @@
> >                          
> > "org.apache.xmlbeans.impl.values.XmlObjectBase.KIND_SETTERHELPER_SINGLETON);");
> >                  emitPost(sType, PrePostExtension.OPERATION_SET, 
> > identifier, isAttr, several ? "0" : "-1");
> >              }
> > +            else if (prop.getType().isUserType())
> > +            {
> > +                emitImplementationPreamble();
> > +                emitPre(sType, PrePostExtension.OPERATION_SET, identifier, 
> > isAttr, several ? "0" : "-1");
> > +                emitGetTarget(setIdentifier, identifier, isAttr, "0", 
> > ADD_NEW_VALUE, jtargetType);
> > +                printJSetUserTypeValue(safeVarName, prop.getType());
> > +                emitPost(sType, PrePostExtension.OPERATION_SET, 
> > identifier, isAttr, several ? "0" : "-1");
> > +                emitImplementationPostamble();
> > +            }
> >              else
> >              {
> >                  emitImplementationPreamble();
> > @@ -2602,6 +2645,7 @@
> >                  {
> >                      printSetterImpls(
> >                          name,
> > +                        prop,
> >                          prop.isAttribute(),
> >                          prop.getJavaPropertyName(),
> >                          prop.getJavaTypeCode(),
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
> > --- a/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java      
> > Sun Mar 15 02:01:12 2009 -0500
> > +++ b/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java      
> > Sun Mar 15 02:38:32 2009 -0500
> > @@ -100,6 +100,8 @@
> >      private volatile Constructor _javaImplConstructor;
> >      private volatile Constructor _javaImplConstructor2;
> >      private volatile boolean _implNotAvailable;
> > +    private volatile Class _userTypeClass;
> > +    private volatile Class _userTypeHandlerClass;
> >  
> >      // user data objects not persisted
> >      private volatile Object _userData;
> > @@ -140,6 +142,11 @@
> >      private int _baseDepth; // how many inheritance steps to AnyType
> >      private int _derivationType;
> >  
> > +    // user type support
> > +    private boolean _isUserType;
> > +    private String _userTypeName;
> > +    private String _userTypeHandler;
> > +
> >      // for complex types with simple content
> >      private SchemaType.Ref _contentBasedOnTyperef;
> >  
> > @@ -577,7 +584,39 @@
> >      public String getFullJavaImplName() { return _fullJavaImplName;}
> >      public String getShortJavaImplName() { return _shortJavaImplName;}
> >  
> > -    public void setInterfaceExtensions(InterfaceExtension[] interfaces)
> > +    public String getUserTypeName()
> > +    {
> > +           return _userTypeName;
> > +    }
> > +
> > +    public void setUserTypeName(String userTypeName)
> > +    {
> > +           _userTypeName = userTypeName;
> > +    }
> > +
> > +    public boolean isUserType()
> > +    {
> > +           return _isUserType;
> > +   }
> > +
> > +   public void setUserType(boolean userType)
> > +   {
> > +           _isUserType = userType;
> > +   }
> > +
> > +   public String getUserTypeHandlerName()
> > +   {
> > +           return _userTypeHandler;
> > +   }
> > +
> > +   public void setUserTypeHandlerName(String typeHandler)
> > +   {
> > +           _userTypeHandler = typeHandler;
> > +   }
> > +
> > +
> > +
> > +   public void setInterfaceExtensions(InterfaceExtension[] interfaces)
> >      {
> >          assertResolved();
> >          _interfaces = interfaces;
> > @@ -1717,6 +1756,46 @@
> >  
> >          return _javaImplClass;
> >      }
> > +
> > +   public Class getUserTypeClass()
> > +   {
> > +           // This field is declared volatile and Class is immutable so 
> > this is
> > +           // allowed.
> > +           if (_userTypeClass == null && getUserTypeName() != null)
> > +           {
> > +                   try
> > +                   {
> > +                           _userTypeClass = Class.forName(_userTypeName, 
> > false,
> > +                                           
> > getTypeSystem().getClassLoader());
> > +                   }
> > +                   catch (ClassNotFoundException e)
> > +                   {
> > +                           _userTypeClass = null;
> > +                   }
> > +           }
> > +
> > +           return _userTypeClass;
> > +   }
> > +
> > +   public Class getUserTypeHandlerClass()
> > +   {
> > +           // This field is declared volatile and Class is immutable so 
> > this is
> > +           // allowed.
> > +           if (_userTypeHandlerClass == null && getUserTypeHandlerName() 
> > != null)
> > +           {
> > +                   try
> > +                   {
> > +                           _userTypeHandlerClass = 
> > Class.forName(_userTypeHandler, false,
> > +                                           
> > getTypeSystem().getClassLoader());
> > +                   }
> > +                   catch (ClassNotFoundException e)
> > +                   {
> > +                           _userTypeHandlerClass = null;
> > +                   }
> > +           }
> > +
> > +           return _userTypeHandlerClass;
> > +   }
> >  
> >      public Constructor getJavaImplConstructor()
> >      {
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
> > --- 
> > a/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java    
> >     Sun Mar 15 02:01:12 2009 -0500
> > +++ 
> > b/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java    
> >     Sun Mar 15 02:38:32 2009 -0500
> > @@ -81,7 +81,7 @@
> >  {
> >      public static final int DATA_BABE = 0xDA7ABABE;
> >      public static final int MAJOR_VERSION = 2;  // must match == to be 
> > compatible
> > -    public static final int MINOR_VERSION = 24; // must be <= to be 
> > compatible
> > +    public static final int MINOR_VERSION = 25; // must be <= to be 
> > compatible
> >      public static final int RELEASE_NUMBER = 0; // should be compatible 
> > even if < or >
> >  
> >      public static final int FILETYPE_SCHEMAINDEX = 1;
> > @@ -134,6 +134,7 @@
> >      static final int FLAG_FINAL_LIST      = 0x20000;
> >      static final int FLAG_ABSTRACT        = 0x40000;
> >      static final int FLAG_ATTRIBUTE_TYPE  = 0x80000;
> > +    static final int FLAG_USER_TYPE       = 0x100000;
> >  
> >      /**
> >       * This is to support the feature of a separate/private XMLBeans
> > @@ -2504,6 +2505,7 @@
> >                  impl.setDocumentType((flags & FLAG_DOCUMENT_TYPE) != 0);
> >                  impl.setAttributeType((flags & FLAG_ATTRIBUTE_TYPE) != 0);
> >                  impl.setSimpleType(!isComplexType);
> > +                impl.setUserType((flags & FLAG_USER_TYPE) != 0);
> >  
> >                  int complexVariety = SchemaType.NOT_COMPLEX_TYPE;
> >                  if (isComplexType)
> > @@ -2688,7 +2690,13 @@
> >                          impl.setContainer(container);
> >                      }
> >                  }
> > -
> > +
> > +                if (impl.isUserType())
> > +                {
> > +                   impl.setUserTypeName(readString());
> > +                   impl.setUserTypeHandlerName(readString());
> > +                }
> > +
> >                  return impl;
> >              }
> >              catch (SchemaTypeLoaderException e)
> > @@ -2777,6 +2785,9 @@
> >                  flags |= FLAG_FINAL_UNION;
> >              if (type.isAbstract())
> >                  flags |= FLAG_ABSTRACT;
> > +
> > +            if (type.isUserType())
> > +                   flags |= FLAG_USER_TYPE;
> >  
> >              writeInt(flags);
> >  
> > @@ -2893,6 +2904,13 @@
> >              }
> >  
> >              writeString(type.getSourceName());
> > +
> > +            // new for version 2.25
> > +            if (type.isUserType())
> > +            {
> > +                   writeString(type.getUserTypeName());
> > +                   writeString(type.getUserTypeHandlerName());
> > +            }
> >          }
> >  
> >          void readExtensionsList()
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java
> > --- a/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java        
> > Sun Mar 15 02:01:12 2009 -0500
> > +++ b/src/typeimpl/org/apache/xmlbeans/impl/schema/StscJavaizer.java        
> > Sun Mar 15 02:38:32 2009 -0500
> > @@ -22,6 +22,7 @@
> >  import org.apache.xmlbeans.SchemaParticle;
> >  import org.apache.xmlbeans.SchemaProperty;
> >  import org.apache.xmlbeans.QNameSet;
> > +import org.apache.xmlbeans.UserType;
> >  import org.apache.xmlbeans.XmlAnySimpleType;
> >  import org.apache.xmlbeans.SchemaStringEnumEntry;
> >  import org.apache.xmlbeans.XmlByte;
> > @@ -98,6 +99,15 @@
> >              {
> >                  sImpl.setFullJavaName(pickFullJavaClassName(usedNames, 
> > findTopName(sImpl), pickedName, sImpl.isDocumentType(), 
> > sImpl.isAttributeType()));
> >                  sImpl.setFullJavaImplName(pickFullJavaImplName(usedNames, 
> > sImpl.getFullJavaName()));
> > +
> > +                UserType utype = 
> > StscState.get().getBindingConfig().lookupUserTypeForQName(sImpl.getName());
> > +                if (utype != null)
> > +                {
> > +                    sImpl.setUserType(true);
> > +                    sImpl.setUserTypeName(utype.getJavaName());
> > +                    sImpl.setUserTypeHandlerName(utype.getStaticHandler());
> > +                }
> > +
> >                  setExtensions(sImpl, state);
> >              }
> >          }
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/typeimpl/org/apache/xmlbeans/impl/values/XmlComplexContentImpl.java
> > --- 
> > a/src/typeimpl/org/apache/xmlbeans/impl/values/XmlComplexContentImpl.java   
> >     Sun Mar 15 02:01:12 2009 -0500
> > +++ 
> > b/src/typeimpl/org/apache/xmlbeans/impl/values/XmlComplexContentImpl.java   
> >     Sun Mar 15 02:38:32 2009 -0500
> > @@ -161,6 +161,70 @@
> >          }
> >      }
> >  
> > +    protected Object userTypeGetterHelper(SimpleValue target)
> > +    {
> > +        try
> > +        {
> > +            Class clazz = Class.forName(
> > +                           schemaType().getUserTypeHandlerName());
> > +            java.lang.reflect.Method method = clazz.getMethod(
> > +                           "decode" + schemaType().getShortJavaName(),
> > +                           new 
> > Class[]{org.apache.xmlbeans.SimpleValue.class});
> > +            return method.invoke(null, new Object[]{target});
> > +        }
> > +        catch (java.lang.ClassNotFoundException e)
> > +        {
> > +            throw new IllegalStateException(
> > +                           "User type handler class does not exist", e);
> > +        }
> > +        catch (java.lang.NoSuchMethodException e)
> > +        {
> > +            throw new IllegalStateException(
> > +                           "User type handler does not have proper decode 
> > method", e);
> > +        }
> > +        catch (java.lang.IllegalAccessException e)
> > +        {
> > +            throw new IllegalStateException(e);
> > +        }
> > +        catch (java.lang.reflect.InvocationTargetException e)
> > +        {
> > +            throw new IllegalStateException(
> > +                           "Error getting element", 
> > e.getTargetException());
> > +        }
> > +    }
> > +
> > +    protected void userTypeSetterHelper(Object object, SimpleValue target,
> > +                   Class targetClass)
> > +    {
> > +
> > +        try
> > +        {
> > +            Class clazz = Class.forName(
> > +                           schemaType().getUserTypeHandlerName());
> > +            java.lang.reflect.Method method = clazz.getMethod(
> > +                           "encode" + schemaType().getShortJavaName(),
> > +                           new Class[]{targetClass,
> > +                                   org.apache.xmlbeans.SimpleValue.class});
> > +            method.invoke(null, new Object[]{object, target});
> > +        }
> > +        catch (java.lang.ClassNotFoundException e)
> > +        {
> > +            throw new IllegalStateException("User type handler class does 
> > not exist", e);
> > +        }
> > +        catch (java.lang.NoSuchMethodException e)
> > +        {
> > +            throw new IllegalStateException("User type handler does not 
> > have proper decode method", e);
> > +        }
> > +        catch (java.lang.IllegalAccessException e)
> > +        {
> > +            throw new IllegalStateException(e);
> > +        }
> > +        catch (java.lang.reflect.InvocationTargetException e)
> > +        {
> > +            throw new IllegalStateException("Error getting element", 
> > e.getTargetException());
> > +        }
> > +    }
> > +
> >      protected void arraySetterHelper ( boolean[] sources, QName elemName )
> >      {
> >          int n = sources == null ? 0 : sources.length;
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
> > --- a/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java Sun Mar 
> > 15 02:01:12 2009 -0500
> > +++ b/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java Sun Mar 
> > 15 02:38:32 2009 -0500
> > @@ -1258,12 +1258,14 @@
> >          return false;
> >      }
> >  
> > -    private static final String CONFIG_URI = 
> > "http://xml.apache.org/xmlbeans/2004/02/xbean/config";;
> > -    private static final String COMPATIBILITY_CONFIG_URI = 
> > "http://www.bea.com/2002/09/xbean/config";;
> > +    private static final String CONFIG_URI = 
> > "http://xml.apache.org/xmlbeans/2009/03/xbean/config";;
> > +    private static final String COMPATIBILITY_CONFIG_URI = 
> > "http://xml.apache.org/xmlbeans/2004/02/xbean/config";;
> > +    private static final String COMPATIBILITY_CONFIG_URI2 = 
> > "http://www.bea.com/2002/09/xbean/config";;
> >      private static final Map MAP_COMPATIBILITY_CONFIG_URIS;
> >      static
> >      {
> >          MAP_COMPATIBILITY_CONFIG_URIS = new HashMap();
> >          MAP_COMPATIBILITY_CONFIG_URIS.put(COMPATIBILITY_CONFIG_URI, 
> > CONFIG_URI);
> > +        MAP_COMPATIBILITY_CONFIG_URIS.put(COMPATIBILITY_CONFIG_URI2, 
> > CONFIG_URI);
> >      }
> >  }
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/xmlconfig/org/apache/xmlbeans/impl/config/BindingConfigImpl.java
> > --- a/src/xmlconfig/org/apache/xmlbeans/impl/config/BindingConfigImpl.java  
> > Sun Mar 15 02:01:12 2009 -0500
> > +++ b/src/xmlconfig/org/apache/xmlbeans/impl/config/BindingConfigImpl.java  
> > Sun Mar 15 02:38:32 2009 -0500
> > @@ -20,7 +20,9 @@
> >  import org.apache.xmlbeans.impl.xb.xmlconfig.Nsconfig;
> >  import org.apache.xmlbeans.impl.xb.xmlconfig.Qnameconfig;
> >  import org.apache.xmlbeans.impl.xb.xmlconfig.Qnametargetenum;
> > +import org.apache.xmlbeans.impl.xb.xmlconfig.Usertypeconfig;
> >  import org.apache.xmlbeans.BindingConfig;
> > +import org.apache.xmlbeans.UserType;
> >  import org.apache.xmlbeans.XmlObject;
> >  import org.apache.xmlbeans.XmlError;
> >  import org.apache.xmlbeans.InterfaceExtension;
> > @@ -54,6 +56,7 @@
> >  
> >      private List _interfaceExtensions;
> >      private List _prePostExtensions;
> > +    private List _userTypes;
> >  
> >      private BindingConfigImpl()
> >      {
> > @@ -69,6 +72,7 @@
> >          _qnameAttMap = Collections.EMPTY_MAP;
> >          _interfaceExtensions = new ArrayList();
> >          _prePostExtensions = new ArrayList();
> > +        _userTypes = new ArrayList();
> >      }
> >  
> >      public static BindingConfig forConfigDocuments(Config[] configs, 
> > File[] javaFiles, File[] classpath)
> > @@ -90,6 +94,7 @@
> >          _qnameAttMap = new LinkedHashMap();
> >          _interfaceExtensions = new ArrayList();
> >          _prePostExtensions = new ArrayList();
> > +        _userTypes = new ArrayList();
> >  
> >          for (int i = 0; i < configs.length; i++)
> >          {
> > @@ -137,6 +142,13 @@
> >              {
> >                  recordExtensionSetting(javaFiles, classpath, ext[j]);
> >              }
> > +
> > +            Usertypeconfig[] utypes = config.getUsertypeArray();
> > +            for (int j = 0; j < utypes.length; j++)
> > +            {
> > +                JamClassLoader jamLoader = getJamLoader(javaFiles, 
> > classpath);
> > +                   _userTypes.add(UserTypeImpl.newInstance(jamLoader, 
> > utypes[j]));
> > +            }
> >          }
> >  
> >          secondPhaseValidation();
> > @@ -354,6 +366,7 @@
> >  
> >      public String lookupJavanameForQName(QName qname, int kind)
> >      {
> > +           // TODO: Want to return user type java name if applicable
> >          switch (kind)
> >          {
> >          case QNAME_TYPE:
> > @@ -367,6 +380,28 @@
> >          }
> >          return null;
> >      }
> > +
> > +
> > +    public UserType lookupUserTypeForQName(QName qname)
> > +    {
> > +        if (qname == null)
> > +            return null;
> > +
> > +        for (Iterator i = _userTypes.iterator(); i.hasNext();)
> > +        {
> > +            UserType utype = (UserType) i.next();
> > +            if (qname.equals(utype.getName()))
> > +                return utype;
> > +        }
> > +
> > +        return null;
> > +    }
> > +
> > +    public UserType[] getUserTypes()
> > +    {
> > +        return (UserType[]) _interfaceExtensions
> > +                .toArray(new UserType[_interfaceExtensions.size()]);
> > +    }
> >  
> >      public InterfaceExtension[] getInterfaceExtensions()
> >      {
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/xmlconfig/org/apache/xmlbeans/impl/config/UserTypeImpl.java
> > --- /dev/null       Thu Jan 01 00:00:00 1970 +0000
> > +++ b/src/xmlconfig/org/apache/xmlbeans/impl/config/UserTypeImpl.java       
> > Sun Mar 15 02:38:32 2009 -0500
> > @@ -0,0 +1,46 @@
> > +package org.apache.xmlbeans.impl.config;
> > +
> > +import javax.xml.namespace.QName;
> > +
> > +import org.apache.xmlbeans.UserType;
> > +import org.apache.xmlbeans.impl.jam.JamClassLoader;
> > +import org.apache.xmlbeans.impl.xb.xmlconfig.Usertypeconfig;
> > +
> > +public class UserTypeImpl implements UserType {
> > +
> > +   private QName _name;
> > +   private String _javaName;
> > +   private String _staticHandler;
> > +
> > +
> > +   static UserTypeImpl newInstance(JamClassLoader loader, Usertypeconfig 
> > cfgXO)
> > +   {
> > +           UserTypeImpl result = new UserTypeImpl();
> > +
> > +           result._name = cfgXO.getName();
> > +           result._javaName = cfgXO.getJavaname();
> > +           result._staticHandler = cfgXO.getStaticHandler();
> > +
> > +           // We don't validate here because we're just using reflection in
> > +           // the implementation. However, in the future we might want to 
> > add
> > +           // the option of directly using the static handler in generated 
> > code
> > +
> > +           return result;
> > +   }
> > +
> > +
> > +   public String getJavaName()
> > +   {
> > +           return _javaName;
> > +   }
> > +
> > +   public QName getName() {
> > +           return _name;
> > +   }
> > +
> > +   public String getStaticHandler() {
> > +           return _staticHandler;
> > +   }
> > +
> > +
> > +}
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/xmlpublic/org/apache/xmlbeans/BindingConfig.java
> > --- a/src/xmlpublic/org/apache/xmlbeans/BindingConfig.java  Sun Mar 15 
> > 02:01:12 2009 -0500
> > +++ b/src/xmlpublic/org/apache/xmlbeans/BindingConfig.java  Sun Mar 15 
> > 02:38:32 2009 -0500
> > @@ -27,6 +27,7 @@
> >  {
> >      private static final InterfaceExtension[] EMPTY_INTERFACE_EXT_ARRAY = 
> > new InterfaceExtension[0];
> >      private static final PrePostExtension[] EMPTY_PREPOST_EXT_ARRAY = new 
> > PrePostExtension[0];
> > +    private static final UserType[] EMPTY_USER_TYPE_ARRY = new UserType[0];
> >  
> >      public static final int QNAME_TYPE = 1;
> >      public static final int QNAME_DOCUMENT_TYPE = 2;
> > @@ -84,5 +85,16 @@
> >       * type generated from schema compilation or null.
> >       */
> >      public PrePostExtension getPrePostExtension(String fullJavaName) { 
> > return null; }
> > +
> > +    /**
> > +     * Returns all defined user types.
> > +     */
> > +    public UserType[] getUserTypes() { return EMPTY_USER_TYPE_ARRY; }
> > +
> > +    /**
> > +     * Returns a user defined Java type for a given QName.
> > +     */
> > +    public UserType lookupUserTypeForQName(QName qname) { return null; }
> > +
> >  
> >  }
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/xmlpublic/org/apache/xmlbeans/SchemaType.java
> > --- a/src/xmlpublic/org/apache/xmlbeans/SchemaType.java     Sun Mar 15 
> > 02:01:12 2009 -0500
> > +++ b/src/xmlpublic/org/apache/xmlbeans/SchemaType.java     Sun Mar 15 
> > 02:38:32 2009 -0500
> > @@ -244,6 +244,38 @@
> >       * True for the anySimpleType and any restrictions/unions/lists.
> >       */
> >      public abstract boolean isSimpleType();
> > +
> > +    /**
> > +     * True if {...@link #isSimpleType()} and the .xsdconfig file 
> > specifies a
> > +     * user-defined Java type translation handler.
> > +     */
> > +    public abstract boolean isUserType();
> > +
> > +    /**
> > +     * Returns the user-defined Java class name if {...@link 
> > #isUserType()} is
> > +     * true. This is the type that will be used for convenience accessers.
> > +     * Actual translation between this type and the {...@link 
> > #getJavaClass()}
> > +     * type is done by the handler class indicated by
> > +     * {...@link #getUserTypeHandlerClass()}.
> > +     */
> > +    public String getUserTypeName();
> > +
> > +    /**
> > +     * Returns the class object indicated by {...@link #getUserTypeName()}.
> > +     */
> > +    public Class getUserTypeClass();
> > +
> > +    /**
> > +     * Returns the class name of the Java type translaction handler 
> > specified
> > +     * in the .xsdconfig file. This is only applicable if {...@link 
> > #isUserType()}
> > +     * is true.
> > +     */
> > +    public String getUserTypeHandlerName();
> > +
> > +    /**
> > +     * Returns the class object indicated by {...@link 
> > #getUserTypeHandlerName()}.
> > +     */
> > +    public Class getUserTypeHandlerClass();
> >  
> >      /**
> >       * Returns base restriction or extension type. Unions and lists
> > diff -r 0ca486927c71 -r e1f81e39f7c7 
> > src/xmlpublic/org/apache/xmlbeans/UserType.java
> > --- /dev/null       Thu Jan 01 00:00:00 1970 +0000
> > +++ b/src/xmlpublic/org/apache/xmlbeans/UserType.java       Sun Mar 15 
> > 02:38:32 2009 -0500
> > @@ -0,0 +1,13 @@
> > +package org.apache.xmlbeans;
> > +
> > +import javax.xml.namespace.QName;
> > +
> > +public interface UserType {
> > +
> > +   QName getName();
> > +
> > +   String getJavaName();
> > +
> > +   String getStaticHandler();
> > +
> > +}
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org
> > For additional commands, e-mail: dev-h...@xmlbeans.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org
> For additional commands, e-mail: dev-h...@xmlbeans.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: dev-h...@xmlbeans.apache.org

Reply via email to