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

XmlFilteringUtils

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

Fields Summary
private static final com.sun.xml.ws.policy.privateutil.PolicyLogger
LOGGER
Constructors Summary
private XmlFilteringUtils()
Prevents creation of a new instance of XmlFilteringUtils

   
                   
      
        // nothing to initialize
    
Methods Summary
private static voidcheckInvocationParameter(com.sun.xml.ws.policy.jaxws.xmlstreamwriter.Invocation invocation, com.sun.xml.ws.policy.jaxws.xmlstreamwriter.XmlStreamWriterMethodType expectedType)

        if (invocation == null) {
            throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_1038_METHOD_PARAMETER_CANNOT_BE_NULL("Invocation parameter")));
        } else {
            if (invocation.getMethodType() != expectedType) {
                throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_1039_ILLEGAL_INVOCATION_METHOD_TYPE(invocation.getMethodType(), expectedType)));
            }
        }
    
public static com.sun.xml.ws.policy.jaxws.xmlstreamwriter.documentfilter.XmlFilteringUtils$AttributeInfogetAttributeNameToWrite(com.sun.xml.ws.policy.jaxws.xmlstreamwriter.Invocation invocation, java.lang.String defaultNamespaceURI)

        checkInvocationParameter(invocation, XmlStreamWriterMethodType.WRITE_ATTRIBUTE);
        
        /*
         * void writeAttribute(String localName, String value)
         * void writeAttribute(String namespaceURI, String localName, String value)
         * void writeAttribute(String prefix, String namespaceURI, String localName, String value)
         */
        final int argumentsCount = invocation.getArgumentsCount();
        String namespaceURI, localName, value;
        
        switch (argumentsCount) {
            case 2:
                namespaceURI = defaultNamespaceURI;
                localName = invocation.getArgument(0).toString();
                value = invocation.getArgument(1).toString();
                break;
            case 3:
                namespaceURI = invocation.getArgument(0).toString();
                localName = invocation.getArgument(1).toString();
                value = invocation.getArgument(2).toString();
                break;
            case 4:
                namespaceURI = invocation.getArgument(1).toString();
                localName = invocation.getArgument(2).toString();
                value = invocation.getArgument(3).toString();
                break;
            default:
                throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_1009_UNEXPECTED_ARGUMENTS_COUNT(XmlStreamWriterMethodType.WRITE_ATTRIBUTE + "(...)", argumentsCount)));
        }
        
        return new AttributeInfo(new QName(namespaceURI, localName), value);
    
public static java.lang.StringgetDefaultNamespaceURI(javax.xml.stream.XMLStreamWriter writer)

        return writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
    
public static javax.xml.namespace.QNamegetElementNameToWrite(com.sun.xml.ws.policy.jaxws.xmlstreamwriter.Invocation invocation, java.lang.String defaultNamespaceURI)

        checkInvocationParameter(invocation, XmlStreamWriterMethodType.WRITE_START_ELEMENT);
        
        /**
         * void writeStartElement(String localName)
         * void writeStartElement(String namespaceURI, String localName)
         * void writeStartElement(String prefix, String localName, String namespaceURI)
         */
        final int argumentsCount = invocation.getArgumentsCount();
        final String namespaceURI;
        final String localName;
        
        switch (argumentsCount) {
            case 1:
                namespaceURI = defaultNamespaceURI;
                localName = invocation.getArgument(0).toString();
                break;
            case 2:
                namespaceURI = invocation.getArgument(0).toString();
                localName = invocation.getArgument(1).toString();
                break;
            case 3:
                localName = invocation.getArgument(1).toString();
                namespaceURI = invocation.getArgument(2).toString();
                break;
            default:
                throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_1009_UNEXPECTED_ARGUMENTS_COUNT(XmlStreamWriterMethodType.WRITE_START_ELEMENT + "(...)", argumentsCount)));
        }
        
        return new QName(namespaceURI, localName);