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


Java XmlRootElement.name方法代码示例

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


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

示例1: parseElementName

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

示例2: getShortName

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
/**
 * Returns a short name for this node which can be useful for ID generation or referring to related resources like images
 *
 * @return defaults to "node" but derived nodes should overload this to provide a unique name
 */
@Override
public String getShortName() {
    if (shortName == null) {
        XmlRootElement root = getClass().getAnnotation(XmlRootElement.class);
        if (root != null) {
            shortName = root.name();
        }
        if (shortName == null) {
            XmlType type = getClass().getAnnotation(XmlType.class);
            if (type != null) {
                shortName = type.name();
            }
        }
    }
    return shortName;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:OptionalIdentifiedDefinition.java

示例3: findQNameForSoapActionOrType

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

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
public static String getTagName(Class<?> handled) {
    if (TAG_NAMES.containsKey(handled)) {
        return TAG_NAMES.get(handled);
    }

    XmlType xmlType = handled.getAnnotation(XmlType.class);
    if (xmlType != null && xmlType.name() != null && xmlType.name().trim().length() > 0) {
        TAG_NAMES.put(handled, xmlType.name());
        return xmlType.name();
    } else {
        XmlRootElement xmlRoot = handled.getAnnotation(XmlRootElement.class);
        if (xmlRoot != null && xmlRoot.name() != null && xmlRoot.name().trim().length() > 0) {
            TAG_NAMES.put(handled, xmlRoot.name());
            return xmlRoot.name();
        }
    }
    throw new IllegalArgumentException("XML name not found for " + handled.getName());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:StAXUtil.java

示例5: getType

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
private static String getType(Class<? extends ClientResource<?>> clientObjectClass) {
	String clientResourceType = null;
	XmlRootElement xmlRootElement = clientObjectClass.getAnnotation(XmlRootElement.class);
	if (xmlRootElement != null && !"##default".equals(xmlRootElement.name()))
		clientResourceType = xmlRootElement.name();
	else {
		XmlType xmlType = clientObjectClass.getAnnotation(XmlType.class);
		if (xmlType != null && !"##default".equals(xmlType.name()))
			clientResourceType = xmlType.name();
	}
	if (clientResourceType == null) {
		String classSimpleName = clientObjectClass.getSimpleName();
		clientResourceType = classSimpleName.replaceFirst("^.", classSimpleName.substring(0, 1).toLowerCase());
	}
	return clientResourceType;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:17,代码来源:WsTypes.java

示例6: init

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
public void init(JavaType baseType) {
    this.baseType = baseType;
    ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
    classes.add(baseType.getRawClass());
    classes.addAll(Arrays.asList(DtoModules.extensionClasses()));
    for ( Class<?> c : classes) {
        if( baseType.getRawClass().isAssignableFrom(c) ) {
            JsonTypeName jsonAnnoation = c.getAnnotation(JsonTypeName.class);
            if(jsonAnnoation!=null && jsonAnnoation.value()!=null) {
                typeToId.put(c, jsonAnnoation.value());
                idToType.put(jsonAnnoation.value(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
                idToType.put(c.getName(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
            } else {
                XmlRootElement xmlAnnoation = c.getAnnotation(XmlRootElement.class);
                if(xmlAnnoation!=null && xmlAnnoation.name()!=null) {
                    typeToId.put(c, xmlAnnoation.name());
                    idToType.put(xmlAnnoation.name(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
                    idToType.put(c.getName(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
                }
            }
        }
    }
}
 
开发者ID:christian-posta,项目名称:activemq-apollo-java-port,代码行数:24,代码来源:ApolloTypeIdResolver.java

示例7: getPatternName

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
/**
 * Returns the pattern name
 */
public static String getPatternName(OptionalIdentifiedDefinition camelNode) {
    // we should grab the annotation instead
    XmlRootElement root = camelNode.getClass().getAnnotation(XmlRootElement.class);
    if (root != null) {
        return root.name();
    }
    String simpleName = Strings.stripSuffix(camelNode.getClass().getSimpleName(), "Definition");
    return Introspector.decapitalize(simpleName);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:13,代码来源:CamelModelHelper.java

示例8: getQName

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
public static QName getQName(Class<?> clss) throws APIException {
	// Obtain the Necessary info for QName from Requirement
	XmlRootElement xre = clss.getAnnotation(XmlRootElement.class);
	if(xre==null)throw new APIException(clss.getName() + " does not have an XmlRootElement annotation");
	Package pkg = clss.getPackage();
	XmlSchema xs = pkg.getAnnotation(XmlSchema.class);
	if(xs==null) throw new APIException(clss.getName() + " package-info does not have an XmlSchema annotation");
	return new QName(xs.namespace(),xre.name());
}
 
开发者ID:att,项目名称:AAF,代码行数:10,代码来源:BaseDataFactory.java

示例9: build

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
/**
 * Build up JAXB Information (recursively)
 * 
 * @param cls
 * @param rootNns
 * @return
 * @throws SecurityException
 * @throws NoSuchFieldException
 * @throws ClassNotFoundException
 * @throws ParseException
 */
public static JaxInfo build(Class<?> cls, String ... rootNns) throws SecurityException, NoSuchFieldException, ClassNotFoundException, ParseException {
	String defaultNS;
	if(rootNns.length>0 && rootNns[0]!=null) {
		defaultNS = rootNns[0];
	} else {
		Package pkg = cls.getPackage();
		XmlSchema xs = pkg.getAnnotation(XmlSchema.class);
		defaultNS = xs==null?"":xs.namespace();
	}
	String name;
	if(rootNns.length>1) {
		name = rootNns[1];
	} else {
		XmlRootElement xre = cls.getAnnotation(XmlRootElement.class);
		if(xre!=null) {
			name = xre.name();
		} else {
			XmlType xt = cls.getAnnotation(XmlType.class);
			if(xt!=null) {
				name=xt.name();
			} else {
				throw new ParseException("Need a JAXB Object with XmlRootElement, or stipulate in parms");
			}
		}
	}
	
	return new JaxInfo(name,defaultNS, cls,buildFields(cls,defaultNS),false,false,false,false);
}
 
开发者ID:att,项目名称:AAF,代码行数:40,代码来源:JaxInfo.java

示例10: getName

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
public static <T extends Model> String getName(Class<T> model) {
    if (model == null)
        return null;

    String name = null;

    XmlRootElement xmlRootElement = model.getAnnotation(XmlRootElement.class);

    if (xmlRootElement != null) {
        name = xmlRootElement.name();
    }

    if (name == null) {
        Class<? extends Model> modelInterface = Reflect.getModelInterface(model);

        if (modelInterface != null) {
            name = modelInterface.getSimpleName();

            if (name != null && name.length() > 0)
                name = name.substring(0, 1).toLowerCase() + name.substring(1);
        }

        if (name == null) {
            name = model.getClass().getSimpleName();
            name = name.replaceFirst("Default", "");
            name = name.substring(0, 1).toLowerCase() + name.substring(1);
        }
    }

    return name;
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:32,代码来源:RestHelper.java

示例11: getWrapperName

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
private static String getWrapperName(List<Model> list, Annotation[] annotations) {
    String name = null;

    XmlRootElement xmlRootElement = findXmlRootElementAnnotation(annotations);

    Model model = null;

    if (xmlRootElement == null && list != null && list.size() > 0) {
        model = list.get(0);

        xmlRootElement = model.getClass().getAnnotation(XmlRootElement.class);
    }

    if (xmlRootElement != null) {
        name = xmlRootElement.name();
    }

    if (name == null && model != null) {
        Class<? extends Model> modelInterface = Reflect.getModelInterface(model.getClass());

        if (modelInterface != null) {
            name = modelInterface.getSimpleName();
        }

        if (name == null) {
            name = model.getClass().getSimpleName();
            name = name.replaceFirst("Default", "");
        }
    }

    return name == null ? "data"
        : Inflector.pluralize(
            new StringBuilder(name.substring(0, 1).toLowerCase()).append(name.substring(1)).toString());
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:35,代码来源:JAXBWriterHelper.java

示例12: processOutputs

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
/**
 * Special for processing an @XmlElementRef outputs field
 */
private void processOutputs(RoundEnvironment roundEnv, TypeElement originalClassType, XmlElementRef elementRef,
                            VariableElement fieldElement, String fieldName, Set<EipOption> eipOptions, String prefix) {
    if ("outputs".equals(fieldName) && supportOutputs(originalClassType)) {
        String kind = "element";
        String name = elementRef.name();
        if (isNullOrEmpty(name) || "##default".equals(name)) {
            name = fieldName;
        }
        name = prefix + name;
        TypeMirror fieldType = fieldElement.asType();
        String fieldTypeName = fieldType.toString();

        // gather oneOf which extends any of the output base classes
        Set<String> oneOfTypes = new TreeSet<String>();
        // find all classes that has that superClassName
        Set<TypeElement> children = new LinkedHashSet<TypeElement>();
        for (String superclass : ONE_OF_OUTPUTS) {
            findTypeElementChildren(roundEnv, children, superclass);
        }
        for (TypeElement child : children) {
            XmlRootElement rootElement = child.getAnnotation(XmlRootElement.class);
            if (rootElement != null) {
                String childName = rootElement.name();
                if (childName != null) {
                    oneOfTypes.add(childName);
                }
            }
        }

        // remove some types which are not intended as an output in eips
        oneOfTypes.remove("route");

        EipOption ep = new EipOption(name, kind, fieldTypeName, true, "", "", false, false, null, true, oneOfTypes);
        eipOptions.add(ep);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:40,代码来源:EipAnnotationProcessor.java

示例13: processVerbs

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
/**
 * Special for processing an @XmlElementRef verbs field (rest-dsl)
 */
private void processVerbs(RoundEnvironment roundEnv, TypeElement originalClassType, XmlElementRef elementRef,
                          VariableElement fieldElement, String fieldName, Set<EipOption> eipOptions, String prefix) {

    Elements elementUtils = processingEnv.getElementUtils();

    if ("verbs".equals(fieldName) && supportOutputs(originalClassType)) {
        String kind = "element";
        String name = elementRef.name();
        if (isNullOrEmpty(name) || "##default".equals(name)) {
            name = fieldName;
        }
        name = prefix + name;
        TypeMirror fieldType = fieldElement.asType();
        String fieldTypeName = fieldType.toString();

        String docComment = findJavaDoc(elementUtils, fieldElement, fieldName, name, originalClassType, true);

        // gather oneOf which extends any of the output base classes
        Set<String> oneOfTypes = new TreeSet<String>();
        // find all classes that has that superClassName
        Set<TypeElement> children = new LinkedHashSet<TypeElement>();
        for (String superclass : ONE_OF_VERBS) {
            findTypeElementChildren(roundEnv, children, superclass);
        }
        for (TypeElement child : children) {
            XmlRootElement rootElement = child.getAnnotation(XmlRootElement.class);
            if (rootElement != null) {
                String childName = rootElement.name();
                if (childName != null) {
                    oneOfTypes.add(childName);
                }
            }
        }

        EipOption ep = new EipOption(name, kind, fieldTypeName, true, "", docComment, false, false, null, true, oneOfTypes);
        eipOptions.add(ep);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:42,代码来源:EipAnnotationProcessor.java

示例14: findQNameForSoapActionOrType

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

示例15: register

import javax.xml.bind.annotation.XmlRootElement; //导入方法依赖的package包/类
protected void register(Class<?> clazz) {
    String elementName;
    XmlRootElement rootElement = clazz.getAnnotation(XmlRootElement.class);
    if (rootElement == null || rootElement.name().equals("##default")) {
        elementName = convertClassNameToAttributeName(clazz.getSimpleName());
    }
    else {
        elementName = rootElement.name();
        if (elementName == null || elementName.length() == 0) {
            throw new IllegalArgumentException("Class " + clazz.getName() + " "  + XmlRootElement.class.getName() + " annotation name cannot be null or empty");
        }
    }
    registerBeanDefinitionParser(elementName, new XmlBeanDefinitionParser(clazz));
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:15,代码来源:AbstractXmlBeanNamespaceHandler.java


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