Java Code Examples for javax.xml.namespace.QName#getLocalPart()

The following examples show how to use javax.xml.namespace.QName#getLocalPart() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
 
Example 2
Source Project: jdk8u60   File: Names.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static String getPortName(Port port) {
    String javaPortName =
        (String) port.getProperty(ModelProperties.PROPERTY_JAVA_PORT_NAME);
    if (javaPortName != null) {
        return javaPortName;
    } else {
        QName portName =
            (QName) port.getProperty(
                ModelProperties.PROPERTY_WSDL_PORT_NAME);
        if (portName != null) {
            return portName.getLocalPart();
        } else {
            String name = stripQualifier(port.getJavaInterface().getName());
            return ClassNameInfo.replaceInnerClassSym(name);
        }
    }
}
 
Example 3
public static String getPortName(Port port) {
    String javaPortName =
        (String) port.getProperty(ModelProperties.PROPERTY_JAVA_PORT_NAME);
    if (javaPortName != null) {
        return javaPortName;
    } else {
        QName portName =
            (QName) port.getProperty(
                ModelProperties.PROPERTY_WSDL_PORT_NAME);
        if (portName != null) {
            return portName.getLocalPart();
        } else {
            String name = stripQualifier(port.getJavaInterface().getName());
            return ClassNameInfo.replaceInnerClassSym(name);
        }
    }
}
 
Example 4
private void handleStartElement(StartElement event) throws SAXException {
    // start namespace bindings
    for (Iterator i = event.getNamespaces(); i.hasNext();) {
        Namespace ns = (Namespace)i.next();
        visitor.startPrefixMapping(
            fixNull(ns.getPrefix()),
            fixNull(ns.getNamespaceURI()));
    }

    // fire startElement
    QName qName = event.getName();
    tagName.uri = fixNull(qName.getNamespaceURI());
    String localName = qName.getLocalPart();
    tagName.uri = fixNull(qName.getNamespaceURI());
    tagName.local = localName;
    tagName.atts = getAttributes(event);
    visitor.startElement(tagName);

    seenText = false;
}
 
Example 5
public SOAPElement setElementQName(QName newName) throws SOAPException {
   log.log(Level.SEVERE,
           "SAAJ0146.impl.invalid.name.change.requested",
           new Object[] {elementQName.getLocalPart(),
                         newName.getLocalPart()});
   throw new SOAPException("Cannot change name for "
                           + elementQName.getLocalPart() + " to "
                           + newName.getLocalPart());
}
 
Example 6
/**
 * Annotate the attribute property 'field'
 */
private void annotateAttribute(JAnnotatable field) {
    CAttributePropertyInfo ap = (CAttributePropertyInfo) prop;
    QName attName = ap.getXmlName();

    // [RESULT]
    // @XmlAttribute(name="foo", required=true, namespace="bar://baz")
    XmlAttributeWriter xaw = field.annotate2(XmlAttributeWriter.class);

    final String generatedName = attName.getLocalPart();
    final String generatedNS = attName.getNamespaceURI();

    // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value
    // generate name property?
    if(!generatedName.equals(ap.getName(false)) || !generatedName.equals(ap.getName(true)) || (outline.parent().getModel().getNameConverter() != NameConverter.standard)) {
        xaw.name(generatedName);
    }

    // generate namespace property?
    if(!generatedNS.equals("")) { // assume attributeFormDefault == unqualified
        xaw.namespace(generatedNS);
    }

    // generate required property?
    if(ap.isRequired()) {
        xaw.required(true);
    }
}
 
Example 7
Source Project: steady   File: SupportingTokensBuilder.java    License: Apache License 2.0 5 votes vote down vote up
private void processAlternative(List<Assertion> assertions, SupportingToken supportingToken) {

        for (Assertion primitive : assertions) {
            QName qname = primitive.getName();
            String localName = qname.getLocalPart();
            
            if (SPConstants.ALGO_SUITE.equals(localName)) {
                supportingToken.setAlgorithmSuite((AlgorithmSuite)primitive);

            } else if (SPConstants.SIGNED_PARTS.equals(localName)) {
                supportingToken.setSignedParts((SignedEncryptedParts)primitive);

            } else if (SPConstants.SIGNED_ELEMENTS.equals(localName)) {
                supportingToken.setSignedElements((SignedEncryptedElements)primitive);

            } else if (SPConstants.ENCRYPTED_PARTS.equals(localName)) {
                supportingToken.setEncryptedParts((SignedEncryptedParts)primitive);

            } else if (SPConstants.ENCRYPTED_ELEMENTS.equals(localName)) {
                supportingToken.setEncryptedElements((SignedEncryptedElements)primitive);

            } else if (primitive instanceof Token) {
                supportingToken.addToken((Token)primitive);
                ((Token)primitive).setSupportingToken(supportingToken);
            }
        }
    }
 
