~vcs-imports/xena/trunk

« back to all changes in this revision

Viewing changes to ext/src/xerces-2_9_1/src/org/apache/xerces/impl/validation/ConfigurableValidationState.java

  • Committer: matthewoliver
  • Date: 2009-12-10 03:18:07 UTC
  • Revision ID: vcs-imports@canonical.com-20091210031807-l086qguzdlljtkl9
Merged Xena Testing into Xena Stable for the Xena 5 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
 
8
 * 
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 * 
 
11
 * Unless required by applicable law or agreed to in writing, software
 
12
 * distributed under the License is distributed on an "AS IS" BASIS,
 
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 * See the License for the specific language governing permissions and
 
15
 * limitations under the License.
 
16
 */
 
17
 
 
18
package org.apache.xerces.impl.validation;
 
19
 
 
20
/**
 
21
 * <p>An extension of ValidationState which can be configured to turn 
 
22
 * off checking for ID/IDREF errors and unparsed entity errors.</p>
 
23
 * 
 
24
 * @xerces.internal
 
25
 *
 
26
 * @author Peter McCracken, IBM
 
27
 * @version $Id: ConfigurableValidationState.java,v 1.2 2009/12/10 03:18:42 matthewoliver Exp $
 
28
 */
 
29
public final class ConfigurableValidationState extends ValidationState {
 
30
    
 
31
    /**
 
32
     * Whether to check for ID/IDREF errors
 
33
     */
 
34
    private boolean fIdIdrefChecking;
 
35
    
 
36
    /**
 
37
     * Whether to check for unparsed entity errors
 
38
     */
 
39
    private boolean fUnparsedEntityChecking;
 
40
    
 
41
    /**
 
42
     * Creates a new ConfigurableValidationState.
 
43
     * By default, error checking for both ID/IDREFs 
 
44
     * and unparsed entities are turned on.
 
45
     */
 
46
    public ConfigurableValidationState() {
 
47
        super();
 
48
        fIdIdrefChecking = true;
 
49
        fUnparsedEntityChecking = true;
 
50
    }
 
51
    
 
52
    /**
 
53
     * Turns checking for ID/IDREF errors on and off.
 
54
     * @param setting true to turn on error checking,
 
55
     *                 false to turn off error checking
 
56
     */
 
57
    public void setIdIdrefChecking(boolean setting) {
 
58
        fIdIdrefChecking = setting;
 
59
    }
 
60
    
 
61
    /**
 
62
     * Turns checking for unparsed entity errors on and off.
 
63
     * @param setting true to turn on error checking,
 
64
     *                 false to turn off error checking
 
65
     */
 
66
    public void setUnparsedEntityChecking(boolean setting) {
 
67
        fUnparsedEntityChecking = setting;
 
68
    }
 
69
    
 
70
    /**
 
71
     * Checks if all IDREFs have a corresponding ID.
 
72
     * @return null, if ID/IDREF checking is turned off
 
73
     *         otherwise, returns the value of the super implementation
 
74
     */
 
75
    public String checkIDRefID() {
 
76
        return (fIdIdrefChecking) ? super.checkIDRefID() : null;
 
77
    }
 
78
    
 
79
    /**
 
80
     * Checks if an ID has already been declared.
 
81
     * @return false, if ID/IDREF checking is turned off
 
82
     *         otherwise, returns the value of the super implementation
 
83
     */
 
84
    public boolean isIdDeclared(String name) {
 
85
        return (fIdIdrefChecking) ? super.isIdDeclared(name) : false;
 
86
    }
 
87
    
 
88
    /**
 
89
     * Checks if an entity is declared.
 
90
     * @return true, if unparsed entity checking is turned off
 
91
     *         otherwise, returns the value of the super implementation
 
92
     */
 
93
    public boolean isEntityDeclared(String name) {
 
94
        return (fUnparsedEntityChecking) ? super.isEntityDeclared(name) : true;
 
95
    }
 
96
    
 
97
    /**
 
98
     * Checks if an entity is unparsed.
 
99
     * @return true, if unparsed entity checking is turned off
 
100
     *         otherwise, returns the value of the super implementation
 
101
     */
 
102
    public boolean isEntityUnparsed(String name) {
 
103
        return (fUnparsedEntityChecking) ? super.isEntityUnparsed(name) : true;
 
104
    }
 
105
    
 
106
    /**
 
107
     * Adds the ID, if ID/IDREF checking is enabled.
 
108
     * @param name the ID to add
 
109
     */
 
110
    public void addId(String name) {
 
111
        if (fIdIdrefChecking) {
 
112
            super.addId(name);
 
113
        }
 
114
    }
 
115
    
 
116
    /**
 
117
     * Adds the IDREF, if ID/IDREF checking is enabled.
 
118
     * @param name the IDREF to add
 
119
     */
 
120
    public void addIdRef(String name) {
 
121
        if (fIdIdrefChecking) {
 
122
            super.addIdRef(name);
 
123
        }
 
124
    }
 
125
}