com.sun.codemodel.internal.JCodeModel Java Examples

The following examples show how to use com.sun.codemodel.internal.JCodeModel. 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: IsSetField.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) {
    // add isSetXXX and unsetXXX.
    MethodWriter writer = outline.createMethodWriter();

    JCodeModel codeModel = outline.parent().getCodeModel();

    FieldAccessor acc = core.create(JExpr._this());

    if( generateIsSetMethod ) {
        // [RESULT] boolean isSetXXX()
        JExpression hasSetValue = acc.hasSetValue();
        if( hasSetValue==null ) {
            // this field renderer doesn't support the isSet/unset methods generation.
            // issue an error
            throw new UnsupportedOperationException();
        }
        writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true))
            .body()._return( hasSetValue );
    }

    if( generateUnSetMethod ) {
        // [RESULT] void unsetXXX()
        acc.unsetValues(
            writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() );
    }
}
 
Example #2
Source File: RELAXNGCompiler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #3
Source File: ElementCollectionAdapter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void fromRawValue(JBlock block, String uniqueName, JExpression $var) {
    JCodeModel cm = outline().getCodeModel();
    JClass elementType = ei.toType(outline(),EXPOSED).boxify();

    // [RESULT]
    // $t = new ArrayList();
    // for( Type e : $var ) {
    //     $var.add(new JAXBElement(e));
    // }
    // [core.fromRawValue]

    JClass col = cm.ref(ArrayList.class).narrow(elementType);
    JVar $t = block.decl(col,uniqueName+"_col",JExpr._new(col));

    JForEach loop = block.forEach(itemType(), uniqueName+"_i", $t);
    loop.body().invoke($var,"add").arg(createJAXBElement(loop.var()));

    acc.fromRawValue(block, uniqueName, $t);
}
 
Example #4
Source File: BIConversion.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #5
Source File: RELAXNGCompiler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #6
Source File: TypeUtil.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #7
Source File: RELAXNGCompiler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #8
Source File: BIConversion.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #9
Source File: RELAXNGCompiler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #10
Source File: RELAXNGCompiler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #11
Source File: BIConversion.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public TypeUse getTypeUse(XSSimpleType owner) {
    if(typeUse!=null)
        return typeUse;

    JCodeModel cm = getCodeModel();

    JDefinedClass a;
    try {
        a = cm._class(adapter);
        a.hide();   // we assume this is given by the user
        a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow(
                cm.ref(type)));
    } catch (JClassAlreadyExistsException e) {
        a = e.getExistingClass();
    }

    // TODO: it's not correct to say that it adapts from String,
    // but OTOH I don't think we can compute that.
    typeUse = TypeUseFactory.adapt(
            CBuiltinLeafInfo.STRING,
            new CAdapter(a));

    return typeUse;
}
 
Example #12
Source File: TypeUtil.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #13
Source File: CClassInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public CClassInfo(Model model,JCodeModel cm, String fullName, Locator location, QName typeName, QName elementName, XSComponent source, CCustomizations customizations) {
    super(model,source,location,customizations);
    this.model = model;
    int idx = fullName.indexOf('.');
    if(idx<0) {
        this.parent = model.getPackage(cm.rootPackage());
        this.shortName = model.allocator.assignClassName(parent,fullName);
    } else {
        this.parent = model.getPackage(cm._package(fullName.substring(0,idx)));
        this.shortName = model.allocator.assignClassName(parent,fullName.substring(idx+1));
    }
    this.typeName = typeName;
    this.elementName = elementName;

    model.add(this);
}
 
Example #14
Source File: IsSetField.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) {
    // add isSetXXX and unsetXXX.
    MethodWriter writer = outline.createMethodWriter();

    JCodeModel codeModel = outline.parent().getCodeModel();

    FieldAccessor acc = core.create(JExpr._this());

    if( generateIsSetMethod ) {
        // [RESULT] boolean isSetXXX()
        JExpression hasSetValue = acc.hasSetValue();
        if( hasSetValue==null ) {
            // this field renderer doesn't support the isSet/unset methods generation.
            // issue an error
            throw new UnsupportedOperationException();
        }
        writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true))
            .body()._return( hasSetValue );
    }

    if( generateUnSetMethod ) {
        // [RESULT] void unsetXXX()
        acc.unsetValues(
            writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() );
    }
}
 
