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


Java XmlNs類代碼示例

本文整理匯總了Java中javax.xml.bind.annotation.XmlNs的典型用法代碼示例。如果您正苦於以下問題:Java XmlNs類的具體用法?Java XmlNs怎麽用?Java XmlNs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: getXmlNs

import javax.xml.bind.annotation.XmlNs; //導入依賴的package包/類
public Map<String,String> getXmlNs(String namespaceUri) {
    if(xmlNsCache==null) {
        xmlNsCache = new HashMap<String,Map<String,String>>();

        for (ClassInfoImpl<T, C, F, M> ci : beans().values()) {
            XmlSchema xs = reader.getPackageAnnotation( XmlSchema.class, ci.getClazz(), null );
            if(xs==null)
                continue;

            String uri = xs.namespace();
            Map<String,String> m = xmlNsCache.get(uri);
            if(m==null)
                xmlNsCache.put(uri,m=new HashMap<String, String>());

            for( XmlNs xns : xs.xmlns() ) {
                m.put(xns.prefix(),xns.namespaceURI());
            }
        }
    }

    Map<String,String> r = xmlNsCache.get(namespaceUri);
    if(r!=null)     return r;
    else            return Collections.emptyMap();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:TypeInfoSetImpl.java

示例2: getPrefix

import javax.xml.bind.annotation.XmlNs; //導入依賴的package包/類
private static String getPrefix(final Package targetPackage,
		String namespaceURI) {
	String prefix;
	final Map<String, String> namespacePrefixes = new HashMap<String, String>();
	if (targetPackage != null) {
		final XmlSchema xmlSchemaAnnotation = targetPackage
				.getAnnotation(XmlSchema.class);
		if (xmlSchemaAnnotation != null) {
			for (XmlNs xmlns : xmlSchemaAnnotation.xmlns()) {
				namespacePrefixes.put(xmlns.namespaceURI(), xmlns.prefix());
			}
		}
	}

	prefix = namespacePrefixes.get(namespaceURI);
	return prefix;
}
 
開發者ID:highsource,項目名稱:jaxb2-basics,代碼行數:18,代碼來源:XmlTypeUtils.java

示例3: run

import javax.xml.bind.annotation.XmlNs; //導入依賴的package包/類
@Override
public boolean run(final Outline outline, final Options options, final ErrorHandler errorHandler) {
	final JClass xmlNsClass = outline.getCodeModel().ref(XmlNs.class);
	final JClass xmlSchemaClass = outline.getCodeModel().ref(XmlSchema.class);

	for (PackageOutline packageOutline : outline.getAllPackageContexts()) {
		final JPackage p = packageOutline._package();

		// get the target namespaces of all schemas that bind to the current package
		final Set<String> packageNamespaces = getPackageNamespace(packageOutline);

		// is there any prefix binding defined for the current package ?
		final Model packageModel = getPackageModel((PackageOutlineImpl) packageOutline);
		final List<Pair> list = getPrefixBinding(packageModel, packageNamespaces);
		acknowledgePrefixAnnotations(packageModel);

		if (list == null || list.isEmpty()) {
			// no prefix binding, nothing to do
			continue;
		}

		// add XML namespace prefix annotations
		final JAnnotationUse xmlSchemaAnnotation = getOrAddXmlSchemaAnnotation(p, xmlSchemaClass);
		if (xmlSchemaAnnotation == null) {
			throw new RuntimeException("Unable to get/add 'XmlSchema' annotation to package [" + p.name() + "]");
		}

		final JAnnotationArrayMember members = xmlSchemaAnnotation.paramArray("xmlns");
		for (Pair pair : list) {
			addNamespacePrefix(xmlNsClass, members, pair.getNamespace(), pair.getPrefix());
		}
	}

	return true;
}
 
開發者ID:Siggen,項目名稱:jaxb2-namespace-prefix,代碼行數:36,代碼來源:NamespacePrefixPlugin.java

示例4: xmlns

import javax.xml.bind.annotation.XmlNs; //導入依賴的package包/類
public XmlNs[] xmlns() {
    return core.xmlns();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:XmlSchemaQuick.java

示例5: getXmlNsSet

import javax.xml.bind.annotation.XmlNs; //導入依賴的package包/類
/**
 * Returns declared XmlNs annotations (from package-level annotation XmlSchema
 *
 * @return set of all present XmlNs annotations
 */
public Set<XmlNs> getXmlNsSet() {
    return xmlNsSet;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:9,代碼來源:JAXBContextImpl.java


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