1/* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5/* 6 * Licensed to the Apache Software Foundation (ASF) under one or more 7 * contributor license agreements. See the NOTICE file distributed with 8 * this work for additional information regarding copyright ownership. 9 * The ASF licenses this file to You under the Apache License, Version 2.0 10 * (the "License"); you may not use this file except in compliance with 11 * the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22package com.sun.org.apache.xerces.internal.jaxp.validation; 23 24import java.util.HashMap; 25 26import javax.xml.validation.Schema; 27import javax.xml.validation.Validator; 28import javax.xml.validation.ValidatorHandler; 29 30/** 31 * <p>Abstract implementation of Schema for W3C XML Schemas.</p> 32 * 33 * @author Michael Glavassevich, IBM 34 */ 35abstract class AbstractXMLSchema extends Schema implements 36 XSGrammarPoolContainer { 37 38 /** 39 * Map containing the initial values of features for 40 * validators created using this grammar pool container. 41 */ 42 private final HashMap fFeatures; 43 44 /** 45 * Map containing the initial values of properties for 46 * validators created using this grammar pool container. 47 */ 48 private final HashMap fProperties; 49 50 public AbstractXMLSchema() { 51 fFeatures = new HashMap(); 52 fProperties = new HashMap(); 53 } 54 55 /* 56 * Schema methods 57 */ 58 59 /* 60 * @see javax.xml.validation.Schema#newValidator() 61 */ 62 public final Validator newValidator() { 63 return new ValidatorImpl(this); 64 } 65 66 /* 67 * @see javax.xml.validation.Schema#newValidatorHandler() 68 */ 69 public final ValidatorHandler newValidatorHandler() { 70 return new ValidatorHandlerImpl(this); 71 } 72 73 /* 74 * XSGrammarPoolContainer methods 75 */ 76 77 /** 78 * Returns the initial value of a feature for validators created 79 * using this grammar pool container or null if the validators 80 * should use the default value. 81 */ 82 public final Boolean getFeature(String featureId) { 83 return (Boolean) fFeatures.get(featureId); 84 } 85 86 /* 87 * Set a feature on the schema 88 */ 89 public final void setFeature(String featureId, boolean state) { 90 fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE); 91 } 92 93 /** 94 * Returns the initial value of a property for validators created 95 * using this grammar pool container or null if the validators 96 * should use the default value. 97 */ 98 public final Object getProperty(String propertyId) { 99 return fProperties.get(propertyId); 100 } 101 102 /* 103 * Set a property on the schema 104 */ 105 public final void setProperty(String propertyId, Object state) { 106 fProperties.put(propertyId, state); 107 } 108 109} // AbstractXMLSchema 110