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


Java XmlSchema.namespace方法代碼示例

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


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

示例1: getXMLFilterForClass

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
public static <T> XMLFilter getXMLFilterForClass(final Class<T> clazz) throws SAXException {
	final XMLFilter filter;
	final XmlSchema schema = clazz.getPackage().getAnnotation(XmlSchema.class);
	if (schema != null) {
		final String namespace = schema.namespace();
		if (namespace != null && !"".equals(namespace)) {
			LogUtils.tracef(clazz, "found namespace %s for class %s", namespace, clazz);
			filter = new SimpleNamespaceFilter(namespace, true);
		} else {
			filter = new SimpleNamespaceFilter("", false);
		}
	} else {
		filter = new SimpleNamespaceFilter("", false);
	}

	final XMLReader xmlReader = XMLReaderFactory.createXMLReader();
	filter.setParent(xmlReader);
	return filter;
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:20,代碼來源:JaxbUtils.java

示例2: getXmlNs

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的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

示例3: parseElementName

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
/**
 * Parses an {@link XmlRootElement} annotation on a class
 * and determine the element name.
 *
 * @return null
 *      if none was found.
 */
protected final QName parseElementName(ClassDeclT clazz) {
    XmlRootElement e = reader().getClassAnnotation(XmlRootElement.class,clazz,this);
    if(e==null)
        return null;

    String local = e.name();
    if(local.equals("##default")) {
        // if defaulted...
        local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz));
    }
    String nsUri = e.namespace();
    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:TypeInfoImpl.java