Example #15
Source File: BGMBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Entry point.
 */
public static Model build( XSSchemaSet _schemas, JCodeModel codeModel,
        ErrorReceiver _errorReceiver, Options opts ) {
    // set up a ring
    final Ring old = Ring.begin();
    try {
        ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver);

        Ring.add(XSSchemaSet.class,_schemas);
        Ring.add(codeModel);
        Model model = new Model(opts, codeModel, null/*set later*/, opts.classNameAllocator, _schemas);
        Ring.add(model);
        Ring.add(ErrorReceiver.class,ef);
        Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef));

        BGMBuilder builder = new BGMBuilder(opts.defaultPackage,opts.defaultPackage2,
            opts.isExtensionMode(),opts.getFieldRendererFactory(), opts.activePlugins);
        builder._build();

        if(ef.hadError())   return null;
        else                return model;
    } finally {
        Ring.end(old);
    }
}
 
Example #16
Source File: TypeUtil.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #17
Source File: Model.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param nc
 *      Usually this should be set in the constructor, but we do allow this parameter
 *      to be initially null, and then set later.
 * @param schemaComponent
 *      The source schema model, if this is built from XSD.
 */
public Model( Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent ) {
    this.options = opts;
    this.codeModel = cm;
    this.nameConverter = nc;
    this.defaultSymbolSpace = new SymbolSpace(codeModel);
    defaultSymbolSpace.setType(codeModel.ref(Object.class));

    elementMappings.put(null,new HashMap<QName,CElementInfo>());

    if(opts.automaticNameConflictResolution)
        allocator = new AutoClassNameAllocator(allocator);
    this.allocator = new ClassNameAllocatorWrapper(allocator);
    this.schemaComponent = schemaComponent;
    this.gloablCustomizations.setParent(this,this);
}
 
Example #18
Source File: IsSetField.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void generate( ClassOutlineImpl outline, CPropertyInfo prop ) {
    // add isSetXXX and unsetXXX.
    MethodWriter writer = outline.createMethodWriter();

    JCodeModel codeModel = outline.parent().getCodeModel();

    FieldAccessor acc = core.create(JExpr._this());

    if( generateIsSetMethod ) {
        // [RESULT] boolean isSetXXX()
        JExpression hasSetValue = acc.hasSetValue();
        if( hasSetValue==null ) {
            // this field renderer doesn't support the isSet/unset methods generation.
            // issue an error
            throw new UnsupportedOperationException();
        }
        writer.declareMethod(codeModel.BOOLEAN,"isSet"+this.prop.getName(true))
            .body()._return( hasSetValue );
    }

    if( generateUnSetMethod ) {
        // [RESULT] void unsetXXX()
        acc.unsetValues(
            writer.declareMethod(codeModel.VOID,"unset"+this.prop.getName(true)).body() );
    }
}
 
Example #19
Source File: TypeUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #20
Source File: ElementOutlineImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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());

    }
}
 
Example #21
Source File: WhitespaceNormalizer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public JExpression generate( JCodeModel codeModel, JExpression literal ) {
    // WhitespaceProcessor.replace(<literal>);
    if( literal instanceof JStringLiteral )
        // optimize
        return JExpr.lit( WhiteSpaceProcessor.replace(((JStringLiteral)literal).str) );
    else
        return codeModel.ref(WhiteSpaceProcessor.class)
            .staticInvoke("replace").arg(literal);
}
 
Example #22
Source File: WhitespaceNormalizer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public JExpression generate( JCodeModel codeModel, JExpression literal ) {
    // WhitespaceProcessor.replace(<literal>);
    if( literal instanceof JStringLiteral )
        // optimize
        return JExpr.lit( WhiteSpaceProcessor.collapse(((JStringLiteral)literal).str) );
    else
        return codeModel.ref(WhiteSpaceProcessor.class)
            .staticInvoke("collapse").arg(literal);
}
 
Example #23
Source File: ElementAdapter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Wraps a type value into a {@link JAXBElement}.
 */
