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