/[classpath]/classpath/gnu/xml/aelfred2/SAXDriver.java
ViewVC logotype

Diff of /classpath/gnu/xml/aelfred2/SAXDriver.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mark, Thu Dec 23 22:38:43 2004 UTC revision 1.2 by dog, Fri Feb 4 19:12:02 2005 UTC
# Line 150  final public class SAXDriver Line 150  final public class SAXDriver
150      private Stack                       entityStack;      private Stack                       entityStack;
151    
152      // one vector (of object/struct): faster, smaller      // one vector (of object/struct): faster, smaller
153      private List                        attributesList = Collections.synchronizedList(new ArrayList());      private List                        attributesList;
     
     private boolean                     attributeSpecified [] = new boolean[10];  
     private boolean                     attributeDeclared [] = new boolean[10];  
154    
155      private boolean                     namespaces = true;      private boolean                     namespaces = true;
156      private boolean                     xmlNames = false;      private boolean                     xmlNames = false;
# Line 183  final public class SAXDriver Line 180  final public class SAXDriver
180        elementName = null;        elementName = null;
181        entityStack = new Stack ();        entityStack = new Stack ();
182        attributesList = Collections.synchronizedList(new ArrayList());        attributesList = Collections.synchronizedList(new ArrayList());
       attributeSpecified = new boolean[10];  
       attributeDeclared = new boolean[10];  
183        attributeCount = 0;        attributeCount = 0;
184        attributes = false;        attributes = false;
185        nsTemp = new String[3];        nsTemp = new String[3];
# Line 849  final public class SAXDriver Line 844  final public class SAXDriver
844    }    }
845          // remember this attribute ...          // remember this attribute ...
846    
         if (attributeCount == attributeSpecified.length) {      // grow array?  
             boolean temp [] = new boolean [attributeSpecified.length + 5];  
             System.arraycopy (attributeSpecified, 0, temp, 0, attributeCount);  
             attributeSpecified = temp;  
         }  
         attributeSpecified [attributeCount] = isSpecified;  
   
847          attributeCount++;          attributeCount++;
848                    
849          // attribute type comes from querying parser's DTD records          // attribute type comes from querying parser's DTD records
850          attributesList.add(new Attribute(qname, value));          attributesList.add(new Attribute(qname, value, isSpecified));
851    
852      }      }
853    
# Line 1212  final public class SAXDriver Line 1200  final public class SAXDriver
1200      {      {
1201          if (index < 0 || index >= attributeCount)          if (index < 0 || index >= attributeCount)
1202              throw new ArrayIndexOutOfBoundsException ();              throw new ArrayIndexOutOfBoundsException ();
1203          return attributeDeclared [index];          String type = parser.getAttributeType(elementName, getQName(index));
1204            return (type != null);
1205      }      }
1206    
1207      /** @return false unless the attribute was declared in the DTD.      /** @return false unless the attribute was declared in the DTD.
1208       * @throws java.lang.IllegalArgumentException       * @throws java.lang.IllegalArgumentException
1209       *   When the supplied names do not identify an attribute.       *   When the supplied names do not identify an attribute.
1210       */       */
1211      public boolean isDeclared (java.lang.String qName)      public boolean isDeclared (String qName)
1212      {      {
1213          int index = getIndex (qName);          int index = getIndex (qName);
1214          if (index < 0)          if (index < 0)
1215              throw new IllegalArgumentException ();              throw new IllegalArgumentException ();
1216          return attributeDeclared [index];          String type = parser.getAttributeType(elementName, qName);
1217            return (type != null);
1218      }      }
1219    
1220      /** @return false unless the attribute was declared in the DTD.      /** @return false unless the attribute was declared in the DTD.
1221       * @throws java.lang.IllegalArgumentException       * @throws java.lang.IllegalArgumentException
1222       *   When the supplied names do not identify an attribute.       *   When the supplied names do not identify an attribute.
1223       */       */
1224      public boolean isDeclared (java.lang.String uri, java.lang.String localName)      public boolean isDeclared (String uri, String localName)
1225      {      {
1226          int index = getIndex (uri, localName);          int index = getIndex (uri, localName);
1227          if (index < 0)          return isDeclared(index);
             throw new IllegalArgumentException ();  
         return attributeDeclared [index];  
1228      }      }
1229    
1230    
# Line 1245  final public class SAXDriver Line 1233  final public class SAXDriver
1233       */       */
1234      public boolean isSpecified (int index)      public boolean isSpecified (int index)
1235      {      {
1236          if (index < 0 || index >= attributeCount)          return ((Attribute) attributesList.get(index)).specified;
             throw new ArrayIndexOutOfBoundsException ();  
         return attributeSpecified [index];  
1237      }      }
1238    
1239      /**      /**
# Line 1256  final public class SAXDriver Line 1242  final public class SAXDriver
1242      public boolean isSpecified (String uri, String local)      public boolean isSpecified (String uri, String local)
1243      {      {
1244          int index = getIndex (uri, local);          int index = getIndex (uri, local);
1245            return isSpecified(index);
         if (index < 0)  
             throw new IllegalArgumentException ();  
         return attributeSpecified [index];  
1246      }      }
1247    
1248      /**      /**
# Line 1268  final public class SAXDriver Line 1251  final public class SAXDriver
1251      public boolean isSpecified (String xmlName)      public boolean isSpecified (String xmlName)
1252      {      {
1253          int index = getIndex (xmlName);          int index = getIndex (xmlName);
1254            return isSpecified(index);
         if (index < 0)  
             throw new IllegalArgumentException ();  
         return attributeSpecified [index];  
1255      }      }
1256    
1257    
# Line 1374  class Attribute Line 1354  class Attribute
1354      String value;      String value;
1355      String nameSpace;      String nameSpace;
1356      String localName;      String localName;
1357        boolean specified;
1358    
1359      Attribute(String name, String value)      Attribute(String name, String value, boolean specified)
1360      {      {
1361          this.name = name;          this.name = name;
1362          this.value = value;          this.value = value;
1363          this.nameSpace = "";          this.nameSpace = "";
1364            this.specified = specified;
1365      }      }
1366  }  }
1367    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26