FileDocCategorySizeDatePackage
MexImportFilteringStateMachine.javaAPI DocExample6424Tue May 29 16:56:38 BST 2007com.sun.xml.ws.policy.jaxws.xmlstreamwriter.documentfilter

MexImportFilteringStateMachine

public final class MexImportFilteringStateMachine extends Object implements FilteringStateMachine
author
Marek Potociar (marek.potociar at sun.com)

Fields Summary
private static final com.sun.xml.ws.policy.privateutil.PolicyLogger
LOGGER
private static final String
MEX_NAMESPACE
private static final String
WSDL_NAMESPACE
private static final QName
WSDL_IMPORT_ELEMENT
private static final QName
IMPORT_NAMESPACE_ATTIBUTE
private int
depth
private StateMachineMode
currentMode
Constructors Summary
public MexImportFilteringStateMachine()
Creates a new instance of MexImportFilteringStateMachine

 // indicates that current mode of the filtering state machine
    
           
      
        // nothing to initialize
    
Methods Summary
public InvocationProcessingStategetState(com.sun.xml.ws.policy.jaxws.xmlstreamwriter.Invocation invocation, javax.xml.stream.XMLStreamWriter writer)

        LOGGER.entering(invocation);
        InvocationProcessingState resultingState = NO_STATE_CHANGE;
        try {
            switch (invocation.getMethodType()) {
                case WRITE_START_ELEMENT:
                    if (currentMode == StateMachineMode.INACTIVE) {
                        if (startBuffering(invocation, writer)) {
                            resultingState = START_BUFFERING;
                            currentMode = StateMachineMode.BUFFERING;
                        }
                    } else {
                        depth++;
                    }
                    break;
                case WRITE_END_ELEMENT:
                    if (currentMode != StateMachineMode.INACTIVE) {
                        if (depth == 0) {
                            resultingState = (currentMode == StateMachineMode.BUFFERING) ? STOP_BUFFERING : STOP_FILTERING;
                            currentMode = StateMachineMode.INACTIVE;
                        } else {
                            depth--;
                        }
                    }
                    break;
                case WRITE_ATTRIBUTE:
                    if (currentMode == StateMachineMode.BUFFERING && startFiltering(invocation, writer)) {
                        resultingState = START_FILTERING;
                        currentMode = StateMachineMode.FILTERING;
                    }
                    break;
                case CLOSE:
                    switch (currentMode) {
                        case BUFFERING:
                            resultingState = STOP_BUFFERING; break;
                        case FILTERING:
                            resultingState = STOP_FILTERING; break;
                    }
                    currentMode = StateMachineMode.INACTIVE;
                    break;
                default:
                    break;
            }
            
            return resultingState;
            
        } finally {
            LOGGER.exiting(resultingState);
        }
    
private booleanstartBuffering(com.sun.xml.ws.policy.jaxws.xmlstreamwriter.Invocation invocation, javax.xml.stream.XMLStreamWriter writer)

        final QName elementName = XmlFilteringUtils.getElementNameToWrite(invocation, XmlFilteringUtils.getDefaultNamespaceURI(writer));
        return WSDL_IMPORT_ELEMENT.equals(elementName);
    
private booleanstartFiltering(com.sun.xml.ws.policy.jaxws.xmlstreamwriter.Invocation invocation, javax.xml.stream.XMLStreamWriter writer)

        final XmlFilteringUtils.AttributeInfo attributeInfo = XmlFilteringUtils.getAttributeNameToWrite(invocation, XmlFilteringUtils.getDefaultNamespaceURI(writer));
        return IMPORT_NAMESPACE_ATTIBUTE.equals(attributeInfo.getName()) && MEX_NAMESPACE.equals(attributeInfo.getValue());