本文整理汇总了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;
}
示例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();
}
示例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());
}
示例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());
}
示例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;
}
}
示例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;
}
示例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());
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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());
}