View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 2001-2004 The Apache Software Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *      http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package com.sun.org.apache.xerces.internal.impl.xs.models;
22  
23  import com.sun.org.apache.xerces.internal.xni.QName;
24  import com.sun.org.apache.xerces.internal.impl.xs.SubstitutionGroupHandler;
25  import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaException;
26  
27  import java.util.Vector;
28  import java.util.ArrayList;
29  
30  /**
31   * Note: State of the content model is stored in the validator
32   *
33   * @xerces.internal
34   *
35   * @author Sandy Gao, IBM
36   * @author Elena Litani, IBM
37   * @version $Id: XSCMValidator.java,v 1.6 2009/07/28 15:18:12 spericas Exp $
38   */
39  public interface XSCMValidator {
40  
41  
42      public static final short FIRST_ERROR = -1;
43  
44      // on subsequent errors the validator should not report
45      // an error
46      //
47      public static final short SUBSEQUENT_ERROR = -2;
48  
49      /**
50       * This methods to be called on entering a first element whose type
51       * has this content model. It will return the initial state of the content model
52       *
53       * @return Start state of the content model
54       */
55      public int[] startContentModel();
56  
57  
58      /**
59       * The method corresponds to one transaction in the content model.
60       *
61       * @param elementName
62       * @param state  Current state
63       * @return element decl or wildcard decl that
64       *         corresponds to the element from the Schema grammar
65       */
66      public Object oneTransition (QName elementName, int[] state, SubstitutionGroupHandler subGroupHandler);
67  
68  
69      /**
70       * The method indicates the end of list of children
71       *
72       * @param state  Current state of the content model
73       * @return true if the last state was a valid final state
74       */
75      public boolean endContentModel (int[] state);
76  
77      /**
78       * check whether this content violates UPA constraint.
79       *
80       * @param subGroupHandler the substitution group handler
81       * @return true if this content model contains other or list wildcard
82       */
83      public boolean checkUniqueParticleAttribution(SubstitutionGroupHandler subGroupHandler) throws XMLSchemaException;
84  
85      /**
86       * Check which elements are valid to appear at this point. This method also
87       * works if the state is in error, in which case it returns what should
88       * have been seen.
89       *
90       * @param state  the current state
91       * @return       a Vector whose entries are instances of
92       *               either XSWildcardDecl or XSElementDecl.
93       */
94      public Vector whatCanGoHere(int[] state);
95  
96      /**
97       * Used by constant space algorithm for a{n,m} for n > 1 and
98       * m <= unbounded. Called by a validator if validation of
99       * countent model succeeds after subsuming a{n,m} to a*
100      * (or a+) to check the n and m bounds.
101      * Returns <code>null</code> if validation of bounds is
102      * successful. Returns a list of strings with error info
103      * if not. Even entries in list returned are error codes
104      * (used to look up properties) and odd entries are parameters
105      * to be passed when formatting error message. Each parameter
106      * is associated with the error code that preceeds it in
107      * the list.
108      */
109     public ArrayList checkMinMaxBounds();
110 
111 } // XSCMValidator