当前位置: 首页>>代码示例>>Java>>正文


Java XmlType.namespace方法代码示例

本文整理汇总了Java中javax.xml.bind.annotation.XmlType.namespace方法的典型用法代码示例。如果您正苦于以下问题:Java XmlType.namespace方法的具体用法?Java XmlType.namespace怎么用?Java XmlType.namespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.bind.annotation.XmlType的用法示例。


在下文中一共展示了XmlType.namespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: determineNamespaceUncached

import javax.xml.bind.annotation.XmlType; //导入方法依赖的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

示例2: determineTypeForClassUncached

import javax.xml.bind.annotation.XmlType; //导入方法依赖的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

示例3: findQNameForSoapActionOrType

import javax.xml.bind.annotation.XmlType; //导入方法依赖的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

示例4: determineNamespaceUncached

import javax.xml.bind.annotation.XmlType; //导入方法依赖的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

示例5: determineTypeForClassUncached

import javax.xml.bind.annotation.XmlType; //导入方法依赖的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

示例6: getTypeIdName

import javax.xml.bind.annotation.XmlType; //导入方法依赖的package包/类
/**
 * Get the id for the specified type.
 *
 * @param type The type.
 * @return The type id.
 */
public static String getTypeIdName(Class<?> type) {
  String ns = "";
  if (type.getPackage() != null && type.getPackage().isAnnotationPresent(XmlSchema.class)) {
    ns = type.getPackage().getAnnotation(XmlSchema.class).namespace();
  }

  String name = Introspector.decapitalize(type.getSimpleName());
  if (type.isAnnotationPresent(XmlType.class)) {
    XmlType typeMeta = type.getAnnotation(XmlType.class);
    if (!"##default".equals(typeMeta.name())) {
      name = typeMeta.name();
    }

    if (!"##default".equals(typeMeta.namespace())) {
      ns = typeMeta.namespace();
    }
  }

  return ns + name;
}
 
开发者ID:FamilySearch,项目名称:gedcomx-java,代码行数:27,代码来源:GedcomNamespaceManager.java

示例7: getNamespace

import javax.xml.bind.annotation.XmlType; //导入方法依赖的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

示例8: parseTypeName

import javax.xml.bind.annotation.XmlType; //导入方法依赖的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

示例9: getClass

import javax.xml.bind.annotation.XmlType; //导入方法依赖的package包/类
/**
 * 获取数据的类型
 * 
 * @param name
 *            标记的名称
 * @return
 * @throws ClassNotFoundException
 * @throws IOException
 * @throws TransformException
 */
protected Class<?> getClass(String name) throws ClassNotFoundException, IOException, TransformException {
	String simpleName = name;
	if (simpleName.startsWith("http")) {
		simpleName = simpleName.substring(simpleName.lastIndexOf("/") + 1);
	}
	// 遍历加载器可识别类名称,找到可能的
	for (String className : this.getClassLoader().getClassNames()) {
		if (className.toLowerCase().endsWith(simpleName)) {
			Class<?> type = this.getClassLoader().findClass(className);
			if (type != null) {
				XmlType xmlType = type.getAnnotation(XmlType.class);
				if (xmlType != null) {
					String xmlName = type.getSimpleName();
					if (!xmlType.name().equals("##default")) {
						xmlName = xmlType.name();
					}
					if (!xmlType.namespace().equals("##default")) {
						if (xmlType.namespace().equals("/")) {
							xmlName = xmlType.namespace() + xmlName;
						} else {
							xmlName = xmlType.namespace() + "/" + xmlName;
						}
					}
					if (xmlName.equalsIgnoreCase(name)) {
						return type;
					}
				}
			}
		}
	}
	throw new ClassNotFoundException(name);
}
 
开发者ID:color-coding,项目名称:btulz.transforms,代码行数:43,代码来源:DataTransformer.java

示例10: findTypeNameUncached

import javax.xml.bind.annotation.XmlType; //导入方法依赖的package包/类
private QName findTypeNameUncached(Field field, Class contentClass, String schemaNamespace) {
      if (field != null) {
	XmlSchemaType xmlSchemaType = field.getAnnotation(XmlSchemaType.class);
          if (xmlSchemaType != null) {
              return new QName(xmlSchemaType.namespace(), xmlSchemaType.name());
          }
      }
      QName typeName = XsdTypeMapper.getJavaToXsdMapping(contentClass);
      if (typeName != null) {
      	return typeName;
}
// TODO the following code is similar to determineTypeForClass
XmlType xmlType = (XmlType) contentClass.getAnnotation(XmlType.class);
if (xmlType != null) {
	String propTypeLocalPart = xmlType.name();
	String propTypeNamespace = xmlType.namespace();
	if (propTypeNamespace.equals(BeanMarshaller.DEFAULT_PLACEHOLDER)) {
		PrismSchema schema = prismContext.getSchemaRegistry().findSchemaByCompileTimeClass(contentClass);
		if (schema != null && schema.getNamespace() != null) {
			propTypeNamespace = schema.getNamespace();		// should be non-null for properly initialized schemas
		} else {
			// schemaNamespace is only a poor indicator of required namespace (consider e.g. having c:UserType in apit:ObjectListType)
			// so we use it only if we couldn't find anything else
			propTypeNamespace = schemaNamespace;
		}
	}
	return new QName(propTypeNamespace, propTypeLocalPart);
}
return null;
  }
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:31,代码来源:PrismBeanInspector.java