示例4: parseElementName

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
final QName parseElementName(XmlElementDecl e) {
    String local = e.name();
    String nsUri = e.namespace();
    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,
            nav().getDeclaringClassForMethod(method),this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:ElementInfoImpl.java

示例5: getNamespaceUriForType

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
/**
 * Returns the schema namespace URI for the specified JAXB type. The URI
 * can then be used to create a {@link QName} instance that is necessary
 * to instantiate a {@link JAXBElement}.
 *
 * @param type a JAXB generated type.
 * @return the namespace URI.
 */
@SuppressWarnings("unchecked")
public static String getNamespaceUriForType( Class<?> type )
{
  String pkgInfoFqcn = type.getPackage().getName() + ".package-info";
  try
  {
    /*
     * package-info.class is a special class generated by JAXB - it contains the schema namespace
     * URI for all generated classes.
     */
    Class<?> pkgInfo = Class.forName( pkgInfoFqcn );
    XmlSchema schema = pkgInfo.getAnnotation( XmlSchema.class );
    return schema.namespace();
  }
  catch ( ClassNotFoundException e )
  {
    return null;
  }
}
 
開發者ID:quartzdesk,項目名稱:quartzdesk-executor,代碼行數:28,代碼來源:JaxbHelper.java

示例6: determineNamespaceUncached

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
private String determineNamespaceUncached(Class<? extends Object> beanClass) {
    XmlType xmlType = beanClass.getAnnotation(XmlType.class);
    if (xmlType == null) {
        return null;
    }

    String namespace = xmlType.namespace();
    if (BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
        XmlSchema xmlSchema = beanClass.getPackage().getAnnotation(XmlSchema.class);
        namespace = xmlSchema.namespace();
    }
    if (StringUtils.isBlank(namespace) || BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
        return null;
    }

    return namespace;
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:18,代碼來源:PrismBeanInspector.java

示例7: determineTypeForClassUncached

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
private QName determineTypeForClassUncached(Class<? extends Object> beanClass) {
    XmlType xmlType = beanClass.getAnnotation(XmlType.class);
    if (xmlType == null) {
        return null;
    }

    String namespace = xmlType.namespace();
    if (BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
        XmlSchema xmlSchema = beanClass.getPackage().getAnnotation(XmlSchema.class);
        namespace = xmlSchema.namespace();
    }
    if (StringUtils.isBlank(namespace) || BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
        return null;
    }

    return new QName(namespace, xmlType.name());
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:18,代碼來源:PrismBeanInspector.java

示例8: getXmlSchemaNamespace

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
/**
 * Gets the xml schema namespace.
 * 
 * @param clazz the clazz
 * 
 * @return the xml schema namespace
 */
public static String getXmlSchemaNamespace(Class<?> clazz) {

    AnnotatedElement pack = clazz.getPackage();
    if (pack == null) {
        return "";
    }

    XmlSchema schema = pack.getAnnotation(XmlSchema.class);
    String namespace = null;
    if (schema != null) {
        namespace = schema.namespace();
    } else {
        namespace = "";
    }
    return namespace;

}
 
開發者ID:clstoulouse,項目名稱:motu,代碼行數:25,代碼來源:ReflectionUtils.java

示例9: findQNameForSoapActionOrType

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
/**
 * @return determine element name by using the XmlType.name() of the type to
 *         be marshalled and the XmlSchema.namespace() of the package-info
 */
public QName findQNameForSoapActionOrType(String soapAction, Class<?> type) {
    XmlType xmlType = type.getAnnotation(XmlType.class);
    if (xmlType == null || xmlType.name() == null) {
        throw new RuntimeException("The type " + type.getName() + " needs to have an XmlType annotation with name");
    }
    String nameSpace = xmlType.namespace();
    if ("##default".equals(nameSpace)) {
        XmlSchema xmlSchema = type.getPackage().getAnnotation(XmlSchema.class);
        if (xmlSchema != null) {
            nameSpace = xmlSchema.namespace();
        }
    }
    // prefer name from the XmlType, and fallback to XmlRootElement
    String localName = xmlType.name();
    if (ObjectHelper.isEmpty(localName)) {
        XmlRootElement root = type.getAnnotation(XmlRootElement.class);
        if (root != null) {
            localName = root.name();
        }
    }
    return new QName(nameSpace, localName);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:27,代碼來源:TypeNameStrategy.java

示例10: getNamespace

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
private static String getNamespace(final Package targetPackage) {
	String namespaceURI;
	if (targetPackage == null) {
		namespaceURI = "";
	} else {
		final XmlSchema xmlSchemaAnnotation = targetPackage
				.getAnnotation(XmlSchema.class);
		if (xmlSchemaAnnotation == null) {
			namespaceURI = "";
		} else {
			final String packageNamespace = xmlSchemaAnnotation.namespace();
			if (packageNamespace == null || "".equals(packageNamespace)) {
				namespaceURI = "";
			} else {
				namespaceURI = packageNamespace;
			}
		}
	}
	return namespaceURI;
}
 
開發者ID:highsource,項目名稱:jaxb2-basics,代碼行數:21,代碼來源:XmlTypeUtils.java

示例11: determineNamespaceUncached

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
private String determineNamespaceUncached(Class<?> beanClass) {
    XmlType xmlType = beanClass.getAnnotation(XmlType.class);
    if (xmlType == null) {
        return null;
    }

    String namespace = xmlType.namespace();
    if (BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
        XmlSchema xmlSchema = beanClass.getPackage().getAnnotation(XmlSchema.class);
        namespace = xmlSchema.namespace();
    }
    if (StringUtils.isBlank(namespace) || BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
        return null;
    }

    return namespace;
}
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:18,代碼來源:PrismBeanInspector.java

示例12: determineTypeForClassUncached

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
private QName determineTypeForClassUncached(Class<?> beanClass) {
    XmlType xmlType = beanClass.getAnnotation(XmlType.class);
    if (xmlType == null) {
        return null;
    }

    String namespace = xmlType.namespace();
    if (BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
        XmlSchema xmlSchema = beanClass.getPackage().getAnnotation(XmlSchema.class);
        namespace = xmlSchema.namespace();
    }
    if (StringUtils.isBlank(namespace) || BeanMarshaller.DEFAULT_PLACEHOLDER.equals(namespace)) {
        return null;
    }

    return new QName(namespace, xmlType.name());
}
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:18,代碼來源:PrismBeanInspector.java

示例13: getNamespace

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
public static String getNamespace(Class<?> klass) {
	String namespace = null;
	XmlType xmlType = klass.getAnnotation(XmlType.class);
	if (xmlType != null) {
		String ns = xmlType.namespace();
		if (!DEFAULT_NAMESPACE_VALUE.equals(ns)) {
			namespace = ns;
		}
	}
	if (namespace == null) {
		namespace = DEFAULT_NAMESPACE_VALUE;
		Package pkg = klass.getPackage();
		XmlSchema xmlSchema = pkg.getAnnotation(XmlSchema.class);
		if (xmlSchema != null) {
			namespace = xmlSchema.namespace();
		}
	}
	return namespace;
}
 
開發者ID:NCIP,項目名稱:cagrid2,代碼行數:20,代碼來源:JAXBUtils.java

示例14: getXMLFilterForClass

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
public static <T> XMLFilter getXMLFilterForClass(final Class<T> clazz) throws SAXException {
	final XMLFilter filter;
	final XmlSchema schema = clazz.getPackage().getAnnotation(XmlSchema.class);
	if (schema != null) {
		final String namespace = schema.namespace();
		if (namespace != null && !"".equals(namespace)) {
			LogUtils.debugf(clazz, "found namespace %s for class %s", namespace, clazz);
			filter = new SimpleNamespaceFilter(namespace, true);
		} else {
			filter = new SimpleNamespaceFilter("", false);
		}
	} else {
		filter = new SimpleNamespaceFilter("", false);
	}

	final XMLReader xmlReader = XMLReaderFactory.createXMLReader();
	filter.setParent(xmlReader);
	return filter;
}
 
開發者ID:vishwaabhinav,項目名稱:OpenNMS,代碼行數:20,代碼來源:JaxbUtils.java

示例15: parseTypeName

import javax.xml.bind.annotation.XmlSchema; //導入方法依賴的package包/類
/**
 * Parses a (potentially-null) {@link XmlType} annotation on a class
 * and determine the actual value.
 *
 * @param clazz
 *      The class on which the XmlType annotation is checked.
 * @param t
 *      The {@link XmlType} annotation on the clazz. This value
 *      is taken as a parameter to improve the performance for the case where
 *      't' is pre-computed.
 */
protected final QName parseTypeName(ClassDeclT clazz, XmlType t) {
    String nsUri="##default";
    String local="##default";
    if(t!=null) {
        nsUri = t.namespace();
        local = t.name();
    }

    if(local.length()==0)
        return null; // anonymous


    if(local.equals("##default"))
        // if defaulted ...
        local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz));

    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:40,代碼來源:TypeInfoImpl.java


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