Example 8
Source Project: hottub   File: ElementImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public ElementImpl(SOAPDocumentImpl ownerDoc, QName name) {
    super(
        ownerDoc,
        name.getNamespaceURI(),
        getQualifiedName(name),
        name.getLocalPart());
    elementQName = name;
}
 
Example 9
@Override
public POMComponent create(POMComponent context, QName qName) {
   String prefix = qName.getPrefix();
   if (prefix == null || prefix.length() == 0) {
       prefix = qName.getLocalPart();
   } else {
       prefix = prefix + ":" + qName.getLocalPart();
   }

   ElementFactory factory = ElementFactoryRegistry.getDefault().get(qName);
   Element element = model.getDocument().createElementNS(qName.getNamespaceURI(), prefix);
   return create(factory, element, context);
}
 
Example 10
private JAXBMessage(XMLBridge bridge, Object jaxbObject, SOAPVersion soapVer) {
    super(soapVer);
    // TODO: think about a better way to handle BridgeContext
    this.bridge = bridge;
    this.rawContext = null;
    this.jaxbObject = jaxbObject;
    QName tagName = bridge.getTypeInfo().tagName;
    this.nsUri = tagName.getNamespaceURI();
    this.localName = tagName.getLocalPart();
    this.attachmentSet = new AttachmentSetImpl();
}
 
Example 11
public JAXBHeader(XMLBridge bridge, Object jaxbObject) {
    this.jaxbObject = jaxbObject;
    this.bridge = bridge;

    QName tagName = bridge.getTypeInfo().tagName;
    this.nsUri = tagName.getNamespaceURI();
    this.localName = tagName.getLocalPart();
}
 
Example 12
/**
 * Get the attributes associated with the given START_ELEMENT StAXevent.
 *
 * @return the StAX attributes converted to an org.xml.sax.Attributes
 */
private Attributes getAttributes(StartElement event) {
    attrs.clear();

    // in SAX, namespace declarations are not part of attributes by default.
    // (there's a property to control that, but as far as we are concerned
    // we don't use it.) So don't add xmlns:* to attributes.

    // gather non-namespace attrs
    for (Iterator i = event.getAttributes(); i.hasNext();) {
        Attribute staxAttr = (Attribute)i.next();

        QName name = staxAttr.getName();
        String uri = fixNull(name.getNamespaceURI());
        String localName = name.getLocalPart();
        String prefix = name.getPrefix();
        String qName;
        if (prefix == null || prefix.length() == 0)
            qName = localName;
        else
            qName = prefix + ':' + localName;
        String type = staxAttr.getDTDType();
        String value = staxAttr.getValue();

        attrs.addAttribute(uri, localName, qName, type, value);
    }

    return attrs;
}
 
Example 13
public ElementImpl(SOAPDocumentImpl ownerDoc, QName name) {
    super(
        ownerDoc,
        name.getNamespaceURI(),
        getQualifiedName(name),
        name.getLocalPart());
    elementQName = name;
}
 
Example 14
Source Project: steady   File: SpnegoContextToken.java    License: Apache License 2.0 4 votes vote down vote up
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
    QName name = constants.getSpnegoContextToken();
    String localname = name.getLocalPart();
    String namespaceURI = name.getNamespaceURI();
    String prefix;

    String writerPrefix = writer.getPrefix(namespaceURI);

    if (writerPrefix == null) {
        prefix = name.getPrefix();
        writer.setPrefix(prefix, namespaceURI);
    } else {
        prefix = writerPrefix;
    }

    // <sp:SpnegoContextToken>
    writer.writeStartElement(prefix, localname, namespaceURI);

    if (writerPrefix == null) {
        // xmlns:sp=".."
        writer.writeNamespace(prefix, namespaceURI);
    }

    String inclusion;

    inclusion = constants.getAttributeValueFromInclusion(getInclusion());

    if (inclusion != null) {
        writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
    }

    if (issuerEpr != null) {
        // <sp:Issuer>
        writer.writeStartElement(prefix, SPConstants.ISSUER, namespaceURI);

        StaxUtils.copy(issuerEpr, writer);

        writer.writeEndElement();
    }

    if (isDerivedKeys()) {

        String wspNamespaceURI = SPConstants.POLICY.getNamespaceURI();

        String wspPrefix;

        String wspWriterPrefix = writer.getPrefix(wspNamespaceURI);

        if (wspWriterPrefix == null) {
            wspPrefix = SPConstants.POLICY.getPrefix();
            writer.setPrefix(wspPrefix, wspNamespaceURI);

        } else {
            wspPrefix = wspWriterPrefix;
        }

        // <wsp:Policy>
        writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), wspNamespaceURI);

        if (wspWriterPrefix == null) {
            // xmlns:wsp=".."
            writer.writeNamespace(wspPrefix, wspNamespaceURI);
        }

        if (isDerivedKeys()) {
            // <sp:RequireDerivedKeys />
            writer.writeEmptyElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI);
        }

        // </wsp:Policy>
        writer.writeEndElement();
    }

    // </sp:SpnegoContextToken>
    writer.writeEndElement();
}
 
Example 15
Source Project: steady   File: SpnegoContextToken.java    License: Apache License 2.0 4 votes vote down vote up
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
    QName name = constants.getSpnegoContextToken();
    String localname = name.getLocalPart();
    String namespaceURI = name.getNamespaceURI();
    String prefix;

    String writerPrefix = writer.getPrefix(namespaceURI);

    if (writerPrefix == null) {
        prefix = name.getPrefix();
        writer.setPrefix(prefix, namespaceURI);
    } else {
        prefix = writerPrefix;
    }

    // <sp:SpnegoContextToken>
    writer.writeStartElement(prefix, localname, namespaceURI);

    if (writerPrefix == null) {
        // xmlns:sp=".."
        writer.writeNamespace(prefix, namespaceURI);
    }

    String inclusion;

    inclusion = constants.getAttributeValueFromInclusion(getInclusion());

    if (inclusion != null) {
        writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
    }

    if (issuerEpr != null) {
        // <sp:Issuer>
        writer.writeStartElement(prefix, SPConstants.ISSUER, namespaceURI);

        StaxUtils.copy(issuerEpr, writer);

        writer.writeEndElement();
    }

    if (isDerivedKeys()) {

        String wspNamespaceURI = SPConstants.POLICY.getNamespaceURI();

        String wspPrefix;

        String wspWriterPrefix = writer.getPrefix(wspNamespaceURI);

        if (wspWriterPrefix == null) {
            wspPrefix = SPConstants.POLICY.getPrefix();
            writer.setPrefix(wspPrefix, wspNamespaceURI);

        } else {
            wspPrefix = wspWriterPrefix;
        }

        // <wsp:Policy>
        writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), wspNamespaceURI);

        if (wspWriterPrefix == null) {
            // xmlns:wsp=".."
            writer.writeNamespace(wspPrefix, wspNamespaceURI);
        }

        if (isDerivedKeys()) {
            // <sp:RequireDerivedKeys />
            writer.writeEmptyElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI);
        }

        // </wsp:Policy>
        writer.writeEndElement();
    }

    // </sp:SpnegoContextToken>
    writer.writeEndElement();
}
 
Example 16
Source Project: steady   File: UsernameToken.java    License: Apache License 2.0 4 votes vote down vote up
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
    QName name = constants.getUserNameToken();
    String localname = name.getLocalPart();
    String namespaceURI = name.getNamespaceURI();

    String prefix = writer.getPrefix(namespaceURI);
    if (prefix == null) {
        prefix = name.getPrefix();
        writer.setPrefix(prefix, namespaceURI);
    }

    // <sp:UsernameToken
    writer.writeStartElement(prefix, localname, namespaceURI);

    writer.writeNamespace(prefix, namespaceURI);

    String inclusion;

    inclusion = constants.getAttributeValueFromInclusion(getInclusion());

    if (inclusion != null) {
        writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
    }

    if (isUseUTProfile10() || isUseUTProfile11()) {
        String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
        if (pPrefix == null) {
            pPrefix = SPConstants.POLICY.getPrefix();
            writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI());
        }

        // <wsp:Policy>
        writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY
            .getNamespaceURI());

        // CHECKME
        if (isUseUTProfile10()) {
            // <sp:WssUsernameToken10 />
            writer.writeStartElement(prefix, SPConstants.USERNAME_TOKEN10, namespaceURI);
        } else {
            // <sp:WssUsernameToken11 />
            writer.writeStartElement(prefix, SPConstants.USERNAME_TOKEN11, namespaceURI);
        }

        if (constants.getVersion() == SPConstants.Version.SP_V12) {

            if (isNoPassword()) {
                writer.writeStartElement(prefix, SPConstants.NO_PASSWORD, namespaceURI);
                writer.writeEndElement();
            } else if (isHashPassword()) {
                writer.writeStartElement(prefix, SPConstants.HASH_PASSWORD, namespaceURI);
                writer.writeEndElement();
            }

            if (isDerivedKeys()) {
                writer.writeStartElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI);
                writer.writeEndElement();
            } else if (isExplicitDerivedKeys()) {
                writer.writeStartElement(prefix, SPConstants.REQUIRE_EXPLICIT_DERIVED_KEYS, namespaceURI);
                writer.writeEndElement();
            } else if (isImpliedDerivedKeys()) {
                writer.writeStartElement(prefix, SPConstants.REQUIRE_IMPLIED_DERIVED_KEYS, namespaceURI);
                writer.writeEndElement();
            }
            
            if (isRequireCreated()) {
                writer.writeStartElement(SP13Constants.SP_PREFIX, "Created", SP13Constants.SP_NS);
                writer.writeNamespace(SP13Constants.SP_PREFIX, SP13Constants.SP_NS);
                writer.writeEndElement();
            }
            if (isRequireNonce()) {
                writer.writeStartElement(SP13Constants.SP_PREFIX, "Nonce", SP13Constants.SP_NS);
                writer.writeNamespace(SP13Constants.SP_PREFIX, SP13Constants.SP_NS);
                writer.writeEndElement();
            }

        }
        writer.writeEndElement();

        // </wsp:Policy>
        writer.writeEndElement();

    }

    writer.writeEndElement();
    // </sp:UsernameToken>

}
 
Example 17
protected PropertyGetter getPropertyGetter(QName name) {
    Object key = (elementLocalNameCollision) ? name : name.getLocalPart();
    return propertyGetters.get(key);
}
 
Example 18
Source Project: steady   File: UsernameToken.java    License: Apache License 2.0 4 votes vote down vote up
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
    QName name = constants.getUserNameToken();
    String localname = name.getLocalPart();
    String namespaceURI = name.getNamespaceURI();

    String prefix = writer.getPrefix(namespaceURI);
    if (prefix == null) {
        prefix = name.getPrefix();
        writer.setPrefix(prefix, namespaceURI);
    }

    // <sp:UsernameToken
    writer.writeStartElement(prefix, localname, namespaceURI);

    writer.writeNamespace(prefix, namespaceURI);

    String inclusion;

    inclusion = constants.getAttributeValueFromInclusion(getInclusion());

    if (inclusion != null) {
        writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
    }

    if (isUseUTProfile10() || isUseUTProfile11()) {
        String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
        if (pPrefix == null) {
            pPrefix = SPConstants.POLICY.getPrefix();
            writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI());
        }

        // <wsp:Policy>
        writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY
            .getNamespaceURI());

        // CHECKME
        if (isUseUTProfile10()) {
            // <sp:WssUsernameToken10 />
            writer.writeStartElement(prefix, SPConstants.USERNAME_TOKEN10, namespaceURI);
        } else {
            // <sp:WssUsernameToken11 />
            writer.writeStartElement(prefix, SPConstants.USERNAME_TOKEN11, namespaceURI);
        }

        if (constants.getVersion() == SPConstants.Version.SP_V12) {

            if (isNoPassword()) {
                writer.writeStartElement(prefix, SPConstants.NO_PASSWORD, namespaceURI);
                writer.writeEndElement();
            } else if (isHashPassword()) {
                writer.writeStartElement(prefix, SPConstants.HASH_PASSWORD, namespaceURI);
                writer.writeEndElement();
            }

            if (isDerivedKeys()) {
                writer.writeStartElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI);
                writer.writeEndElement();
            } else if (isExplicitDerivedKeys()) {
                writer.writeStartElement(prefix, SPConstants.REQUIRE_EXPLICIT_DERIVED_KEYS, namespaceURI);
                writer.writeEndElement();
            } else if (isImpliedDerivedKeys()) {
                writer.writeStartElement(prefix, SPConstants.REQUIRE_IMPLIED_DERIVED_KEYS, namespaceURI);
                writer.writeEndElement();
            }
            
            if (isRequireCreated()) {
                writer.writeStartElement(SP13Constants.SP_PREFIX, "Created", SP13Constants.SP_NS);
                writer.writeNamespace(SP13Constants.SP_PREFIX, SP13Constants.SP_NS);
                writer.writeEndElement();
            }
            if (isRequireNonce()) {
                writer.writeStartElement(SP13Constants.SP_PREFIX, "Nonce", SP13Constants.SP_NS);
                writer.writeNamespace(SP13Constants.SP_PREFIX, SP13Constants.SP_NS);
                writer.writeEndElement();
            }

        }
        writer.writeEndElement();

        // </wsp:Policy>
        writer.writeEndElement();

    }

    writer.writeEndElement();
    // </sp:UsernameToken>

}
 