示例11: findQNameForSoapActionOrType

import javax.xml.bind.annotation.XmlType; //导入方法依赖的package包/类
@Override
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");
    }
    // prefer name+ns from the XmlRootElement, and fallback to XmlType
    String localName = null;
    String nameSpace = null;

    XmlRootElement root = type.getAnnotation(XmlRootElement.class);
    if (root != null) {
        localName = ObjectHelper.isEmpty(localName) ? root.name() : localName;
        nameSpace = isInValidNamespace(nameSpace) ? root.namespace() : nameSpace;
    }

    if (ObjectHelper.isEmpty(localName)) {
        localName = xmlType.name();
    }

    if (isInValidNamespace(nameSpace)) {
        XmlSchema xmlSchema = type.getPackage().getAnnotation(XmlSchema.class);
        if (xmlSchema != null) {
            nameSpace = xmlSchema.namespace();
        }
    }

    if (isInValidNamespace(nameSpace)) {
        nameSpace = xmlType.namespace();
    }

    if (ObjectHelper.isEmpty(localName) || isInValidNamespace(nameSpace)) {
        throw new IllegalStateException("Unable to determine localName or namespace for type <" + type.getName() + ">");
    }
    return new QName(nameSpace, localName);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:37,代码来源:XmlRootElementPreferringElementNameStrategy.java

示例12: getTargetNamespace

import javax.xml.bind.annotation.XmlType; //导入方法依赖的package包/类
private String getTargetNamespace(final Class<?> clazz) {
	final XmlRootElement xmlRootElementAnnotation = clazz.getAnnotation(XmlRootElement.class);
	if (xmlRootElementAnnotation == null) {
		final XmlType xmlTypeAnnotation = clazz.getAnnotation(XmlType.class);
		return xmlTypeAnnotation == null ? null : xmlTypeAnnotation.namespace();
	} else {
		return xmlRootElementAnnotation.namespace();
	}
}
 
开发者ID:mklemm,项目名称:jxpath-object-formatter,代码行数:10,代码来源:JaxbJXPathBeanInfo.java

示例13: parseTypeName

import javax.xml.bind.annotation.XmlType; //导入方法依赖的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 && xs.namespace().length()>0)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:40,代码来源:TypeInfoImpl.java

示例14: findTypeNameUncached

import javax.xml.bind.annotation.XmlType; //导入方法依赖的package包/类
private QName findTypeNameUncached(Field field, Class contentClass, String schemaNamespace) {
  	if (RawType.class.equals(contentClass)) {
  		// RawType is a meta-type. We do not really want to use field types of RawType class.
  		return null;
  	}
      if (field != null) {
	XmlSchemaType xmlSchemaType = field.getAnnotation(XmlSchemaType.class);
          if (xmlSchemaType != null) {
              return new QName(xmlSchemaType.namespace(), xmlSchemaType.name());
          }
      }
      QName typeName = XsdTypeMapper.getJavaToXsdMapping(contentClass);
      if (typeName != null) {
      	return typeName;
}
// TODO the following code is similar to determineTypeForClass
XmlType xmlType = (XmlType) contentClass.getAnnotation(XmlType.class);
if (xmlType != null) {
	String propTypeLocalPart = xmlType.name();
	String propTypeNamespace = xmlType.namespace();
	if (propTypeNamespace.equals(BeanMarshaller.DEFAULT_PLACEHOLDER)) {
		PrismSchema schema = prismContext.getSchemaRegistry().findSchemaByCompileTimeClass(contentClass);
		if (schema != null && schema.getNamespace() != null) {
			propTypeNamespace = schema.getNamespace();		// should be non-null for properly initialized schemas
		} else {
			// schemaNamespace is only a poor indicator of required namespace (consider e.g. having c:UserType in apit:ObjectListType)
			// so we use it only if we couldn't find anything else
			propTypeNamespace = schemaNamespace;
		}
	}
	return new QName(propTypeNamespace, propTypeLocalPart);
}
return null;
  }
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:35,代码来源:PrismBeanInspector.java

示例15: getXmlTypeQName

import javax.xml.bind.annotation.XmlType; //导入方法依赖的package包/类
/**
 * @param clazz
 * @return namespace of @XmlType or null if this is object does not represent a root element
 */
public static QName getXmlTypeQName(Class clazz) {

    // See if the object has an @XmlType
    XmlType t = (XmlType) getAnnotation(clazz,XmlType.class);
    if (t == null) {
        return null;
    }

    String name = t.name();
    String namespace = t.namespace();

    // The name may need to be defaulted
    if (name == null || name.length() == 0 || name.equals("##default")) {
        name = getSimpleName(clazz.getCanonicalName());
    }

    // The namespace may need to be defaulted
    if (namespace == null || namespace.length() == 0 || namespace.equals("##default")) {
        Package pkg = clazz.getPackage();
        XmlSchema schema = (XmlSchema) getAnnotation(pkg,XmlSchema.class);
        if (schema != null) {
            namespace = schema.namespace();
        } else {
            namespace = "";
        }
    }

    return new QName(namespace, name);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:34,代码来源:XMLRootElementUtil.java


注:本文中的javax.xml.bind.annotation.XmlType.namespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。