xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From david...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema BuiltinSchemaTypeSystem.java SchemaTypeImpl.java
Date Thu, 11 Dec 2003 19:32:54 GMT
davidbau    2003/12/11 11:32:54

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        PathBindingLoader.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        Both2Bind.java Both2BindTask.java
                        SimpleTypeMatcher.java TypeMatcher.java
               v2/src/typeimpl/org/apache/xmlbeans/impl/schema
                        BuiltinSchemaTypeSystem.java SchemaTypeImpl.java
  Log:
  (1) Adding a "typeMatcher" to the Both2Bind task, to make it more configurable
  (2) Fix a bad break introduced in a recent checkin with XmlName->XmlTypeName
  (3) Added the ability for a Both2Bind typeMatcher to be able to substitute an actual class-to-instantiate
for a declared-class-of-a-property.
  
  review: pcal (needed)
  DRT: passed
  
  Revision  Changes    Path
  1.6       +2 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/PathBindingLoader.java
  
  Index: PathBindingLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/PathBindingLoader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PathBindingLoader.java	4 Dec 2003 21:14:55 -0000	1.5
  +++ PathBindingLoader.java	11 Dec 2003 19:32:54 -0000	1.6
  @@ -225,6 +225,8 @@
           {
               for (int i = 0; i < jarsOrDirs.length; i++)
               {
  +                if (!jarsOrDirs[i].exists())
  +                    continue; // skip parts of the claspath which do not exist
                   FileResourceLoader rl = new FileResourceLoader(jarsOrDirs[i]);
                   InputStream resource = rl.getResourceAsStream(STANDARD_PATH);
                   files.add(BindingFile.forDoc(BindingConfigDocument.Factory.parse(resource)));
  
  
  
  1.2       +4 -2      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Both2Bind.java
  
  Index: Both2Bind.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Both2Bind.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Both2Bind.java	9 Dec 2003 17:25:16 -0000	1.1
  +++ Both2Bind.java	11 Dec 2003 19:32:54 -0000	1.2
  @@ -84,8 +84,6 @@
   import java.util.Set;
   import java.util.HashSet;
   import java.math.BigInteger;
  -import java.io.OutputStream;
  -import java.io.IOException;
   
   public class Both2Bind implements BindingFileResult
   {
  @@ -658,6 +656,10 @@
                       jPropType = jPropType.getArrayComponentType();
                   }
               }
  +            
  +            // A matcher can say that a declared type is "really" another type.
  +            // The normal matcher just returns the same thing back.
  +            jPropType = matcher.substituteClass(jPropType);
               
               // Queues the binding type for this property for processing if needed
               BindingType bType = bindingTypeForMatchedTypes(jPropType, sPropType, matchedProperties[i]);
  
  
  
  1.2       +19 -1     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Both2BindTask.java
  
  Index: Both2BindTask.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Both2BindTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Both2BindTask.java	9 Dec 2003 17:25:16 -0000	1.1
  +++ Both2BindTask.java	11 Dec 2003 19:32:54 -0000	1.2
  @@ -62,6 +62,7 @@
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.xmlbeans.XmlException;
  +import org.apache.xmlbeans.XmlOptions;
   
   import java.io.File;
   import java.io.IOException;
  @@ -79,6 +80,7 @@
       private Path mClasspath = null;
       private List mXsdFiles = null;
       private List mJavaFiles = null;
  +    private String mTypeMatcherClass = null;
   
       // =========================================================================
       // Task attributes
  @@ -100,6 +102,15 @@
               mSrc.append(srcDir);
           }
       }
  +    
  +    /**
  +     * Sets the typematcher class name.  Must be a fully-qualified
  +     * class name for a class that implements the TypeMatcher interface.
  +     */
  +    public void setTypeMatcher(String typeMatcher)
  +    {
  +        mTypeMatcherClass = typeMatcher;
  +    }
   
       /**
        * Adds a path for source compilation.
  @@ -219,7 +230,14 @@
           }
           
           TylarBuilder tb = new ExplodedTylarBuilder(mDestDir);
  -        BindingFileResult result = Both2Bind.bind(input, null);
  +        XmlOptions opts = null;
  +        if (mTypeMatcherClass != null)
  +        {
  +            opts = new XmlOptions();
  +            opts.put(Both2Bind.TYPE_MATCHER, mTypeMatcherClass);
  +            System.out.println("Got matcher class " + mTypeMatcherClass);
  +        }
  +        BindingFileResult result = Both2Bind.bind(input, opts);
   
           try {
               tb.buildTylar(result);
  
  
  
  1.2       +5 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/SimpleTypeMatcher.java
  
  Index: SimpleTypeMatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/SimpleTypeMatcher.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleTypeMatcher.java	4 Dec 2003 21:14:55 -0000	1.1
  +++ SimpleTypeMatcher.java	11 Dec 2003 19:32:54 -0000	1.2
  @@ -135,7 +135,11 @@
           
           return (MatchedProperties[])result.toArray(new MatchedProperties[result.size()]);
       }
  -    
  +
  +    public JClass substituteClass(JClass declaredClass) {
  +        return declaredClass;
  +    }
  +
       public void startMatch()
       {
           mapByShortName.clear();
  
  
  
  1.2       +30 -19    xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/TypeMatcher.java
  
  Index: TypeMatcher.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/TypeMatcher.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeMatcher.java	4 Dec 2003 21:14:55 -0000	1.1
  +++ TypeMatcher.java	11 Dec 2003 19:32:54 -0000	1.2
  @@ -64,6 +64,36 @@
   
   public interface TypeMatcher
   {
  +    /**
  +     * Returns a collection of MatchedTypes, advising which
  +     * Java classes and which Schema types should be matched
  +     * with each other.  Not every class or type needs to be
  +     * matched by the matcher.  Any remaining ones will be
  +     * dealt with automatically if possible, and warnings
  +     * will be produced for any types that are not covered.
  +     */ 
  +    MatchedType[] matchTypes(BothSourceSet bss);
  +    
  +    /**
  +     * Returns a collection of MatchedProperties, advising which
  +     * Java properties and Schema properties (elements or
  +     * attributes) should be matched with each other.
  +     * Any properties not returned here will not be bound.
  +     * It is acceptable to rebind properties that were already
  +     * bound in a base class. Conflicts will result in an error.
  +     */ 
  +    MatchedProperties[] matchProperties(JClass jClass, SchemaType sType);
  +
  +    /**
  +     * Substitutes a class-to-bind for a declared-class seen.
  +     * This is used when, for example, an interface is used to
  +     * always stand in for a specific implementation class.  In
  +     * reality, it is the implementation class which is being
  +     * bound, but all the declared properties have types corresponding
  +     * to the interface.
  +     */
  +    JClass substituteClass(JClass declaredClass);
  +    
       public static class MatchedType
       {
           private JClass jClass;
  @@ -106,25 +136,6 @@
               return result;
           }
       }
  -    /**
  -     * Returns a collection of MatchedTypes, advising which
  -     * Java classes and which Schema types should be matched
  -     * with each other.  Not every class or type needs to be
  -     * matched by the matcher.  Any remaining ones will be
  -     * dealt with automatically if possible, and warnings
  -     * will be produced for any types that are not covered.
  -     */ 
  -    MatchedType[] matchTypes(BothSourceSet bss);
  -    
  -    /**
  -     * Returns a collection of MatchedProperties, advising which
  -     * Java properties and Schema properties (elements or
  -     * attributes) should be matched with each other.
  -     * Any properties not returned here will not be bound.
  -     * It is acceptable to rebind properties that were already
  -     * bound in a base class. Conflicts will result in an error.
  -     */ 
  -    MatchedProperties[] matchProperties(JClass jClass, SchemaType sType);
       
       public static class MatchedProperties
       {
  
  
  
  1.4       +1 -1      xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java
  
  Index: BuiltinSchemaTypeSystem.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/BuiltinSchemaTypeSystem.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BuiltinSchemaTypeSystem.java	4 Dec 2003 21:14:56 -0000	1.3
  +++ BuiltinSchemaTypeSystem.java	11 Dec 2003 19:32:54 -0000	1.4
  @@ -321,7 +321,7 @@
           // derived strings
           setupBuiltin(SchemaType.BTC_NORMALIZED_STRING, "normalizedString", "org.apache.xmlbeans.XmlNormalizedString");
           setupBuiltin(SchemaType.BTC_TOKEN, "token", "org.apache.xmlbeans.XmlToken");
  -        setupBuiltin(SchemaType.BTC_NAME, "Name", "org.apache.xmlbeans.XmlTypeName");
  +        setupBuiltin(SchemaType.BTC_NAME, "Name", "org.apache.xmlbeans.XmlName");
           setupBuiltin(SchemaType.BTC_NCNAME, "NCName", "org.apache.xmlbeans.XmlNCName");
           setupBuiltin(SchemaType.BTC_LANGUAGE, "language", "org.apache.xmlbeans.XmlLanguage");
           setupBuiltin(SchemaType.BTC_ID, "ID", "org.apache.xmlbeans.XmlID");
  
  
  
  1.4       +5 -1      xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
  
  Index: SchemaTypeImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SchemaTypeImpl.java	13 Nov 2003 01:03:00 -0000	1.3
  +++ SchemaTypeImpl.java	11 Dec 2003 19:32:54 -0000	1.4
  @@ -834,6 +834,8 @@
               SchemaGlobalElement elt = wildcardTypeLoader.findElement(eltName);
               if (elt == null)
                   return BuiltinSchemaTypeSystem.ST_NO_TYPE;
  +            // According to http://www.w3.org/TR/xmlschema-1/#key-lva,
  +            // the line above should return ST_ANY_TYPE.
               type = elt.getType();
           }
   
  @@ -865,7 +867,9 @@
   
           if (!_typedWildcardAttributes.contains(attrName) || wildcardTypeLoader == null)
               return BuiltinSchemaTypeSystem.ST_NO_TYPE;
  -
  +        // For symmetry with the element case (as well as with URType), perhaps
  +        // the above line should be returning ST_ANY_SIMPLE
  +        
           SchemaGlobalAttribute attr = wildcardTypeLoader.findAttribute(attrName);
           if (attr == null)
               return BuiltinSchemaTypeSystem.ST_NO_TYPE;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message