本文整理汇总了Java中com.sun.codemodel.internal.JType类的典型用法代码示例。如果您正苦于以下问题:Java JType类的具体用法?Java JType怎么用?Java JType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JType类属于com.sun.codemodel.internal包,在下文中一共展示了JType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: writeGetPort
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
private void writeGetPort(Port port, JType retType, JDefinedClass cls) {
JMethod m = cls.method(JMod.PUBLIC, retType, port.getPortGetter());
JDocComment methodDoc = m.javadoc();
if (port.getJavaDoc() != null) {
methodDoc.add(port.getJavaDoc());
}
JCommentPart ret = methodDoc.addReturn();
JCommentPart paramDoc = methodDoc.addParam("features");
paramDoc.append("A list of ");
paramDoc.append("{@link " + WebServiceFeature.class.getName() + "}");
paramDoc.append("to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.");
ret.add("returns " + retType.name());
m.varParam(WebServiceFeature.class, "features");
JBlock body = m.body();
StringBuilder statement = new StringBuilder("return ");
statement.append("super.getPort(new QName(\"").append(port.getName().getNamespaceURI()).append("\", \"").append(port.getName().getLocalPart()).append("\"), ");
statement.append(retType.name());
statement.append(".class, features);");
body.directStatement(statement.toString());
writeWebEndpoint(port, m);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:ServiceGenerator.java
示例2: writeMember
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
private void writeMember(JDefinedClass cls, TypeMirror paramType,
String paramName) {
if (cls == null)
return;
String accessorName =BindingHelper.mangleNameToPropertyName(paramName);
String getterPrefix = paramType.toString().equals("boolean")? "is" : "get";
JType propType = getType(paramType);
JMethod m = cls.method(JMod.PUBLIC, propType, getterPrefix+ accessorName);
JDocComment methodDoc = m.javadoc();
JCommentPart ret = methodDoc.addReturn();
ret.add("returns "+propType.name());
JBlock body = m.body();
body._return( JExpr._this().ref(paramName) );
m = cls.method(JMod.PUBLIC, cm.VOID, "set"+accessorName);
JVar param = m.param(propType, paramName);
methodDoc = m.javadoc();
JCommentPart part = methodDoc.addParam(paramName);
part.add("the value for the "+ paramName+" property");
body = m.body();
body.assign( JExpr._this().ref(paramName), param );
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:WebServiceWrapperGenerator.java
示例3: getTypeClass
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
public JType getTypeClass() {
CAdapter a = typeUse.getAdapterUse();
NType nt;
if(a!=null)
nt = a.customType;
else
nt = typeUse.getInfo().getType();
JType jt = nt.toType(outline,EXPOSED);
JPrimitiveType prim = jt.boxify().getPrimitiveType();
if(!typeUse.isCollection() && prim!=null)
jt = prim;
if(typeUse.isCollection())
jt = jt.array();
return jt;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:TypeAndAnnotationImpl.java
示例4: getType
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
/**
* Obtains a {@link JType} object for the string representation
* of a type.
*/
public static JType getType( JCodeModel codeModel,
String typeName, ErrorReceiver errorHandler, Locator errorSource ) {
try {
return codeModel.parseType(typeName);
} catch( ClassNotFoundException ee ) {
// make it a warning
errorHandler.warning( new SAXParseException(
Messages.ERR_CLASS_NOT_FOUND.format(typeName)
,errorSource));
// recover by assuming that it's a class that derives from Object
return codeModel.directClass(typeName);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:TypeUtil.java
示例5: writeDefaultGetPort
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
private void writeDefaultGetPort(Port port, JType retType, JDefinedClass cls) {
String portGetter = port.getPortGetter();
JMethod m = cls.method(JMod.PUBLIC, retType, portGetter);
JDocComment methodDoc = m.javadoc();
if (port.getJavaDoc() != null) {
methodDoc.add(port.getJavaDoc());
}
JCommentPart ret = methodDoc.addReturn();
ret.add("returns " + retType.name());
JBlock body = m.body();
StringBuilder statement = new StringBuilder("return ");
statement.append("super.getPort(new QName(\"").append(port.getName().getNamespaceURI()).append("\", \"").append(port.getName().getLocalPart()).append("\"), ");
statement.append(retType.name());
statement.append(".class);");
body.directStatement(statement.toString());
writeWebEndpoint(port, m);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:ServiceGenerator.java
示例6: getType
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
private JType getType(TypeMirror typeMirror) {
String type = typeMirror.toString();
try {
// System.out.println("typeName: "+typeName);
return cm.parseType(type);
// System.out.println("type: "+type);
} catch (ClassNotFoundException e) {
return cm.ref(type);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:WebServiceWrapperGenerator.java
示例7: listPossibleTypes
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
/**
* Returns contents to be added to javadoc.
*/
protected final List<Object> listPossibleTypes( CPropertyInfo prop ) {
List<Object> r = new ArrayList<Object>();
for( CTypeInfo tt : prop.ref() ) {
JType t = tt.getType().toType(outline.parent(),Aspect.EXPOSED);
if( t.isPrimitive() || t.isArray() )
r.add(t.fullName());
else {
r.add(t);
r.add("\n");
}
}
return r;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:AbstractField.java
示例8: getType
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
@Override
protected JType getType(final Aspect aspect) {
if (Aspect.IMPLEMENTATION.equals(aspect)) {
return super.getType(aspect);
}
if (prop instanceof CReferencePropertyInfo) {
Set<CElement> elements = ((CReferencePropertyInfo)prop).getElements();
if ((elements != null) && (elements.size() > 0)) {
return codeModel.ref(Serializable.class);
}
}
return codeModel.ref(String.class);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:NoExtendedContentField.java
示例9: getType
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
@Override
protected JType getType(final Aspect aspect) {
if (Aspect.IMPLEMENTATION.equals(aspect)) {
return super.getType(aspect);
}
return codeModel.ref(Serializable.class);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:ContentListField.java
示例10: ElementOutlineImpl
import com.sun.codemodel.internal.JType; //导入依赖的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
示例11: printName
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
/** Get the display name of a type. */
private String printName( JType t ) {
String name = t.fullName();
if(name.startsWith("java.lang."))
name = name.substring(10); // chop off the package name
return name;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:SignatureWriter.java
示例12: toType
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
public JType toType(Outline o, Aspect aspect) {
try {
return o.getCodeModel().parseType(t.toString());
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError(e.getMessage());
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:EagerNType.java
示例13: getBaseType
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
public JType getBaseType() {
if(baseType!=null && baseType.name!=null) {
return TypeUtil.getType(getCodeModel(),
baseType.name,
Ring.get(ErrorReceiver.class),getLocation());
}
BIProperty next = getDefault();
if(next!=null) return next.getBaseType();
else return null;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:BIProperty.java
示例14: write
import com.sun.codemodel.internal.JType; //导入依赖的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
示例15: writeGetWsdlLocation
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
private void writeGetWsdlLocation(JType retType, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) {
JMethod m = cls.method(JMod.PRIVATE|JMod.STATIC , retType, "__getWsdlLocation");
JConditional ifBlock = m.body()._if(exField.ne(JExpr._null()));
ifBlock._then()._throw(exField);
m.body()._return(urlField);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:ServiceGenerator.java
示例16: setType
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
public void setType(JType type) {
this.type = type;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:JAXBTypeAndAnnotation.java
示例17: JAXBTypeAndAnnotation
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
public JAXBTypeAndAnnotation(JType type) {
this.type = type;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:JAXBTypeAndAnnotation.java
示例18: setType
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
public void setType( JType _type ) {
if( this.type==null )
this.type = _type;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:SymbolSpace.java
示例19: getRawType
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
public JType getRawType() {
return core.getRawType();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:IsSetField.java
示例20: generateField
import com.sun.codemodel.internal.JType; //导入依赖的package包/类
/**
* Generates the field declaration.
*/
protected final JFieldVar generateField( JType type ) {
return outline.implClass.field( JMod.PROTECTED, type, prop.getName(false) );
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:AbstractField.java
注:本文中的com.sun.codemodel.internal.JType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论