当前位置: 首页>>代码示例>>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;未经允许,请勿转载。