View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 1999-2002,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.validation;
22  
23  import java.util.Vector;
24  
25  /**
26   * ValidationManager is a coordinator property for validators in the
27   * pipeline. Each validator must know how to interact with
28   * this property. Validators are not required to know what kind of
29   * other validators present in the pipeline, but should understand
30   * that there are others and that some coordination is required.
31   *
32   * @xerces.internal
33   *
34   * @author Elena Litani, IBM
35   */
36  public class ValidationManager {
37  
38      protected final Vector fVSs = new Vector();
39      protected boolean fGrammarFound = false;
40  
41      // used by the DTD validator to tell other components that it has a
42      // cached DTD in hand so there's no reason to
43      // scan external subset or entity decls.
44      protected boolean fCachedDTD = false;
45  
46      /**
47       * Each validator should call this method to add its ValidationState into
48       * the validation manager.
49       */
50      public final void addValidationState(ValidationState vs) {
51          fVSs.addElement(vs);
52      }
53  
54      /**
55       * Set the information required to validate entity values.
56       */
57      public final void setEntityState(EntityState state) {
58          for (int i = fVSs.size()-1; i >= 0; i--) {
59              ((ValidationState)fVSs.elementAt(i)).setEntityState(state);
60          }
61      }
62  
63      public final void setGrammarFound(boolean grammar){
64          fGrammarFound = grammar;
65      }
66  
67      public final boolean isGrammarFound(){
68          return fGrammarFound;
69      }
70  
71      public final void setCachedDTD(boolean cachedDTD) {
72          fCachedDTD = cachedDTD;
73      } // setCachedDTD(boolean)
74  
75      public final boolean isCachedDTD() {
76          return fCachedDTD;
77      } // isCachedDTD():  boolean
78  
79  
80      public final void reset (){
81          fVSs.removeAllElements();
82          fGrammarFound = false;
83          fCachedDTD = false;
84      }
85  }