1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Copyright 2005 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.jaxp.validation;
  22 
  23 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
  24 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
  25 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
  26 
  27 /**
  28  * <p>Filter {@link XMLGrammarPool} that exposes a
  29  * read-only view of the underlying pool.</p>
  30  *
  31  * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  32  */
  33 final class ReadOnlyGrammarPool implements XMLGrammarPool {
  34 
  35     private final XMLGrammarPool core;
  36 
  37     public ReadOnlyGrammarPool( XMLGrammarPool pool ) {
  38         this.core = pool;
  39     }
  40 
  41     public void cacheGrammars(String grammarType, Grammar[] grammars) {
  42         // noop. don't let caching to happen
  43     }
  44 
  45     public void clear() {
  46         // noop. cache is read-only.
  47     }
  48 
  49     public void lockPool() {
  50         // noop. this pool is always read-only
  51     }
  52 
  53     public Grammar retrieveGrammar(XMLGrammarDescription desc) {
  54         return core.retrieveGrammar(desc);
  55     }
  56 
  57     public Grammar[] retrieveInitialGrammarSet(String grammarType) {
  58         return core.retrieveInitialGrammarSet(grammarType);
  59     }
  60 
  61     public void unlockPool() {
  62         // noop. this pool is always read-only.
  63     }
  64 
  65 } // ReadOnlyGrammarPool