You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by er...@locus.apache.org on 2000/06/09 00:51:42 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/validators Grammar.java InvalidDatatypeValueException.java

ericye      00/06/08 15:51:42

  Modified:    java/src/org/apache/xerces/validators Tag: xerces_j_2
                        Grammar.java InvalidDatatypeValueException.java
  Log:
  add Decl Pools and several getters --ericye
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +124 -7    xml-xerces/java/src/org/apache/xerces/validators/Attic/Grammar.java
  
  Index: Grammar.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/Attic/Grammar.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- Grammar.java	2000/06/08 00:09:31	1.1.2.3
  +++ Grammar.java	2000/06/08 22:51:41	1.1.2.4
  @@ -59,14 +59,28 @@
   
   import org.w3c.dom.Document;
   
  +import org.apache.xerces.utils.QName;
  +
   /**
    * @author Stubs generated by DesignDoc on Wed Jun 07 11:58:44 PDT 2000
  - * @version $Id: Grammar.java,v 1.1.2.3 2000/06/08 00:09:31 andyc Exp $
  + * @version $Id: Grammar.java,v 1.1.2.4 2000/06/08 22:51:41 ericye Exp $
    */
   public class Grammar
       implements ContentSpecProvider {
   
       //
  +    // Constants
  +    //
  +
  +    private static final int CHUNK_SHIFT = 8; // 2^8 = 256
  +    private static final int CHUNK_SIZE = (1 << CHUNK_SHIFT);
  +    private static final int CHUNK_MASK = CHUNK_SIZE - 1;
  +    private static final int INITIAL_CHUNK_COUNT = (1 << (10 - CHUNK_SHIFT)); // 2^10 = 1k
  +
  +    private static final short LIST_FLAG = 0x80;
  +    private static final short LIST_MASK = ~LIST_FLAG;
  +    
  +    //
       // Data
       //
   
  @@ -76,6 +90,44 @@
       /** fGrammarDocument */
       protected Document fGrammarDocument;
   
  +        // element decl tables
  +
  +    private int fElementDeclCount = 0;
  +    private String fElementDeclName[][] = new String[INITIAL_CHUNK_COUNT][];
  +    private short fElementDeclType[][] = new short[INITIAL_CHUNK_COUNT][];
  +    private DatatypeValidator fElementDeclDatatypeValidator[][] = new DatatypeValidator[INITIAL_CHUNK_COUNT][];
  +    private int fElementDeclContentSpecIndex[][] = new int[INITIAL_CHUNK_COUNT][];
  +    private ContentModelValidator fElementDeclContentModelValidator[][] = new ContentModelValidator[INITIAL_CHUNK_COUNT][];
  +    private int fElementDeclFirstAttributeDeclIndex[][] = new int[INITIAL_CHUNK_COUNT][];
  +    private int fElementDeclLastAttributeDeclIndex[][] = new int[INITIAL_CHUNK_COUNT][];
  +    private String fElementDeclDefaultValue[][] = new String[INITIAL_CHUNK_COUNT][];
  +    private short   fElementDeclDefaultType[][] = new short[INITIAL_CHUNK_COUNT][];
  +
  +    // content spec tables
  +
  +    private int fContentSpecCount = 0 ;
  +    private int fContentSpecType[][] = new int[INITIAL_CHUNK_COUNT][];
  +    private Object fContentSpecTree[][] = new Object[INITIAL_CHUNK_COUNT][];
  +    /***
  +    private int fContentSpecValue[][] = new int[INITIAL_CHUNK_COUNT][];
  +    private int fContentSpecOtherValue[][] = new int[INITIAL_CHUNK_COUNT][];
  +    ***/
  +
  +    // attribute decl tables
  +
  +    private int fAttributeDeclCount = 0 ;
  +    private QName fAttributeDeclName[][] = new QName[INITIAL_CHUNK_COUNT][];
  +    private short   fAttributeDeclType[][] = new short[INITIAL_CHUNK_COUNT][];
  +    private String[]   fAttributeDeclEnumeration[][] = new String[INITIAL_CHUNK_COUNT][][];
  +    private short   fAttributeDeclDefaultType[][] = new short[INITIAL_CHUNK_COUNT][];
  +    private DatatypeValidator fAttributeDeclDatatypeValidator[][] = new DatatypeValidator[INITIAL_CHUNK_COUNT][];
  +    private String fAttributeDeclDefaultValue[][] = new String[INITIAL_CHUNK_COUNT][];
  +    private int fAttributeDeclNextAttributeDeclIndex[][] = new int[INITIAL_CHUNK_COUNT][];
  +
  +    // scope mapping tables
  +
  +    //private Hash2intTable fElementNameAndScopeToElementDeclIndexMapping = new Hash2intTable();
  +
       //
       // Constructors
       //
  @@ -96,7 +148,7 @@
        * @return 
        */
       public String getTargetNamespace() {
  -        return null;
  +        return fTargetNamespace;
       } // getTargetNamespace
   
       /**
  @@ -105,7 +157,7 @@
        * @return 
        */
       public Document getGrammarDocument() {
  -        return null;
  +        return fGrammarDocument;
       } // getGrammarDocument
   
       /**
  @@ -129,7 +181,36 @@
        * @return 
        */
       public boolean getElementDecl(int elementDeclIndex, XMLElementDecl elementDecl) {
  -        return false;
  +        if (elementDeclIndex < 0 || elementDeclIndex >= fElementDeclCount) {
  +            return false;
  +        }
  +
  +        int chunk = elementDeclIndex >> CHUNK_SHIFT;
  +        int index = elementDeclIndex &  CHUNK_MASK;
  +
  +        //elementDecl.name.clear();
  +        elementDecl.name.prefix = null;
  +        elementDecl.name.rawname = null;
  +
  +        elementDecl.name.localpart          = fElementDeclName[chunk][index];               
  +        elementDecl.name.uri                = fTargetNamespace; 
  +
  +        if (fElementDeclType[chunk][index] == -1) {
  +            elementDecl.type                    = -1;
  +            elementDecl.simpleType.list = false;
  +        }
  +        else {
  +            elementDecl.type                    = (short) (fElementDeclType[chunk][index] & LIST_MASK);
  +            elementDecl.simpleType.list = (fElementDeclType[chunk][index] & LIST_FLAG) != 0;
  +        }
  +
  +        elementDecl.contentSpec = fElementDeclContentSpecIndex[chunk][index];        
  +
  +        elementDecl.simpleType.datatypeValidator = fElementDeclDatatypeValidator[chunk][index];       
  +        elementDecl.simpleType.defaultType = fElementDeclDefaultType[chunk][index];
  +        elementDecl.simpleType.defaultValue = fElementDeclDefaultValue[chunk][index];
  +
  +        return true;
       } // getElementDecl
   
       /**
  @@ -140,7 +221,10 @@
        * @return 
        */
       public int getFirstAttributeDeclIndex(int elementDeclIndex) {
  -        return -1;
  +        int chunk = elementDeclIndex >> CHUNK_SHIFT;
  +        int index = elementDeclIndex &  CHUNK_MASK;
  +
  +        return  fElementDeclFirstAttributeDeclIndex[chunk][index];
       } // getFirstAttributeDeclIndex
   
       /**
  @@ -151,7 +235,10 @@
        * @return 
        */
       public int getNextAttributeDeclIndex(int attributeDeclIndex) {
  -        return -1;
  +        int chunk = attributeDeclIndex >> CHUNK_SHIFT;
  +        int index = attributeDeclIndex &  CHUNK_MASK;
  +
  +        return fAttributeDeclNextAttributeDeclIndex[chunk][index];
       } // getNextAttributeDeclIndex
   
       /**
  @@ -175,7 +262,37 @@
        * @return 
        */
       public boolean getAttributeDecl(int attributeDeclIndex, XMLAttributeDecl attributeDecl) {
  -        return false;
  +        if (attributeDeclIndex < 0 || attributeDeclIndex >= fAttributeDeclCount) {
  +            return false;
  +        }
  +        int chunk = attributeDeclIndex >> CHUNK_SHIFT;
  +        int index = attributeDeclIndex & CHUNK_MASK;
  +
  +        //attributeDecl.name.setValues(fAttributeDeclName[chunk][index]);
  +        QName temp = fAttributeDeclName[chunk][index];
  +        attributeDecl.name.prefix = temp.prefix;
  +        attributeDecl.name.localpart =  temp.localpart;
  +        attributeDecl.name.rawname = temp.rawname;
  +        attributeDecl.name.uri = temp.uri;
  +
  +
  +        short attributeType;
  +        boolean isList;
  +
  +        if (fAttributeDeclType[chunk][index] == -1) {
  +            
  +            attributeType = -1;
  +            isList = false;
  +        }
  +        else {
  +            attributeType = (short) (fAttributeDeclType[chunk][index] & LIST_MASK);
  +            isList = (fAttributeDeclType[chunk][index] & LIST_FLAG) != 0;
  +        }
  +        attributeDecl.simpleType.setValues(attributeType,"",fAttributeDeclEnumeration[chunk][index],
  +                                           isList, fAttributeDeclDefaultType[chunk][index],
  +                                           fAttributeDeclDefaultValue[chunk][index], 
  +                                           fAttributeDeclDatatypeValidator[chunk][index]);
  +        return true;
       } // getAttributeDecl
   
       /**
  
  
  
  1.1.2.4   +5 -1      xml-xerces/java/src/org/apache/xerces/validators/Attic/InvalidDatatypeValueException.java
  
  Index: InvalidDatatypeValueException.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/Attic/InvalidDatatypeValueException.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- InvalidDatatypeValueException.java	2000/06/08 00:09:32	1.1.2.3
  +++ InvalidDatatypeValueException.java	2000/06/08 22:51:41	1.1.2.4
  @@ -61,7 +61,7 @@
   
   /**
    * @author Stubs generated by DesignDoc on Wed Jun 07 11:58:44 PDT 2000
  - * @version $Id: InvalidDatatypeValueException.java,v 1.1.2.3 2000/06/08 00:09:32 andyc Exp $
  + * @version $Id: InvalidDatatypeValueException.java,v 1.1.2.4 2000/06/08 22:51:41 ericye Exp $
    */
   public class InvalidDatatypeValueException
       extends SAXException {
  @@ -74,6 +74,7 @@
        * 
        */
       public InvalidDatatypeValueException() {
  +        super("");
       }
   
       /**
  @@ -82,6 +83,7 @@
        * @param message 
        */
       public InvalidDatatypeValueException(String message) {
  +        super(message);
       }
   
       /**
  @@ -90,6 +92,7 @@
        * @param exception 
        */
       public InvalidDatatypeValueException(Exception exception) {
  +        super(exception);
       }
   
       /**
  @@ -99,6 +102,7 @@
        * @param exception 
        */
       public InvalidDatatypeValueException(String message, Exception exception) {
  +        super(message, exception);
       }
   
   } // class InvalidDatatypeValueException