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

PrivateAttributeFilteringStateMachine

public class PrivateAttributeFilteringStateMachine 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 int
depth
private boolean
filteringOn
private boolean
cmdBufferingOn
Constructors Summary
public PrivateAttributeFilteringStateMachine()
Creates a new instance of PrivateAttributeFilteringStateMachine

 // indicates whether the commands should be buffered or whether they can be directly executed on the underlying XML output stream
    
    
           
      
        // 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 (filteringOn) {
                        depth++;
                    } else if (cmdBufferingOn) {
                        resultingState = RESTART_BUFFERING;
                    } else {
                        cmdBufferingOn = true;
                        resultingState = START_BUFFERING;
                    }
                    break;
                case WRITE_END_ELEMENT:
                    if (filteringOn) {
                        if (depth == 0) {
                            filteringOn = false;
                            resultingState = STOP_FILTERING;
                        } else {
                            depth--;
                        }
                    } else if (cmdBufferingOn) {
                        cmdBufferingOn = false;
                        resultingState = STOP_BUFFERING;
                    }
                    break;
                case WRITE_ATTRIBUTE:
                    if (!filteringOn && cmdBufferingOn && startFiltering(invocation, writer)) {
                        filteringOn = true;
                        cmdBufferingOn = false;
                        resultingState = START_FILTERING;
                    }
                    break;
                case CLOSE:
                    if (filteringOn) {
                        filteringOn = false;
                        resultingState = STOP_FILTERING;
                    } else if (cmdBufferingOn) {
                        cmdBufferingOn = false;
                        resultingState = STOP_BUFFERING;
                    }
                    break;
                default:
                    break;
            }
            
            return resultingState;            
        } finally {
            LOGGER.exiting(resultingState);
        }
    
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 VISIBILITY_ATTRIBUTE.equals(attributeInfo.getName()) && VISIBILITY_VALUE_PRIVATE.equals(attributeInfo.getValue());