< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/SoftReferenceGrammarPool.java

Print this page


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Nov 2017
   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 
  22 package com.sun.org.apache.xerces.internal.jaxp.validation;
  23 
  24 import java.lang.ref.Reference;
  25 import java.lang.ref.ReferenceQueue;
  26 import java.lang.ref.SoftReference;
  27 
  28 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
  29 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
  30 import com.sun.org.apache.xerces.internal.xni.grammars.XMLSchemaDescription;
  31 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
  32 
  33 /**
  34  * <p>This grammar pool is a memory sensitive cache. The grammars
  35  * stored in the pool are softly reachable and may be cleared by
  36  * the garbage collector in response to memory demand. Equality
  37  * of <code>XMLSchemaDescription</code>s is determined using both
  38  * the target namespace for the schema and schema location.</p>
  39  *
  40  * @author Michael Glavassevich, IBM

  41  */
  42 final class SoftReferenceGrammarPool implements XMLGrammarPool {
  43 
  44     //
  45     // Constants
  46     //
  47 
  48     /** Default size. */
  49     protected static final int TABLE_SIZE = 11;
  50 
  51     /** Zero length grammar array. */
  52     protected static final Grammar [] ZERO_LENGTH_GRAMMAR_ARRAY = new Grammar [0];
  53 
  54     //
  55     // Data
  56     //
  57 
  58     /** Grammars. */
  59     protected Entry [] fGrammars = null;
  60 


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.

   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  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 java.lang.ref.Reference;
  24 import java.lang.ref.ReferenceQueue;
  25 import java.lang.ref.SoftReference;
  26 
  27 import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
  28 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
  29 import com.sun.org.apache.xerces.internal.xni.grammars.XMLSchemaDescription;
  30 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
  31 
  32 /**
  33  * <p>This grammar pool is a memory sensitive cache. The grammars
  34  * stored in the pool are softly reachable and may be cleared by
  35  * the garbage collector in response to memory demand. Equality
  36  * of <code>XMLSchemaDescription</code>s is determined using both
  37  * the target namespace for the schema and schema location.</p>
  38  *
  39  * @author Michael Glavassevich, IBM
  40  * @LastModified: Nov 2017
  41  */
  42 final class SoftReferenceGrammarPool implements XMLGrammarPool {
  43 
  44     //
  45     // Constants
  46     //
  47 
  48     /** Default size. */
  49     protected static final int TABLE_SIZE = 11;
  50 
  51     /** Zero length grammar array. */
  52     protected static final Grammar [] ZERO_LENGTH_GRAMMAR_ARRAY = new Grammar [0];
  53 
  54     //
  55     // Data
  56     //
  57 
  58     /** Grammars. */
  59     protected Entry [] fGrammars = null;
  60 


< prev index next >