You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by da...@apache.org on 2004/08/09 22:25:39 UTC

cvs commit: xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema SchemaTypeSystemImpl.java

daveremy    2004/08/09 13:25:39

  Modified:    v2/src/typeimpl/org/apache/xmlbeans/impl/schema
                        SchemaTypeSystemImpl.java
  Log:
  Fix for a possible NPE when dealing with older versions of xsbs.
  Contributed by Radu Preotiuc.
  
  Revision  Changes    Path
  1.12      +31 -22    xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
  
  Index: SchemaTypeSystemImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SchemaTypeSystemImpl.java	6 Aug 2004 02:28:30 -0000	1.11
  +++ SchemaTypeSystemImpl.java	9 Aug 2004 20:25:39 -0000	1.12
  @@ -535,27 +535,36 @@
               String ns = ((QName) entry.getKey()).getNamespaceURI();
               getContainerNonNull(ns).addAttributeType((SchemaType.Ref) entry.getValue());
           }
  -        assert _redefinedGlobalTypes.size() == redefTypeNames.size();
  -        for (Iterator it = _redefinedGlobalTypes.iterator(), itname = redefTypeNames.iterator(); it.hasNext(); )
  +        // Some earlier .xsb versions don't have records for redefinitions
  +        if (_redefinedGlobalTypes != null && _redefinedModelGroups != null &&
  +            _redefinedAttributeGroups != null)
           {
  -            String ns = ((QName) itname.next()).getNamespaceURI();
  -            getContainerNonNull(ns).addRedefinedType((SchemaType.Ref) it.next());
  -        }
  -        for (Iterator it = _redefinedModelGroups.iterator(), itname = redefModelGroupNames.iterator(); it.hasNext(); )
  -        {
  -            String ns = ((QName) itname.next()).getNamespaceURI();
  -            getContainerNonNull(ns).addRedefinedModelGroup((SchemaModelGroup.Ref) it.next());
  -        }
  -        for (Iterator it = _redefinedAttributeGroups.iterator(), itname = redefAttributeGroupNames.iterator(); it.hasNext(); )
  -        {
  -            String ns = ((QName) itname.next()).getNamespaceURI();
  -            getContainerNonNull(ns).addRedefinedAttributeGroup((SchemaAttributeGroup.Ref) it.next());
  +            assert _redefinedGlobalTypes.size() == redefTypeNames.size();
  +            for (Iterator it = _redefinedGlobalTypes.iterator(), itname = redefTypeNames.iterator(); it.hasNext(); )
  +            {
  +                String ns = ((QName) itname.next()).getNamespaceURI();
  +                getContainerNonNull(ns).addRedefinedType((SchemaType.Ref) it.next());
  +            }
  +            for (Iterator it = _redefinedModelGroups.iterator(), itname = redefModelGroupNames.iterator(); it.hasNext(); )
  +            {
  +                String ns = ((QName) itname.next()).getNamespaceURI();
  +                getContainerNonNull(ns).addRedefinedModelGroup((SchemaModelGroup.Ref) it.next());
  +            }
  +            for (Iterator it = _redefinedAttributeGroups.iterator(), itname = redefAttributeGroupNames.iterator(); it.hasNext(); )
  +            {
  +                String ns = ((QName) itname.next()).getNamespaceURI();
  +                getContainerNonNull(ns).addRedefinedAttributeGroup((SchemaAttributeGroup.Ref) it.next());
  +            }
           }
  -        for (Iterator it = _annotations.iterator(); it.hasNext(); )
  +        // Some earlier .xsb versions don't have records for annotations
  +        if (_annotations != null)
           {
  -            SchemaAnnotation ann = (SchemaAnnotation) it.next();
  -            // BUGBUG(radup)
  -            getContainerNonNull("").addAnnotation(ann);
  +            for (Iterator it = _annotations.iterator(); it.hasNext(); )
  +            {
  +                SchemaAnnotation ann = (SchemaAnnotation) it.next();
  +                // BUGBUG(radup)
  +                getContainerNonNull("").addAnnotation(ann);
  +            }
           }
           for (Iterator it = _containers.values().iterator(); it.hasNext(); )
               ((SchemaContainer) it.next()).setImmutable();
  @@ -3386,7 +3395,7 @@
   
       public SchemaType[] redefinedGlobalTypes()
       {
  -        if (_redefinedGlobalTypes.isEmpty())
  +        if (_redefinedGlobalTypes == null || _redefinedGlobalTypes.isEmpty())
               return EMPTY_ST_ARRAY;
   
           SchemaType[] result = new SchemaType[_redefinedGlobalTypes.size()];
  @@ -3475,7 +3484,7 @@
   
       public SchemaModelGroup[] redefinedModelGroups()
       {
  -        if (_redefinedModelGroups.isEmpty())
  +        if (_redefinedModelGroups == null || _redefinedModelGroups.isEmpty())
               return EMPTY_MG_ARRAY;
   
           SchemaModelGroup[] result = new SchemaModelGroup[_redefinedModelGroups.size()];
  @@ -3499,7 +3508,7 @@
   
       public SchemaAttributeGroup[] redefinedAttributeGroups()
       {
  -        if (_redefinedAttributeGroups.isEmpty())
  +        if (_redefinedAttributeGroups == null || _redefinedAttributeGroups.isEmpty())
               return EMPTY_AG_ARRAY;
   
           SchemaAttributeGroup[] result = new SchemaAttributeGroup[_redefinedAttributeGroups.size()];
  @@ -3511,7 +3520,7 @@
   
       public SchemaAnnotation[] annotations()
       {
  -        if (_annotations.isEmpty())
  +        if (_annotations == null || _annotations.isEmpty())
               return EMPTY_ANN_ARRAY;
   
           SchemaAnnotation[] result = new SchemaAnnotation[_annotations.size()];
  
  
  

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