當前位置: 首頁>>代碼示例>>Java>>正文


Java QName.getPrefix方法代碼示例

本文整理匯總了Java中javax.xml.namespace.QName.getPrefix方法的典型用法代碼示例。如果您正苦於以下問題:Java QName.getPrefix方法的具體用法?Java QName.getPrefix怎麽用?Java QName.getPrefix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.namespace.QName的用法示例。


在下文中一共展示了QName.getPrefix方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: appendFaultSubcode

import javax.xml.namespace.QName; //導入方法依賴的package包/類
@Override
public void appendFaultSubcode(QName subcode) throws SOAPException {
    if (subcode == null) {
        return;
    }
    if (subcode.getNamespaceURI() == null ||
        "".equals(subcode.getNamespaceURI())) {

        log.severe("SAAJ0432.ver1_2.subcode.not.ns.qualified");
        throw new SOAPExceptionImpl("A Subcode must be namespace-qualified");
    }
    if (innermostSubCodeElement == null) {
        if (faultCodeElement == null)
            findFaultCodeElement();
        innermostSubCodeElement = faultCodeElement;
    }
    String prefix = null;
    if (subcode.getPrefix() == null || "".equals(subcode.getPrefix())) {
        prefix =
            ((ElementImpl) innermostSubCodeElement).getNamespacePrefix(
                subcode.getNamespaceURI());
    } else
        prefix = subcode.getPrefix();
    if (prefix == null || "".equals(prefix)) {
        prefix = "ns1";
    }
    innermostSubCodeElement =
        innermostSubCodeElement.addChildElement(subcodeName);
    SOAPElement subcodeValueElement =
        innermostSubCodeElement.addChildElement(valueName);
    ((ElementImpl) subcodeValueElement).ensureNamespaceIsDeclared(
        prefix,
        subcode.getNamespaceURI());
    subcodeValueElement.addTextNode(prefix + ":" + subcode.getLocalPart());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:36,代碼來源:Fault1_2Impl.java

示例2: startNode

import javax.xml.namespace.QName; //導入方法依賴的package包/類
@Override
public void startNode(final String name, final Class<?> clazz) {
    final XMLStreamWriter out = getXMLStreamWriter();
    if (clazz != null && out instanceof AbstractXMLStreamWriter) {
        if (Collection.class.isAssignableFrom(clazz) || Map.class.isAssignableFrom(clazz) || clazz.isArray()) {
            final QName qname = getQNameMap().getQName(encodeNode(name));
            final String prefix = qname.getPrefix();
            final String uri = qname.getNamespaceURI();
            final String key = convention.createKey(prefix, uri, qname.getLocalPart());
            if (!((AbstractXMLStreamWriter)out).getSerializedAsArrays().contains(key)) {
                // Typo is in the API of Jettison ...
                ((AbstractXMLStreamWriter)out).seriliazeAsArray(key);
            }
        }
    }
    startNode(name);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:JettisonStaxWriter.java

示例3: TypeInfo

import javax.xml.namespace.QName; //導入方法依賴的package包/類
public TypeInfo(QName tagName, Type type, Annotation... annotations) {
        if(tagName==null || type==null || annotations==null) {
            String nullArgs = "";

            if(tagName == null)     nullArgs = "tagName";
            if(type == null)        nullArgs += (nullArgs.length() > 0 ? ", type" : "type");
            if(annotations == null) nullArgs += (nullArgs.length() > 0 ? ", annotations" : "annotations");

//            Messages.ARGUMENT_CANT_BE_NULL.format(nullArgs);

            throw new IllegalArgumentException( "Argument(s) \"" + nullArgs + "\" can''t be null.)");
        }

        this.tagName = new QName(tagName.getNamespaceURI().intern(), tagName.getLocalPart().intern(), tagName.getPrefix());
        this.type = type;
        if (type instanceof Class && ((Class<?>)type).isPrimitive()) nillable = false;
        this.annotations = annotations;
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:TypeInfo.java

示例4: TypeReference

import javax.xml.namespace.QName; //導入方法依賴的package包/類
public TypeReference(QName tagName, Type type, Annotation... annotations) {
    if(tagName==null || type==null || annotations==null) {
        String nullArgs = "";

        if(tagName == null)     nullArgs = "tagName";
        if(type == null)        nullArgs += (nullArgs.length() > 0 ? ", type" : "type");
        if(annotations == null) nullArgs += (nullArgs.length() > 0 ? ", annotations" : "annotations");

        Messages.ARGUMENT_CANT_BE_NULL.format(nullArgs);

        throw new IllegalArgumentException(Messages.ARGUMENT_CANT_BE_NULL.format(nullArgs));
    }

    this.tagName = new QName(tagName.getNamespaceURI().intern(), tagName.getLocalPart().intern(), tagName.getPrefix());
    this.type = type;
    this.annotations = annotations;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:TypeReference.java

示例5: getAttributeByName

import javax.xml.namespace.QName; //導入方法依賴的package包/類
private Attribute getAttributeByName(final StartElement element,
        final QName attributeName) {
    // call standard API method to retrieve the attribute by name
    Attribute attribute = element.getAttributeByName(attributeName);

    // try to find the attribute without a prefix.
    if (attribute == null) {
        final String localAttributeName = attributeName.getLocalPart();
        final Iterator iterator = element.getAttributes();
        while (iterator.hasNext()) {
            final Attribute nextAttribute = (Attribute) iterator.next();
            final QName aName = nextAttribute.getName();
            final boolean attributeFoundByWorkaround = aName.equals(attributeName) || (aName.getLocalPart().equals(localAttributeName) && (aName.getPrefix() == null || "".equals(aName.getPrefix())));
            if (attributeFoundByWorkaround) {
                attribute = nextAttribute;
                break;
            }

        }
    }

    return attribute;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:XmlPolicyModelUnmarshaller.java

示例6: addToNameTable

import javax.xml.namespace.QName; //導入方法依賴的package包/類
private void addToNameTable(QName n, LocalNameQualifiedNamesMap m) {
    int namespaceURIIndex = -1;
    int prefixIndex = -1;
    if (n.getNamespaceURI().length() > 0) {
        namespaceURIIndex = namespaceName.obtainIndex(n.getNamespaceURI());
        if (namespaceURIIndex == KeyIntMap.NOT_PRESENT) {
            namespaceURIIndex = namespaceName.get(n.getNamespaceURI());
        }

        if (n.getPrefix().length() > 0) {
            prefixIndex = prefix.obtainIndex(n.getPrefix());
            if (prefixIndex == KeyIntMap.NOT_PRESENT) {
                prefixIndex = prefix.get(n.getPrefix());
            }
        }
    }

    int localNameIndex = localName.obtainIndex(n.getLocalPart());
    if (localNameIndex == KeyIntMap.NOT_PRESENT) {
        localNameIndex = localName.get(n.getLocalPart());
    }

    QualifiedName name = new QualifiedName(n.getPrefix(), n.getNamespaceURI(), n.getLocalPart(),
            m.getNextIndex(),
            prefixIndex, namespaceURIIndex, localNameIndex);

    LocalNameQualifiedNamesMap.Entry entry = null;
    if (_useLocalNameAsKey) {
        entry = m.obtainEntry(n.getLocalPart());
    } else {
        String qName = (prefixIndex == -1)
            ? n.getLocalPart()
            : n.getPrefix() + ":" + n.getLocalPart();
        entry = m.obtainEntry(qName);
    }

    entry.addQualifiedName(name);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:39,代碼來源:SerializerVocabulary.java

示例7: handleEndElement

import javax.xml.namespace.QName; //導入方法依賴的package包/類
private void handleEndElement(EndElement event) throws XMLStreamException {
    QName qName = event.getName();

    //construct prefix:localName from qName
    String qname = "";
    if (qName.getPrefix() != null && qName.getPrefix().trim().length() != 0){
        qname = qName.getPrefix() + ":";
    }
    qname += qName.getLocalPart();

    try {
        // fire endElement
        _sax.endElement(
            qName.getNamespaceURI(),
            qName.getLocalPart(),
            qname);

        // end namespace bindings
        for( Iterator i = event.getNamespaces(); i.hasNext();) {
            String prefix = (String)i.next();
            if( prefix == null ) { // true for default namespace
                prefix = "";
            }
            _sax.endPrefixMapping(prefix);
        }
    } catch (SAXException e) {
        throw new XMLStreamException(e);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:StAXEvent2SAX.java

示例8: addNotUnderstoodHeaderElement

import javax.xml.namespace.QName; //導入方法依賴的package包/類
@Override
public SOAPHeaderElement addNotUnderstoodHeaderElement(final QName sourceName)
    throws SOAPException {

    if (sourceName == null) {
        log.severe("SAAJ0410.ver1_2.no.null.to.addNotUnderstoodHeader");
        throw new SOAPException("Cannot pass NULL to addNotUnderstoodHeaderElement");
    }
    if ("".equals(sourceName.getNamespaceURI())) {
        log.severe("SAAJ0417.ver1_2.qname.not.ns.qualified");
        throw new SOAPException("The qname passed to addNotUnderstoodHeaderElement must be namespace-qualified");
    }
    String prefix = sourceName.getPrefix();
    if ("".equals(prefix)) {
        prefix = "ns1";
    }
    Name notunderstoodName = getNotUnderstoodName();
    SOAPHeaderElement notunderstoodHeaderElement =
        (SOAPHeaderElement) addChildElement(notunderstoodName);
    notunderstoodHeaderElement.addAttribute(
        NameImpl.createFromUnqualifiedName("qname"),
        getQualifiedName(
            new QName(
                sourceName.getNamespaceURI(),
                sourceName.getLocalPart(),
                prefix)));
    notunderstoodHeaderElement.addNamespaceDeclaration(
        prefix,
        sourceName.getNamespaceURI());
    return notunderstoodHeaderElement;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:Header1_2Impl.java

示例9: create

import javax.xml.namespace.QName; //導入方法依賴的package包/類
@Override
public SettingsComponent create(SettingsComponent 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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:SettingsComponentFactoryImpl.java

示例10: getAttributes

import javax.xml.namespace.QName; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:34,代碼來源:StAXEventConnector.java

示例11: addNotUnderstoodHeaderElement

import javax.xml.namespace.QName; //導入方法依賴的package包/類
public SOAPHeaderElement addNotUnderstoodHeaderElement(final QName sourceName)
    throws SOAPException {

    if (sourceName == null) {
        log.severe("SAAJ0410.ver1_2.no.null.to.addNotUnderstoodHeader");
        throw new SOAPException("Cannot pass NULL to addNotUnderstoodHeaderElement");
    }
    if ("".equals(sourceName.getNamespaceURI())) {
        log.severe("SAAJ0417.ver1_2.qname.not.ns.qualified");
        throw new SOAPException("The qname passed to addNotUnderstoodHeaderElement must be namespace-qualified");
    }
    String prefix = sourceName.getPrefix();
    if ("".equals(prefix)) {
        prefix = "ns1";
    }
    Name notunderstoodName = getNotUnderstoodName();
    SOAPHeaderElement notunderstoodHeaderElement =
        (SOAPHeaderElement) addChildElement(notunderstoodName);
    notunderstoodHeaderElement.addAttribute(
        NameImpl.createFromUnqualifiedName("qname"),
        getQualifiedName(
            new QName(
                sourceName.getNamespaceURI(),
                sourceName.getLocalPart(),
                prefix)));
    notunderstoodHeaderElement.addNamespaceDeclaration(
        prefix,
        sourceName.getNamespaceURI());
    return notunderstoodHeaderElement;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:Header1_2Impl.java

示例12: appendFaultSubcode

import javax.xml.namespace.QName; //導入方法依賴的package包/類
public void appendFaultSubcode(QName subcode) throws SOAPException {
    if (subcode == null) {
        return;
    }
    if (subcode.getNamespaceURI() == null ||
        "".equals(subcode.getNamespaceURI())) {

        log.severe("SAAJ0432.ver1_2.subcode.not.ns.qualified");
        throw new SOAPExceptionImpl("A Subcode must be namespace-qualified");
    }
    if (innermostSubCodeElement == null) {
        if (faultCodeElement == null)
            findFaultCodeElement();
        innermostSubCodeElement = faultCodeElement;
    }
    String prefix = null;
    if (subcode.getPrefix() == null || "".equals(subcode.getPrefix())) {
        prefix =
            ((ElementImpl) innermostSubCodeElement).getNamespacePrefix(
                subcode.getNamespaceURI());
    } else
        prefix = subcode.getPrefix();
    if (prefix == null || "".equals(prefix)) {
        prefix = "ns1";
    }
    innermostSubCodeElement =
        innermostSubCodeElement.addChildElement(subcodeName);
    SOAPElement subcodeValueElement =
        innermostSubCodeElement.addChildElement(valueName);
    ((ElementImpl) subcodeValueElement).ensureNamespaceIsDeclared(
        prefix,
        subcode.getNamespaceURI());
    subcodeValueElement.addTextNode(prefix + ":" + subcode.getLocalPart());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:35,代碼來源:Fault1_2Impl.java

示例13: getTypesListFromXsd

import javax.xml.namespace.QName; //導入方法依賴的package包/類
private ArrayList<String> getTypesListFromXsd() {
	ArrayList<String> types = new ArrayList<String>();
	try {
		String tns = transaction.getProject().getTargetNamespace();
		String projectName = transaction.getProject().getName();
		XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(projectName);
		QName responseTypeQName = new QName(tns, transaction.getXsdResponseTypeName());
		XmlSchemaComplexType xmlSchemaType = (XmlSchemaComplexType) schema.getTypeByName(responseTypeQName);
		XmlSchemaParticle xmlSchemaParticle = xmlSchemaType.getParticle();
		if (xmlSchemaParticle != null && xmlSchemaParticle instanceof XmlSchemaSequence) {
			XmlSchemaObjectCollection xmlSchemaObjectCollection = ((XmlSchemaSequence)xmlSchemaParticle).getItems();
			for (int i=0;i<xmlSchemaObjectCollection.getCount();i++) {
				XmlSchemaObject xso = xmlSchemaObjectCollection.getItem(i);
				if (xso instanceof XmlSchemaElement) {
					XmlSchemaElement xmlSchemaElement = (XmlSchemaElement)xso;
					String elName = xmlSchemaElement.getName();
					QName elType = xmlSchemaElement.getSchemaTypeName();
					String value = "<xsd:element name=\""+elName+"\" type=\""+elType.getPrefix()+":"+elType.getLocalPart()+"\"/>";
					types.add(value);
				}
			}
		}
	}
	catch (Exception e) {
	}
	return types;
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:28,代碼來源:TransactionXSDTypesDialogComposite.java

示例14: handleStartElement

import javax.xml.namespace.QName; //導入方法依賴的package包/類
private void handleStartElement() throws XMLStreamException {

        try {
            // start namespace bindings
            int nsCount = staxStreamReader.getNamespaceCount();
            for (int i = 0; i < nsCount; i++) {
                saxHandler.startPrefixMapping(
                    fixNull(staxStreamReader.getNamespacePrefix(i)),
                    fixNull(staxStreamReader.getNamespaceURI(i)));
            }

            // fire startElement
            QName qName = staxStreamReader.getName();
            String prefix = qName.getPrefix();
            String rawname;
            if(prefix==null || prefix.length()==0)
                rawname = qName.getLocalPart();
            else
                rawname = prefix + ':' + qName.getLocalPart();
            Attributes attrs = getAttributes();
            saxHandler.startElement(
                qName.getNamespaceURI(),
                qName.getLocalPart(),
                rawname,
                attrs);
        } catch (SAXException e) {
            throw new XMLStreamException2(e);
        }
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:XMLStreamReaderToContentHandler.java

示例15: attWildcardAsURIs

import javax.xml.namespace.QName; //導入方法依賴的package包/類
public void attWildcardAsURIs(Map<QName,String> attributes, String fieldName) {
    if(attributes==null)    return;
    for( Map.Entry<QName,String> e : attributes.entrySet() ) {
        QName n = e.getKey();
        String nsUri = n.getNamespaceURI();
        if(nsUri.length()>0) {
            String p = n.getPrefix();
            if(p.length()==0)   p=null;
            nsContext.declareNsUri(nsUri, p, true);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:XMLSerializer.java


注:本文中的javax.xml.namespace.QName.getPrefix方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。