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
9
* http://www.apache.org/licenses/LICENSE-2.0
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.
18
package org.apache.xerces.impl.validation;
21
* <p>An extension of ValidationState which can be configured to turn
22
* off checking for ID/IDREF errors and unparsed entity errors.</p>
26
* @author Peter McCracken, IBM
27
* @version $Id: ConfigurableValidationState.java,v 1.2 2009/12/10 03:18:42 matthewoliver Exp $
29
public final class ConfigurableValidationState extends ValidationState {
32
* Whether to check for ID/IDREF errors
34
private boolean fIdIdrefChecking;
37
* Whether to check for unparsed entity errors
39
private boolean fUnparsedEntityChecking;
42
* Creates a new ConfigurableValidationState.
43
* By default, error checking for both ID/IDREFs
44
* and unparsed entities are turned on.
46
public ConfigurableValidationState() {
48
fIdIdrefChecking = true;
49
fUnparsedEntityChecking = true;
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
57
public void setIdIdrefChecking(boolean setting) {
58
fIdIdrefChecking = setting;
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
66
public void setUnparsedEntityChecking(boolean setting) {
67
fUnparsedEntityChecking = setting;
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
75
public String checkIDRefID() {
76
return (fIdIdrefChecking) ? super.checkIDRefID() : null;
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
84
public boolean isIdDeclared(String name) {
85
return (fIdIdrefChecking) ? super.isIdDeclared(name) : false;
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
93
public boolean isEntityDeclared(String name) {
94
return (fUnparsedEntityChecking) ? super.isEntityDeclared(name) : true;
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
102
public boolean isEntityUnparsed(String name) {
103
return (fUnparsedEntityChecking) ? super.isEntityUnparsed(name) : true;
107
* Adds the ID, if ID/IDREF checking is enabled.
108
* @param name the ID to add
110
public void addId(String name) {
111
if (fIdIdrefChecking) {
117
* Adds the IDREF, if ID/IDREF checking is enabled.
118
* @param name the IDREF to add
120
public void addIdRef(String name) {
121
if (fIdIdrefChecking) {
122
super.addIdRef(name);