com.sun.codemodel.internal.JType Java Examples

The following examples show how to use com.sun.codemodel.internal.JType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: TypeAndAnnotationImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: ServiceGenerator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: TypeAndAnnotationImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: WebServiceWrapperGenerator.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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 );
}
 
Example #6
Source File: WebServiceWrapperGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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 );
}
 
Example #7
Source File: WebServiceWrapperGenerator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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 );
}
 
Example #8
Source File: AbstractField.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: NoExtendedContentField.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #10
Source File: BIProperty.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #11
Source File: EagerNType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public JType toType(Outline o, Aspect aspect) {
    try {
        return o.getCodeModel().parseType(t.toString());
    } catch (ClassNotFoundException e) {
        throw new NoClassDefFoundError(e.getMessage());
    }
}
 
Example #12
Source File: NoExtendedContentField.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #13
Source File: BIProperty.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #14
Source File: EagerNType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public JType toType(Outline o, Aspect aspect) {
    try {
        return o.getCodeModel().parseType(t.toString());
    } catch (ClassNotFoundException e) {
        throw new NoClassDefFoundError(e.getMessage());
    }
}
 
Example #15
Source File: BIProperty.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #16
Source File: WebServiceWrapperGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
 
Example #17
Source File: ContentListField.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected JType getType(final Aspect aspect) {
    if (Aspect.IMPLEMENTATION.equals(aspect)) {
        return super.getType(aspect);
    }
    return codeModel.ref(Serializable.class);
}
 
Example #18
Source File: AbstractField.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #19
Source File: ContentListField.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected JType getType(final Aspect aspect) {
    if (Aspect.IMPLEMENTATION.equals(aspect)) {
        return super.getType(aspect);
    }
    return codeModel.ref(Serializable.class);
}
 
Example #20
Source File: EagerNType.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public JType toType(Outline o, Aspect aspect) {
    try {
        return o.getCodeModel().parseType(t.toString());
    } catch (ClassNotFoundException e) {
        throw new NoClassDefFoundError(e.getMessage());
    }
}
 
Example #21
Source File: CBuiltinLeafInfo.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Gets the code model representation of this type.
 */
public JType toType(Outline o, Aspect aspect) {
    return getType().toType(o,aspect);
}
 
Example #22
Source File: AbstractFieldWithVar.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public final JType getRawType() {
    return exposedType;
}
 
Example #23
Source File: ElementSingleAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public JType getRawType() {
    return ei.getContentInMemoryType().toType(outline(), Aspect.EXPOSED);
}
 
Example #24
Source File: JAXBTypeAndAnnotation.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public JAXBTypeAndAnnotation(TypeAndAnnotation typeAnn, JType type) {
    this.typeAnn = typeAnn;
    this.type = type;
}
 
Example #25
Source File: ElementCollectionAdapter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public JType getRawType() {
    return codeModel().ref(List.class).narrow(itemType().boxify());
}
 
Example #26
Source File: ElementSingleAdapter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public JType getRawType() {
    return ei.getContentInMemoryType().toType(outline(), Aspect.EXPOSED);
}
 
Example #27
Source File: PropertyImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public final JType type() {
    return fr.getRawType();
}
 
Example #28
Source File: JAXBTypeAndAnnotation.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void setType(JType type) {
    this.type = type;
}
 
Example #29
Source File: PropertyImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public final JType type() {
    return fr.getRawType();
}
 
Example #30
Source File: BeanGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public final JType resolve(CTypeRef ref, Aspect a) {
    return ref.getTarget().getType().toType(this, a);
}