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


Java XmlType.factoryMethod方法代码示例

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


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

示例1: hasFactoryConstructor

import javax.xml.bind.annotation.XmlType; //导入方法依赖的package包/类
/**
 *  XmlType allows specification of factoryClass and
 *  factoryMethod.  There are to be used if no default
 *  constructor is found.
 *
 * @return
 *      true if the factory method was found. False if not.
 */
private  boolean hasFactoryConstructor(XmlType t){
    if (t == null) return false;

    String method = t.factoryMethod();
    T fClass = reader().getClassValue(t, "factoryClass");
    if (method.length() > 0){
        if(nav().isSameType(fClass, nav().ref(XmlType.DEFAULT.class))){
            fClass = nav().use(clazz);
        }
        for(M m: nav().getDeclaredMethods(nav().asDecl(fClass))){
            //- Find the zero-arg public static method with the required return type
            if (nav().getMethodName(m).equals(method) &&
                nav().isSameType(nav().getReturnType(m), nav().use(clazz)) &&
                nav().getMethodParameters(m).length == 0 &&
                nav().isStaticMethod(m)){
                factoryMethod = m;
                break;
            }
        }
        if (factoryMethod == null){
            builder.reportError(new IllegalAnnotationException(
            Messages.NO_FACTORY_METHOD.format(nav().getClassName(nav().asDecl(fClass)), method), this ));
        }
    } else if(!nav().isSameType(fClass, nav().ref(XmlType.DEFAULT.class))){
        builder.reportError(new IllegalAnnotationException(
            Messages.FACTORY_CLASS_NEEDS_FACTORY_METHOD.format(nav().getClassName(nav().asDecl(fClass))), this ));
    }
    return factoryMethod != null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:ClassInfoImpl.java

示例2: hasFactoryConstructor

import javax.xml.bind.annotation.XmlType; //导入方法依赖的package包/类
/**
 *  XmlType allows specification of factoryClass and
 *  factoryMethod.  There are to be used if no default
 *  constructor is found.
 *
 * @return
 *      true if the factory method was found. False if not.
 */
private  boolean hasFactoryConstructor(XmlType t){
    if (t == null) return false;

    String method = t.factoryMethod();
    T fClass = reader().getClassValue(t, "factoryClass");
    if (method.length() > 0){
        if(fClass.equals(nav().ref(XmlType.DEFAULT.class))){
            fClass = nav().use(clazz);
        }
        for(M m: nav().getDeclaredMethods(nav().asDecl(fClass))){
            //- Find the zero-arg public static method with the required return type
            if (nav().getMethodName(m).equals(method) &&
                nav().getReturnType(m).equals(nav().use(clazz)) &&
                nav().getMethodParameters(m).length == 0 &&
                nav().isStaticMethod(m)){
                factoryMethod = m;
                break;
            }
        }
        if (factoryMethod == null){
            builder.reportError(new IllegalAnnotationException(
            Messages.NO_FACTORY_METHOD.format(nav().getClassName(nav().asDecl(fClass)), method), this ));
        }
    } else if(!fClass.equals(nav().ref(XmlType.DEFAULT.class))){
        builder.reportError(new IllegalAnnotationException(
            Messages.FACTORY_CLASS_NEEDS_FACTORY_METHOD.format(nav().getClassName(nav().asDecl(fClass))), this ));
    }
    return factoryMethod != null;
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:38,代码来源:ClassInfoImpl.java


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