FileDocCategorySizeDatePackage
CMNodeFactory.javaAPI DocJava SE 6 API5803Tue Jun 10 00:22:46 BST 2008com.sun.org.apache.xerces.internal.impl.xs.models

CMNodeFactory

public class CMNodeFactory extends Object
xerces.internal
author
Neeraj Bajaj

Fields Summary
private static final String
ERROR_REPORTER
Property identifier: error reporter.
private static final String
SECURITY_MANAGER
property identifier: security manager.
private static final boolean
DEBUG
private static final int
MULTIPLICITY
private int
nodeCount
private int
maxNodeLimit
private XMLErrorReporter
fErrorReporter
Error reporter. This property identifier is: http://apache.org/xml/properties/internal/error-reporter
private SecurityManager
fSecurityManager
Constructors Summary
public CMNodeFactory()
default constructor

    
       
      
    
Methods Summary
public com.sun.org.apache.xerces.internal.impl.dtd.models.CMNodegetCMBinOpNode(int type, com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode leftNode, com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode rightNode)

        return new XSCMBinOp(type, leftNode, rightNode) ;
    
public com.sun.org.apache.xerces.internal.impl.dtd.models.CMNodegetCMLeafNode(int type, java.lang.Object leaf, int id, int position)

        return new XSCMLeaf(type, leaf, id, position) ;
    
public com.sun.org.apache.xerces.internal.impl.dtd.models.CMNodegetCMUniOpNode(int type, com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode childNode)

        return new XSCMUniOp(type, childNode) ;
    
public voidnodeCountCheck()

        if( fSecurityManager != null && nodeCount++ > maxNodeLimit){
            if(DEBUG){
                System.out.println("nodeCount = " + nodeCount ) ;
                System.out.println("nodeLimit = " + maxNodeLimit ) ;
            }
            fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN, "maxOccurLimit", new Object[]{ new Integer(maxNodeLimit) }, XMLErrorReporter.SEVERITY_FATAL_ERROR);
            // similarly to entity manager behaviour, take into accont
            // behaviour if continue-after-fatal-error is set.
            nodeCount = 0;
        }
        
    
public voidreset(com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager componentManager)

        fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
        try {
            fSecurityManager = (SecurityManager)componentManager.getProperty(SECURITY_MANAGER);
            //we are setting the limit of number of nodes to 3times the maxOccur value..
            if(fSecurityManager != null){
                maxNodeLimit = fSecurityManager.getMaxOccurNodeLimit() * MULTIPLICITY ;
            }
        }
        catch (XMLConfigurationException e) {
            fSecurityManager = null;
        }
        
    
public voidresetNodeCount()

        nodeCount = 0 ;
    
public voidsetProperty(java.lang.String propertyId, java.lang.Object value)
Sets the value of a property. This method is called by the component manager any time after reset when a property changes value.

Note: Components should silently ignore properties that do not affect the operation of the component.

param
propertyId The property identifier.
param
value The value of the property.
throws
SAXNotRecognizedException The component should not throw this exception.
throws
SAXNotSupportedException The component should not throw this exception.


        // Xerces properties
        if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
        	final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
        	
            if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() && 
                propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
                fSecurityManager = (SecurityManager)value;                
                maxNodeLimit = (fSecurityManager != null) ? fSecurityManager.getMaxOccurNodeLimit() * MULTIPLICITY : 0 ;
                return;
            }
            if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() && 
                propertyId.endsWith(Constants.ERROR_REPORTER_PROPERTY)) {
                fErrorReporter = (XMLErrorReporter)value;
                return;
            }
        }