FileDocCategorySizeDatePackage
XSDeclarationPool.javaAPI DocJava SE 6 API10903Tue Jun 10 00:22:44 BST 2008com.sun.org.apache.xerces.internal.impl.xs

XSDeclarationPool

public final class XSDeclarationPool extends Object
This class is pool that enables caching of XML Schema declaration objects. Before a compiled grammar object is garbage collected, the implementation will add all XML Schema component declarations to the pool. Note: The cashing mechanism is not implemented yet.
xerces.internal
author
Elena Litani, IBM
version
$Id: XSDeclarationPool.java,v 1.2.6.1 2005/09/09 07:30:55 sunithareddy Exp $

Fields Summary
private static final int
CHUNK_SHIFT
Chunk shift (8).
private static final int
CHUNK_SIZE
Chunk size (1 << CHUNK_SHIFT).
private static final int
CHUNK_MASK
Chunk mask (CHUNK_SIZE - 1).
private static final int
INITIAL_CHUNK_COUNT
Initial chunk count ().
private XSElementDecl[]
fElementDecl
Element declaration pool
private int
fElementDeclIndex
private XSParticleDecl[]
fParticleDecl
Particle declaration pool
private int
fParticleDeclIndex
private XSModelGroupImpl[]
fModelGroup
Particle declaration pool
private int
fModelGroupIndex
private XSAttributeDecl[]
fAttrDecl
Attribute declaration pool
private int
fAttrDeclIndex
private XSComplexTypeDecl[]
fCTDecl
ComplexType declaration pool
private int
fCTDeclIndex
private XSSimpleTypeDecl[]
fSTDecl
SimpleType declaration pool
private int
fSTDeclIndex
private XSAttributeUseImpl[]
fAttributeUse
AttributeUse declaration pool
private int
fAttributeUseIndex
Constructors Summary
Methods Summary
private booleanensureAttrDeclCapacity(int chunk)

        if (chunk >= fAttrDecl.length) {
            fAttrDecl = resize(fAttrDecl, fAttrDecl.length * 2);
        } else if (fAttrDecl[chunk] != null) {            
            return false;
        }

        fAttrDecl[chunk] = new XSAttributeDecl[CHUNK_SIZE];
        return true;
    
private booleanensureAttributeUseCapacity(int chunk)

        if (chunk >= fAttributeUse.length) {
            fAttributeUse = resize(fAttributeUse, fAttributeUse.length * 2);
        } else if (fAttributeUse[chunk] != null) {
            return false;
        }

        fAttributeUse[chunk] = new XSAttributeUseImpl[CHUNK_SIZE];
        return true;
    
private booleanensureCTDeclCapacity(int chunk)


        if (chunk >= fCTDecl.length) {
            fCTDecl = resize(fCTDecl, fCTDecl.length * 2);
        } else if (fCTDecl[chunk] != null){
            return false;
        }

        fCTDecl[chunk] = new XSComplexTypeDecl[CHUNK_SIZE];
        return true;
    
private booleanensureElementDeclCapacity(int chunk)

        if (chunk >= fElementDecl.length) {
            fElementDecl = resize(fElementDecl, fElementDecl.length * 2);
        } else if (fElementDecl[chunk] != null) {
            return false;
        }

        fElementDecl[chunk] = new XSElementDecl[CHUNK_SIZE];
        return true;
    
private booleanensureModelGroupCapacity(int chunk)

        if (chunk >= fModelGroup.length) {
            fModelGroup = resize(fModelGroup, fModelGroup.length * 2);
        } else if (fModelGroup[chunk] != null) {
            return false;
        }

        fModelGroup[chunk] = new XSModelGroupImpl[CHUNK_SIZE];
        return true;
    
private booleanensureParticleDeclCapacity(int chunk)

        if (chunk >= fParticleDecl.length) {
            fParticleDecl = resize(fParticleDecl, fParticleDecl.length * 2);
        } else if (fParticleDecl[chunk] != null) {
            return false;
        }

        fParticleDecl[chunk] = new XSParticleDecl[CHUNK_SIZE];
        return true;
    
private booleanensureSTDeclCapacity(int chunk)

        if (chunk >= fSTDecl.length) {
            fSTDecl = resize(fSTDecl, fSTDecl.length * 2);
        } else if (fSTDecl[chunk] != null) {
            return false;
        }

        fSTDecl[chunk] = new XSSimpleTypeDecl[CHUNK_SIZE];
        return true;
    
public final com.sun.org.apache.xerces.internal.impl.xs.XSAttributeDeclgetAttributeDecl()

        int     chunk       = fAttrDeclIndex >> CHUNK_SHIFT;
        int     index       = fAttrDeclIndex &  CHUNK_MASK;
        ensureAttrDeclCapacity(chunk);
        if (fAttrDecl[chunk][index] == null) {
            fAttrDecl[chunk][index] = new XSAttributeDecl();
        } else {
            fAttrDecl[chunk][index].reset();
        }
        fAttrDeclIndex++;
        return fAttrDecl[chunk][index];

    
public final com.sun.org.apache.xerces.internal.impl.xs.XSAttributeUseImplgetAttributeUse()

        int     chunk       = fAttributeUseIndex >> CHUNK_SHIFT;
        int     index       = fAttributeUseIndex &  CHUNK_MASK;
        ensureAttributeUseCapacity(chunk);
        if (fAttributeUse[chunk][index] == null) {
            fAttributeUse[chunk][index] = new XSAttributeUseImpl();
        } else {
            fAttributeUse[chunk][index].reset();
        }
        fAttributeUseIndex++;
        return fAttributeUse[chunk][index];

    
public final com.sun.org.apache.xerces.internal.impl.xs.XSComplexTypeDeclgetComplexTypeDecl()

        int     chunk       = fCTDeclIndex >> CHUNK_SHIFT;
        int     index       = fCTDeclIndex &  CHUNK_MASK;
        ensureCTDeclCapacity(chunk);
        if (fCTDecl[chunk][index] == null) {

            fCTDecl[chunk][index] = new XSComplexTypeDecl();
        } else {
            fCTDecl[chunk][index].reset();
        }
        fCTDeclIndex++;
        return fCTDecl[chunk][index];
    
public final com.sun.org.apache.xerces.internal.impl.xs.XSElementDeclgetElementDecl()


        
        int     chunk       = fElementDeclIndex >> CHUNK_SHIFT;
        int     index       = fElementDeclIndex &  CHUNK_MASK;
        ensureElementDeclCapacity(chunk);
        if (fElementDecl[chunk][index] == null) {
            fElementDecl[chunk][index] = new XSElementDecl();
        } else {
            fElementDecl[chunk][index].reset();
        }
        fElementDeclIndex++;
        return fElementDecl[chunk][index];
    
public final com.sun.org.apache.xerces.internal.impl.xs.XSModelGroupImplgetModelGroup()

        int     chunk       = fModelGroupIndex >> CHUNK_SHIFT;
        int     index       = fModelGroupIndex &  CHUNK_MASK;
        ensureModelGroupCapacity(chunk);
        if (fModelGroup[chunk][index] == null) {
            fModelGroup[chunk][index] = new XSModelGroupImpl();
        } else {
            fModelGroup[chunk][index].reset();
        }
        fModelGroupIndex++;
        return fModelGroup[chunk][index];
    
public final com.sun.org.apache.xerces.internal.impl.xs.XSParticleDeclgetParticleDecl()

        int     chunk       = fParticleDeclIndex >> CHUNK_SHIFT;
        int     index       = fParticleDeclIndex &  CHUNK_MASK;
        ensureParticleDeclCapacity(chunk);
        if (fParticleDecl[chunk][index] == null) {
            fParticleDecl[chunk][index] = new XSParticleDecl();
        } else {
            fParticleDecl[chunk][index].reset();
        }
        fParticleDeclIndex++;
        return fParticleDecl[chunk][index];
    
public final com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDeclgetSimpleTypeDecl()

        int     chunk       = fSTDeclIndex >> CHUNK_SHIFT;
        int     index       = fSTDeclIndex &  CHUNK_MASK;
        ensureSTDeclCapacity(chunk);
        if (fSTDecl[chunk][index] == null) {
            fSTDecl[chunk][index] = new XSSimpleTypeDecl();
        } else {
            fSTDecl[chunk][index].reset();
        }
        fSTDeclIndex++;
        return fSTDecl[chunk][index];

    
public voidreset()

        fElementDeclIndex = 0;
        fParticleDeclIndex = 0;
        fModelGroupIndex = 0;
        fSTDeclIndex = 0;
        fCTDeclIndex = 0;
        fAttrDeclIndex = 0;
        fAttributeUseIndex = 0;
    
private static com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl[][]resize(com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl[][] array, int newsize)

        XSParticleDecl newarray[][] = new XSParticleDecl[newsize][];
        System.arraycopy(array, 0, newarray, 0, array.length);
        return newarray;
    
private static com.sun.org.apache.xerces.internal.impl.xs.XSModelGroupImpl[][]resize(com.sun.org.apache.xerces.internal.impl.xs.XSModelGroupImpl[][] array, int newsize)

        XSModelGroupImpl newarray[][] = new XSModelGroupImpl[newsize][];
        System.arraycopy(array, 0, newarray, 0, array.length);
        return newarray;
    
private static com.sun.org.apache.xerces.internal.impl.xs.XSAttributeDecl[][]resize(com.sun.org.apache.xerces.internal.impl.xs.XSAttributeDecl[][] array, int newsize)

        XSAttributeDecl newarray[][] = new XSAttributeDecl[newsize][];
        System.arraycopy(array, 0, newarray, 0, array.length);
        return newarray;
    
private static com.sun.org.apache.xerces.internal.impl.xs.XSAttributeUseImpl[][]resize(com.sun.org.apache.xerces.internal.impl.xs.XSAttributeUseImpl[][] array, int newsize)

        XSAttributeUseImpl newarray[][] = new XSAttributeUseImpl[newsize][];
        System.arraycopy(array, 0, newarray, 0, array.length);
        return newarray;
    
private static com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl[][]resize(com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl[][] array, int newsize)

        XSSimpleTypeDecl newarray[][] = new XSSimpleTypeDecl[newsize][];
        System.arraycopy(array, 0, newarray, 0, array.length);
        return newarray;
    
private static com.sun.org.apache.xerces.internal.impl.xs.XSComplexTypeDecl[][]resize(com.sun.org.apache.xerces.internal.impl.xs.XSComplexTypeDecl[][] array, int newsize)

        XSComplexTypeDecl newarray[][] = new XSComplexTypeDecl[newsize][];
        System.arraycopy(array, 0, newarray, 0, array.length);
        return newarray;
    
private static com.sun.org.apache.xerces.internal.impl.xs.XSElementDecl[][]resize(com.sun.org.apache.xerces.internal.impl.xs.XSElementDecl[][] array, int newsize)

        XSElementDecl newarray[][] = new XSElementDecl[newsize][];
        System.arraycopy(array, 0, newarray, 0, array.length);
        return newarray;