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

PrivateElementFilteringStateMachine

public class PrivateElementFilteringStateMachine 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 final QName[]
filteredElements
Constructors Summary
public PrivateElementFilteringStateMachine(QName filteredElements)
Creates a new instance of PrivateElementFilteringStateMachine

    
           
        
        if (filteredElements == null) {
            this.filteredElements = new QName[]{};
        } else {
            this.filteredElements = filteredElements;
        }
    
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 {
                        filteringOn = startFiltering(invocation, writer);
                        if (filteringOn) {
                            resultingState = START_FILTERING;
                        }
                    }
                    break;
                case WRITE_END_ELEMENT:
                    if (filteringOn) {
                        if (depth == 0) {
                            filteringOn = false;
                            resultingState = STOP_FILTERING;
//                            return invocation.execute(mirrorWriter);
                        } else {
                            depth--;
                        }
                    }
                    break;
                case CLOSE:
                    if (filteringOn) {
                        filteringOn = false;
                        resultingState = STOP_FILTERING;
                    }
                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 QName elementName = XmlFilteringUtils.getElementNameToWrite(invocation, XmlFilteringUtils.getDefaultNamespaceURI(writer));
        
        for (QName filteredElement : filteredElements) {
            if (filteredElement.equals(elementName)) {
                return true;
            }
        }
        
        return false;