• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.codemodel.internal.JExpression的典型用法代码示例。如果您正苦于以下问题:Java JExpression类的具体用法?Java JExpression怎么用?Java JExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JExpression类属于com.sun.codemodel.internal包,在下文中一共展示了JExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: generate

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
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() );
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:IsSetField.java


示例2: getQNameInvocation

import com.sun.codemodel.internal.JExpression; //导入依赖的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


示例3: fromRawValue

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:ElementCollectionAdapter.java


示例4: createConstant

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
public JExpression createConstant(Outline outline, XmlString lexical) {
    if(isCollection())  return null;

    if(adapter==null)     return coreType.createConstant(outline, lexical);

    // [RESULT] new Adapter().unmarshal(CONSTANT);
    JExpression cons = coreType.createConstant(outline, lexical);
    Class<? extends XmlAdapter> atype = adapter.getAdapterIfKnown();

    // try to run the adapter now rather than later.
    if(cons instanceof JStringLiteral && atype!=null) {
        JStringLiteral scons = (JStringLiteral) cons;
        XmlAdapter a = ClassFactory.create(atype);
        try {
            Object value = a.unmarshal(scons.str);
            if(value instanceof String) {
                return JExpr.lit((String)value);
            }
        } catch (Exception e) {
            // assume that we can't eagerly bind this
        }
    }

    return JExpr._new(adapter.getAdapterClass(outline)).invoke("unmarshal").arg(cons);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:TypeUseImpl.java


示例5: generate

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:WhitespaceNormalizer.java


示例6: castToImplType

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
/**
 * Case from {@link #exposedType} to {@link #implType} if necessary.
 */
protected final JExpression castToImplType( JExpression exp ) {
    if(implType==exposedType)
        return exp;
    else
        return JExpr.cast(implType,exp);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:AbstractField.java


示例7: create

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
public FieldAccessor create(JExpression targetObject) {
    return new Accessor(targetObject) {

        public void unsetValues( JBlock body ) {
            // you can't unset a value
        }

        public JExpression hasSetValue() {
            return JExpr.TRUE;
        }
    };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:UnboxedField.java


示例8: createConstant

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
public JExpression createConstant(Outline outline, XmlString literal) {
    // correctly identifying which constant it maps to is hard, so
    // here I'm cheating
    JClass type = toType(outline,Aspect.EXPOSED);
    for (CEnumConstant mem : members) {
        if(mem.getLexicalValue().equals(literal.value))
            return type.staticRef(mem.getName());
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:CEnumLeafInfo.java


示例9: create

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
/**
 * Creates a new {@link CDefaultValue} that computes the default value
 * by applying a lexical representation to a {@link TypeUse}.
 */
public static CDefaultValue create(final TypeUse typeUse, final XmlString defaultValue) {
    return new CDefaultValue() {
        public JExpression compute(Outline outline) {
            return typeUse.createConstant(outline,defaultValue);
        }
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:CDefaultValue.java


示例10: ElementOutlineImpl

import com.sun.codemodel.internal.JExpression; //导入依赖的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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:ElementOutlineImpl.java


示例11: createJAXBElement

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ElementAdapter.java


示例12: fromRawValue

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
public void fromRawValue(JBlock block, String uniqueName, JExpression $var) {
    // [RESULT]
    // bean.getLIST().addAll($<var>);
    JVar $list = block.decl(listT,uniqueName+'l',$target.invoke($get));
    block.invoke($list,"addAll").arg($var);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:NoExtendedContentField.java


示例13: create

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
public FieldAccessor create(JExpression targetObject) {
    return new Accessor(targetObject);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:IsSetField.java


示例14: Accessor

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
Accessor( JExpression $target ) {
    super($target);
    this.core = IsSetField.this.core.create($target);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:IsSetField.java


示例15: hasSetValue

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
public JExpression hasSetValue() {
    return $ref.ne( JExpr._null() );
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:SingleField.java


示例16: create

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
public Accessor create(JExpression targetObject) {
    return new Accessor(targetObject);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:UntypedListField.java


示例17: Accessor

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
protected Accessor( JExpression $target ) {
    super($target);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:UntypedListField.java


示例18: fromRawValue

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
public void fromRawValue(JBlock block, String uniqueName, JExpression $var) {
    block.invoke($target,$setAll).arg($var);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:ArrayField.java


示例19: hasSetValue

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
@Override
public JExpression hasSetValue() {
    return field.ne(JExpr._null()).cand(field.ref("length").gt(JExpr.lit(0)));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:ArrayField.java


示例20: castToImplTypeArray

import com.sun.codemodel.internal.JExpression; //导入依赖的package包/类
/**
 * Case from {@link #exposedType} to array of {@link #implType} .
 */
protected final JExpression castToImplTypeArray( JExpression exp ) {
    return JExpr.cast(implType.array(), exp);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:ArrayField.java



注:本文中的com.sun.codemodel.internal.JExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExprFunction类代码示例发布时间:2022-05-23
下一篇:
Java BucketTaggingConfiguration类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap