Example usage for javax.xml.namespace QName getLocalPart

List of usage examples for javax.xml.namespace QName getLocalPart

Introduction

In this page you can find the example usage for javax.xml.namespace QName getLocalPart.

Prototype

public String getLocalPart() 

Source Link

Document

Get the local part of this QName.

Usage

From source file:org.apache.axis.message.MessageElement.java

/**
 * constructor declaring the qualified name of the node
 * and its value//from  ww  w. j a  v a2s  .c  o  m
 * @param name naming information
 * @param value value of the node
 */
public MessageElement(QName name, Object value) {
    this(name.getNamespaceURI(), name.getLocalPart());
    objectValue = value;
}

From source file:org.apache.axis.message.MessageElement.java

/**
 * set the name and namespace of this element
 * @param qName qualified name/*from  w  w w .j a  v  a 2s. c  o  m*/
 */
public void setQName(QName qName) {
    this.name = qName.getLocalPart();
    this.namespaceURI = qName.getNamespaceURI();
}

From source file:org.apache.axis.message.MessageElement.java

/** This is the public output() method, which will always simply use
 * the recorded SAX stream for this element if it is available.  If
 * not, this method calls outputImpl() to allow subclasses and
 * programmatically created messages to serialize themselves.
 *
 * @param outputContext the SerializationContext we will write to.
 *//* www.j  a v  a2  s  . c  o m*/
public final void output(SerializationContext outputContext) throws Exception {
    if ((recorder != null) && (!_isDirty)) {
        recorder.replay(startEventIndex, endEventIndex, new SAXOutputter(outputContext));
        return;
    }

    // Turn QName attributes into strings
    if (qNameAttrs != null) {
        for (int i = 0; i < qNameAttrs.size(); i++) {
            QNameAttr attr = (QNameAttr) qNameAttrs.get(i);
            QName attrName = attr.name;
            setAttribute(attrName.getNamespaceURI(), attrName.getLocalPart(),
                    outputContext.qName2String(attr.value));
        }
    }

    /**
     * Write the encoding style attribute IF it's different from
     * whatever encoding style is in scope....
     */
    if (encodingStyle != null) {
        MessageContext mc = outputContext.getMessageContext();
        SOAPConstants soapConstants = (mc != null) ? mc.getSOAPConstants() : SOAPConstants.SOAP11_CONSTANTS;
        if (parent == null) {
            // don't emit an encoding style if its "" (literal)
            if (!"".equals(encodingStyle)) {
                setAttribute(soapConstants.getEnvelopeURI(), Constants.ATTR_ENCODING_STYLE, encodingStyle);
            }
        } else if (!encodingStyle.equals(((MessageElement) parent).getEncodingStyle())) {
            setAttribute(soapConstants.getEnvelopeURI(), Constants.ATTR_ENCODING_STYLE, encodingStyle);
        }
    }

    outputImpl(outputContext);
}

From source file:org.apache.axis.message.MessageElement.java

/**
 * get an iterator over child elements//from   w  w w.  j  a  v  a 2  s  .  co  m
 * @param qname namespace/element name of parts to find.
 * This iterator is not (currently) susceptible to change in the element
 * list during its lifetime, though changes in the contents of the elements
 * are picked up.
 * @return an iterator.
 */
public Iterator getChildElements(QName qname) {
    initializeChildren();
    int num = children.size();
    Vector c = new Vector(num);
    for (int i = 0; i < num; i++) {
        MessageElement child = (MessageElement) children.get(i);
        Name cname = child.getElementName();
        if (cname.getURI().equals(qname.getNamespaceURI())
                && cname.getLocalName().equals(qname.getLocalPart())) {
            c.add(child);
        }
    }
    return c.iterator();
}

From source file:org.apache.axis.utils.WSDLUtils.java

/**
 * Return the endpoint address from a <soap:address location="..."> tag
 *//*from w w  w  .  j ava2 s.c  om*/
public static String getAddressFromPort(Port p) {
    // Get the endpoint for a port
    List extensibilityList = p.getExtensibilityElements();
    for (ListIterator li = extensibilityList.listIterator(); li.hasNext();) {
        Object obj = li.next();
        if (obj instanceof SOAPAddress) {
            return ((SOAPAddress) obj).getLocationURI();
        } else if (obj instanceof UnknownExtensibilityElement) {
            //TODO: After WSDL4J supports soap12, change this code
            UnknownExtensibilityElement unkElement = (UnknownExtensibilityElement) obj;
            QName name = unkElement.getElementType();
            if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP)
                    && name.getLocalPart().equals("address")) {
                return unkElement.getElement().getAttribute("location");
            }
        }
    }
    // didn't find it
    return null;
}

From source file:org.apache.axis.utils.XMLUtils.java

/**
 * Return a string for a particular QName, mapping a new prefix
 * if necessary./*from  ww w  .j a va  2s  .c om*/
 */
public static String getStringForQName(QName qname, Element e) {
    String uri = qname.getNamespaceURI();
    String prefix = getPrefix(uri, e);
    if (prefix == null) {
        int i = 1;
        prefix = "ns" + i;
        while (getNamespace(prefix, e) != null) {
            i++;
            prefix = "ns" + i;
        }
        e.setAttributeNS(Constants.NS_URI_XMLNS, "xmlns:" + prefix, uri);
    }
    return prefix + ":" + qname.getLocalPart();
}

From source file:org.apache.axis.wsdl.fromJava.Emitter.java

/**
 * Build a Types object and load the input wsdl types
 * //  w  w w  .  jav  a  2s .co m
 * @param def Corresponding wsdl Definition
 * @return Types object
 * @throws IOException                  
 * @throws WSDLException                
 * @throws SAXException                 
 * @throws ParserConfigurationException 
 */
protected Types createTypes(Definition def)
        throws IOException, WSDLException, SAXException, ParserConfigurationException {

    types = new Types(def, tm, (TypeMapping) tmr.getDefaultTypeMapping(), namespaces, intfNS, stopClasses,
            serviceDesc, this);

    if (inputWSDL != null) {
        types.loadInputTypes(inputWSDL);
    }

    if (inputSchema != null) {
        StringTokenizer tokenizer = new StringTokenizer(inputSchema, ", ");

        while (tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken();

            types.loadInputSchema(token);
        }
    }

    // If we're supposed to emit all mapped types, do it now.
    if (emitAllTypes && tm != null) {
        Class[] mappedTypes = tm.getAllClasses();

        for (int i = 0; i < mappedTypes.length; i++) {
            Class mappedType = mappedTypes[i];
            QName name = tm.getTypeQName(mappedType);
            if (name.getLocalPart().indexOf(SymbolTable.ANON_TOKEN) != -1) {
                // If this is an anonymous type, it doesn't need to be
                // written out here (and trying to do so will generate an
                // error). Skip it. 
                continue;
            }

            /** 
             * If it's a non-standard type, make sure it shows up in 
             * our WSDL 
             */
            if (standardTypes.getSerializer(mappedType) == null) {
                types.writeTypeForPart(mappedType, name);
            }
        }

        // Don't bother checking for subtypes, since we already wrote
        // all the possibilities.
        types.mappedTypes = null;
    }

    return types;
}

From source file:org.apache.axis.wsdl.fromJava.Emitter.java

/**
 * Create a Operation/*w  w  w . j a  v  a 2  s .c  om*/
 * 
 * @param def     
 * @param binding 
 * @param desc    
 * @return 
 */
protected BindingOperation writeOperation(Definition def, Binding binding, OperationDesc desc) {

    Operation oper = def.createOperation();

    QName elementQName = desc.getElementQName();
    if (elementQName != null && elementQName.getLocalPart() != null) {
        oper.setName(elementQName.getLocalPart());
    } else {
        oper.setName(desc.getName());
    }
    oper.setUndefined(false);

    return writeBindingOperation(def, binding, oper, desc);
}

From source file:org.apache.axis.wsdl.fromJava.Emitter.java

/**
 * Method qualifyOperation//from www  . jav a 2 s . c om
 * 
 * @param oper 
 */
private void qualifyOperation(OperationDesc oper) {

    if ((style == Style.WRAPPED) && (use == Use.LITERAL)) {
        QName qname = oper.getElementQName();

        if (qname == null) {
            qname = new QName(intfNS, oper.getName());
        } else if (qname.getNamespaceURI().equals("")) {
            qname = new QName(intfNS, qname.getLocalPart());
        }

        oper.setElementQName(qname);
    }
}

From source file:org.apache.axis.wsdl.fromJava.Emitter.java

/**
 * Method getResponseQName/*ww w .  ja  v a2  s .  co m*/
 * 
 * @param oper 
 * @return 
 */
protected QName getResponseQName(OperationDesc oper) {

    qualifyOperation(oper);

    QName qname = oper.getElementQName();

    if (qname == null) {
        return new QName(oper.getName() + "Response");
    }

    return new QName(qname.getNamespaceURI(), qname.getLocalPart() + "Response");
}