本文整理汇总了Java中com.sun.codemodel.internal.JFieldRef类的典型用法代码示例。如果您正苦于以下问题:Java JFieldRef类的具体用法?Java JFieldRef怎么用?Java JFieldRef使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JFieldRef类属于com.sun.codemodel.internal包,在下文中一共展示了JFieldRef类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: write
import com.sun.codemodel.internal.JFieldRef; //导入依赖的package包/类
private void write(Fault fault) throws JClassAlreadyExistsException {
String className = Names.customExceptionClassName(fault);
JDefinedClass cls = cm._class(className, ClassType.CLASS);
JDocComment comment = cls.javadoc();
if(fault.getJavaDoc() != null){
comment.add(fault.getJavaDoc());
comment.add("\n\n");
}
for (String doc : getJAXWSClassComment()) {
comment.add(doc);
}
cls._extends(java.lang.Exception.class);
//@WebFault
JAnnotationUse faultAnn = cls.annotate(WebFault.class);
faultAnn.param("name", fault.getBlock().getName().getLocalPart());
faultAnn.param("targetNamespace", fault.getBlock().getName().getNamespaceURI());
JType faultBean = fault.getBlock().getType().getJavaType().getType().getType();
//faultInfo filed
JFieldVar fi = cls.field(JMod.PRIVATE, faultBean, "faultInfo");
//add jaxb annotations
fault.getBlock().getType().getJavaType().getType().annotate(fi);
fi.javadoc().add("Java type that goes as soapenv:Fault detail element.");
JFieldRef fr = JExpr.ref(JExpr._this(), fi);
//Constructor
JMethod constrc1 = cls.constructor(JMod.PUBLIC);
JVar var1 = constrc1.param(String.class, "message");
JVar var2 = constrc1.param(faultBean, "faultInfo");
constrc1.javadoc().addParam(var1);
constrc1.javadoc().addParam(var2);
JBlock cb1 = constrc1.body();
cb1.invoke("super").arg(var1);
cb1.assign(fr, var2);
//constructor with Throwable
JMethod constrc2 = cls.constructor(JMod.PUBLIC);
var1 = constrc2.param(String.class, "message");
var2 = constrc2.param(faultBean, "faultInfo");
JVar var3 = constrc2.param(Throwable.class, "cause");
constrc2.javadoc().addParam(var1);
constrc2.javadoc().addParam(var2);
constrc2.javadoc().addParam(var3);
JBlock cb2 = constrc2.body();
cb2.invoke("super").arg(var1).arg(var3);
cb2.assign(fr, var2);
//getFaultInfo() method
JMethod fim = cls.method(JMod.PUBLIC, faultBean, "getFaultInfo");
fim.javadoc().addReturn().add("returns fault bean: "+faultBean.fullName());
JBlock fib = fim.body();
fib._return(fi);
fault.setExceptionClass(cls);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:65,代码来源:CustomExceptionGenerator.java
注:本文中的com.sun.codemodel.internal.JFieldRef类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论