protected final JInvocation createJAXBElement(JExpression $var) {
    JCodeModel cm = codeModel();

    return JExpr._new(cm.ref(JAXBElement.class))
        .arg(JExpr._new(cm.ref(QName.class))
            .arg(ei.getElementName().getNamespaceURI())
            .arg(ei.getElementName().getLocalPart()))
        .arg(getRawType().boxify().erasure().dotclass())
        .arg($var);
}
 
Example #24
Source File: ElementOutlineImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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());

    }
}
 
Example #25
Source File: AsyncOperation.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public JavaType getResponseBeanJavaType(){
    JCodeModel cm = _responseBean.getJavaType().getType().getType().owner();
    if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){
        JClass future = cm.ref(java.util.concurrent.Future.class).narrow(cm.ref(Object.class).wildcard());
        return new JavaSimpleType(new JAXBTypeAndAnnotation(future));
    }else if(_asyncOpType.equals(AsyncOperationType.POLLING)){
        JClass polling = cm.ref(javax.xml.ws.Response.class).narrow(_responseBean.getJavaType().getType().getType().boxify());
        return new JavaSimpleType(new JAXBTypeAndAnnotation(polling));
    }
    return null;
}
 
Example #26
Source File: AsyncOperation.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public JavaType getResponseBeanJavaType(){
    JCodeModel cm = _responseBean.getJavaType().getType().getType().owner();
    if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){
        JClass future = cm.ref(java.util.concurrent.Future.class).narrow(cm.ref(Object.class).wildcard());
        return new JavaSimpleType(new JAXBTypeAndAnnotation(future));
    }else if(_asyncOpType.equals(AsyncOperationType.POLLING)){
        JClass polling = cm.ref(javax.xml.ws.Response.class).narrow(_responseBean.getJavaType().getType().getType().boxify());
        return new JavaSimpleType(new JAXBTypeAndAnnotation(polling));
    }
    return null;
}
 
Example #27
Source File: AsyncOperation.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public JavaType getResponseBeanJavaType(){
    JCodeModel cm = _responseBean.getJavaType().getType().getType().owner();
    if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){
        JClass future = cm.ref(java.util.concurrent.Future.class).narrow(cm.ref(Object.class).wildcard());
        return new JavaSimpleType(new JAXBTypeAndAnnotation(future));
    }else if(_asyncOpType.equals(AsyncOperationType.POLLING)){
        JClass polling = cm.ref(javax.xml.ws.Response.class).narrow(_responseBean.getJavaType().getType().getType().boxify());
        return new JavaSimpleType(new JAXBTypeAndAnnotation(polling));
    }
    return null;
}
 
Example #28
Source File: WhitespaceNormalizer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public JExpression generate( JCodeModel codeModel, JExpression literal ) {
    // WhitespaceProcessor.replace(<literal>);
    if( literal instanceof JStringLiteral )
        // optimize
        return JExpr.lit( WhiteSpaceProcessor.replace(((JStringLiteral)literal).str) );
    else
        return codeModel.ref(WhiteSpaceProcessor.class)
            .staticInvoke("replace").arg(literal);
}
 
Example #29
Source File: AsyncOperation.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public JavaType getResponseBeanJavaType(){
    JCodeModel cm = _responseBean.getJavaType().getType().getType().owner();
    if(_asyncOpType.equals(AsyncOperationType.CALLBACK)){
        JClass future = cm.ref(java.util.concurrent.Future.class).narrow(cm.ref(Object.class).wildcard());
        return new JavaSimpleType(new JAXBTypeAndAnnotation(future));
    }else if(_asyncOpType.equals(AsyncOperationType.POLLING)){
        JClass polling = cm.ref(javax.xml.ws.Response.class).narrow(_responseBean.getJavaType().getType().getType().boxify());
        return new JavaSimpleType(new JAXBTypeAndAnnotation(polling));
    }
    return null;
}
 
Example #30
Source File: ElementAdapter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Wraps a type value into a {@link JAXBElement}.
 */
protected final JInvocation createJAXBElement(JExpression $var) {
    JCodeModel cm = codeModel();

    return JExpr._new(cm.ref(JAXBElement.class))
        .arg(JExpr._new(cm.ref(QName.class))
            .arg(ei.getElementName().getNamespaceURI())
            .arg(ei.getElementName().getLocalPart()))
        .arg(getRawType().boxify().erasure().dotclass())
        .arg($var);
}