Example 19
Source Project: steady   File: KeyValueToken.java    License: Apache License 2.0 4 votes vote down vote up
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
    QName name = constants.getUserNameToken();
    String localname = name.getLocalPart();
    String namespaceURI = name.getNamespaceURI();

    String prefix = writer.getPrefix(namespaceURI);
    if (prefix == null) {
        prefix = name.getPrefix();
        writer.setPrefix(prefix, namespaceURI);
    }

    // <sp:KeyValueToken
    writer.writeStartElement(prefix, localname, namespaceURI);

    writer.writeNamespace(prefix, namespaceURI);

    String inclusion;

    inclusion = constants.getAttributeValueFromInclusion(getInclusion());

    if (inclusion != null) {
        writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
    }


    if (forceRsaKeyValue) {
        String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
        if (pPrefix == null) {
            writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI());
        }

        // <wsp:Policy>
        writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY
            .getNamespaceURI());
        
        writer.writeEmptyElement(prefix, "RsaKeyValue", namespaceURI);

        // </wsp:Policy>
        writer.writeEndElement();

    }
    writer.writeEndElement();
    // </sp:KeyValueToken>

}
 
Example 20
Source Project: steady   File: SpnegoContextToken.java    License: Apache License 2.0 4 votes vote down vote up
public void serialize(XMLStreamWriter writer) throws XMLStreamException {
    QName name = constants.getSpnegoContextToken();
    String localname = name.getLocalPart();
    String namespaceURI = name.getNamespaceURI();
    String prefix;

    String writerPrefix = writer.getPrefix(namespaceURI);

    if (writerPrefix == null) {
        prefix = name.getPrefix();
        writer.setPrefix(prefix, namespaceURI);
    } else {
        prefix = writerPrefix;
    }

    // <sp:SpnegoContextToken>
    writer.writeStartElement(prefix, localname, namespaceURI);

    if (writerPrefix == null) {
        // xmlns:sp=".."
        writer.writeNamespace(prefix, namespaceURI);
    }

    String inclusion;

    inclusion = constants.getAttributeValueFromInclusion(getInclusion());

    if (inclusion != null) {
        writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
    }

    if (issuerEpr != null) {
        // <sp:Issuer>
        writer.writeStartElement(prefix, SPConstants.ISSUER, namespaceURI);

        StaxUtils.copy(issuerEpr, writer);

        writer.writeEndElement();
    }

    if (isDerivedKeys()) {

        String wspNamespaceURI = SPConstants.POLICY.getNamespaceURI();

        String wspPrefix;

        String wspWriterPrefix = writer.getPrefix(wspNamespaceURI);

        if (wspWriterPrefix == null) {
            wspPrefix = SPConstants.POLICY.getPrefix();
            writer.setPrefix(wspPrefix, wspNamespaceURI);

        } else {
            wspPrefix = wspWriterPrefix;
        }

        // <wsp:Policy>
        writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), wspNamespaceURI);

        if (wspWriterPrefix == null) {
            // xmlns:wsp=".."
            writer.writeNamespace(wspPrefix, wspNamespaceURI);
        }

        if (isDerivedKeys()) {
            // <sp:RequireDerivedKeys />
            writer.writeEmptyElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI);
        }

        // </wsp:Policy>
        writer.writeEndElement();
    }

    // </sp:SpnegoContextToken>
    writer.writeEndElement();
}