本文整理汇总了Java中com.sun.codemodel.internal.JFieldVar类的典型用法代码示例。如果您正苦于以下问题:Java JFieldVar类的具体用法?Java JFieldVar怎么用?Java JFieldVar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JFieldVar类属于com.sun.codemodel.internal包,在下文中一共展示了JFieldVar类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getQNameInvocation
import com.sun.codemodel.internal.JFieldVar; //导入依赖的package包/类
/**
* return a JFieldVar that represents the QName field for the given information.
*
* if it doesn't exist, create a static field in the class and store a new JFieldVar.
*/
private JExpression getQNameInvocation(CElementInfo ei) {
QName name = ei.getElementName();
if(qnameMap.containsKey(name)) {
return qnameMap.get(name);
}
if(qnameMap.size()>1024)
// stop gap measure to avoid 'code too large' error in javac.
return createQName(name);
// [RESULT]
// private static final QName _XYZ_NAME = new QName("uri", "local");
JFieldVar qnameField = objectFactory.field(
JMod.PRIVATE | JMod.STATIC | JMod.FINAL,
QName.class,
'_' + ei.getSqueezedName() + "_QNAME", createQName(name));
qnameMap.put(name, qnameField);
return qnameField;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:ObjectFactoryGeneratorImpl.java
示例2: writeAbsWSDLLocation
import com.sun.codemodel.internal.JFieldVar; //导入依赖的package包/类
private void writeAbsWSDLLocation(JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
JBlock staticBlock = cls.init();
JVar urlVar = staticBlock.decl(cm.ref(URL.class), "url", JExpr._null());
JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
JTryBlock tryBlock = staticBlock._try();
tryBlock.body().assign(urlVar, JExpr._new(cm.ref(URL.class)).arg(wsdlLocation));
JCatchBlock catchBlock = tryBlock._catch(cm.ref(MalformedURLException.class));
catchBlock.param("ex");
catchBlock.body().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(JExpr.ref("ex")));
staticBlock.assign(urlField, urlVar);
staticBlock.assign(exField, exVar);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:ServiceGenerator.java
示例3: writeResourceWSDLLocation
import com.sun.codemodel.internal.JFieldVar; //导入依赖的package包/类
private void writeResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
JBlock staticBlock = cls.init();
staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(wsdlLocation));
JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
"Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
staticBlock.assign(exField, exVar);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ServiceGenerator.java
示例4: writeClassLoaderResourceWSDLLocation
import com.sun.codemodel.internal.JFieldVar; //导入依赖的package包/类
private void writeClassLoaderResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
JBlock staticBlock = cls.init();
staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getClassLoader").invoke("getResource").arg(wsdlLocation));
JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null()));
ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(
"Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath."));
staticBlock.assign(exField, exVar);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ServiceGenerator.java
示例5: writeClassLoaderBaseResourceWSDLLocation
import com.sun.codemodel.internal.JFieldVar; //导入依赖的package包/类
private void writeClassLoaderBaseResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
JBlock staticBlock = cls.init();
JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null());
JVar urlVar = staticBlock.decl(cm.ref(URL.class), "url", JExpr._null());
JTryBlock tryBlock = staticBlock._try();
tryBlock.body().assign(urlVar, JExpr._new(cm.ref(URL.class)).arg(JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(".")).arg(wsdlLocation));
JCatchBlock catchBlock = tryBlock._catch(cm.ref(MalformedURLException.class));
JVar murlVar = catchBlock.param("murl");
catchBlock.body().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg(murlVar));
staticBlock.assign(urlField, urlVar);
staticBlock.assign(exField, exVar);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:ServiceGenerator.java
示例6: generateAttributeWildcard
import com.sun.codemodel.internal.JFieldVar; //导入依赖的package包/类
/**
* Generates an attribute wildcard property on a class.
*/
private void generateAttributeWildcard(ClassOutlineImpl cc) {
String FIELD_NAME = "otherAttributes";
String METHOD_SEED = model.getNameConverter().toClassName(FIELD_NAME);
JClass mapType = codeModel.ref(Map.class).narrow(QName.class, String.class);
JClass mapImpl = codeModel.ref(HashMap.class).narrow(QName.class, String.class);
// [RESULT]
// Map<QName,String> m = new HashMap<QName,String>();
JFieldVar $ref = cc.implClass.field(JMod.PRIVATE,
mapType, FIELD_NAME, JExpr._new(mapImpl));
$ref.annotate2(XmlAnyAttributeWriter.class);
MethodWriter writer = cc.createMethodWriter();
JMethod $get = writer.declareMethod(mapType, "get" + METHOD_SEED);
$get.javadoc().append(
"Gets a map that contains attributes that aren't bound to any typed property on this class.\n\n"
+ "<p>\n"
+ "the map is keyed by the name of the attribute and \n"
+ "the value is the string value of the attribute.\n"
+ "\n"
+ "the map returned by this method is live, and you can add new attribute\n"
+ "by updating the map directly. Because of this design, there's no setter.\n");
$get.javadoc().addReturn().append("always non-null");
$get.body()._return($ref);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:BeanGenerator.java
示例7: ElementOutlineImpl
import com.sun.codemodel.internal.JFieldVar; //导入依赖的package包/类
ElementOutlineImpl(BeanGenerator parent, CElementInfo ei) {
super(ei,
parent.getClassFactory().createClass(
parent.getContainer( ei.parent, Aspect.EXPOSED ), ei.shortName(), ei.getLocator() ));
this.parent = parent;
parent.elements.put(ei,this);
JCodeModel cm = parent.getCodeModel();
implClass._extends(
cm.ref(JAXBElement.class).narrow(
target.getContentInMemoryType().toType(parent,Aspect.EXPOSED).boxify()));
if(ei.hasClass()) {
JType implType = ei.getContentInMemoryType().toType(parent,Aspect.IMPLEMENTATION);
JExpression declaredType = JExpr.cast(cm.ref(Class.class),implType.boxify().dotclass()); // why do we have to cast?
JClass scope=null;
if(ei.getScope()!=null)
scope = parent.getClazz(ei.getScope()).implRef;
JExpression scopeClass = scope==null?JExpr._null():scope.dotclass();
JFieldVar valField = implClass.field(JMod.PROTECTED|JMod.FINAL|JMod.STATIC,QName.class,"NAME",createQName(cm,ei.getElementName()));
// take this opportunity to generate a constructor in the element class
JMethod cons = implClass.constructor(JMod.PUBLIC);
cons.body().invoke("super")
.arg(valField)
.arg(declaredType)
.arg(scopeClass)
.arg(cons.param(implType,"value"));
// generate no-arg constructor in the element class (bug #391; section 5.6.2 in JAXB spec 2.1)
JMethod noArgCons = implClass.constructor(JMod.PUBLIC);
noArgCons.body().invoke("super")
.arg(valField)
.arg(declaredType)
.arg(scopeClass)
.arg(JExpr._null());
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:ElementOutlineImpl.java
示例8: augument
import com.sun.codemodel.internal.JFieldVar; //导入依赖的package包/类
/**
* Adds "@Generated" to the classes, methods, and fields.
*/
private void augument(ClassOutline co) {
annotate(co.implClass);
for (JMethod m : co.implClass.methods())
annotate(m);
for (JFieldVar f : co.implClass.fields().values())
annotate(f);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:PluginImpl.java
注:本文中的com.sun.codemodel.internal.JFieldVar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论