本文整理汇总了Java中com.sun.codemodel.JBlock.assign方法的典型用法代码示例。如果您正苦于以下问题:Java JBlock.assign方法的具体用法?Java JBlock.assign怎么用?Java JBlock.assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.codemodel.JBlock
的用法示例。
在下文中一共展示了JBlock.assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitDecimalConstant
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
@Override
public HoldingContainer visitDecimalConstant(DecimalExpression e, ClassGenerator<?> generator)
throws RuntimeException {
CompleteType majorType= e.getCompleteType();
JBlock setup = generator.getBlock(BlockType.SETUP);
JType holderType = majorType.getHolderType(generator.getModel());
JVar var = generator.declareClassField("dec", holderType);
JExpression valueLiteral = JExpr.lit(e.getIntFromDecimal());
JExpression scaleLiteral = JExpr.lit(e.getScale());
JExpression precisionLiteral = JExpr.lit(e.getPrecision());
setup.assign(
var,
generator.getModel().ref(ValueHolderHelper.class).staticInvoke("getNullableDecimalHolder").arg(valueLiteral)
.arg(scaleLiteral).arg(precisionLiteral));
return new HoldingContainer(majorType, var, var.ref("value"), var.ref("isSet"));
}
示例2: renderEnd
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
@Override
public HoldingContainer renderEnd(ClassGenerator<?> g, CompleteType resolvedOutput, HoldingContainer[] inputVariables, JVar[] workspaceJVars) {
HoldingContainer out = g.declare(resolvedOutput, false);
JBlock sub = new JBlock();
g.getEvalBlock().add(sub);
JVar internalOutput = sub.decl(JMod.FINAL, resolvedOutput.getHolderType(g.getModel()), getReturnName(), JExpr._new(resolvedOutput.getHolderType(g.getModel())));
addProtectedBlock(g, sub, output(), null, workspaceJVars, false);
sub.assign(out.getHolder(), internalOutput);
//hash aggregate uses workspace vectors. Initialization is done in "setup" and does not require "reset" block.
if (!g.getMappingSet().isHashAggMapping()) {
generateBody(g, BlockType.RESET, reset(), null, workspaceJVars, false);
}
generateBody(g, BlockType.CLEANUP, cleanup(), null, workspaceJVars, false);
return out;
}
示例3: visitDecimal9Constant
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
@Override
public HoldingContainer visitDecimal9Constant(Decimal9Expression e, ClassGenerator<?> generator)
throws RuntimeException {
MajorType majorType = e.getMajorType();
JBlock setup = generator.getBlock(BlockType.SETUP);
JType holderType = generator.getHolderType(majorType);
JVar var = generator.declareClassField("dec9", holderType);
JExpression valueLiteral = JExpr.lit(e.getIntFromDecimal());
JExpression scaleLiteral = JExpr.lit(e.getScale());
JExpression precisionLiteral = JExpr.lit(e.getPrecision());
setup.assign(
var,
generator.getModel().ref(ValueHolderHelper.class).staticInvoke("getDecimal9Holder").arg(valueLiteral)
.arg(scaleLiteral).arg(precisionLiteral));
return new HoldingContainer(majorType, var, null, null);
}
示例4: visitDecimal18Constant
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
@Override
public HoldingContainer visitDecimal18Constant(Decimal18Expression e, ClassGenerator<?> generator)
throws RuntimeException {
MajorType majorType = e.getMajorType();
JBlock setup = generator.getBlock(BlockType.SETUP);
JType holderType = generator.getHolderType(majorType);
JVar var = generator.declareClassField("dec18", holderType);
JExpression valueLiteral = JExpr.lit(e.getLongFromDecimal());
JExpression scaleLiteral = JExpr.lit(e.getScale());
JExpression precisionLiteral = JExpr.lit(e.getPrecision());
setup.assign(
var,
generator.getModel().ref(ValueHolderHelper.class).staticInvoke("getDecimal18Holder").arg(valueLiteral)
.arg(scaleLiteral).arg(precisionLiteral));
return new HoldingContainer(majorType, var, null, null);
}
示例5: renderEnd
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
@Override
public HoldingContainer renderEnd(ClassGenerator<?> classGenerator, HoldingContainer[] inputVariables,
JVar[] workspaceJVars, FieldReference fieldReference) {
HoldingContainer out = classGenerator.declare(getReturnType(), false);
JBlock sub = new JBlock();
classGenerator.getEvalBlock().add(sub);
JVar internalOutput = sub.decl(JMod.FINAL, classGenerator.getHolderType(getReturnType()), getReturnValue().getName(), JExpr._new(classGenerator.getHolderType(getReturnType())));
addProtectedBlock(classGenerator, sub, output(), null, workspaceJVars, false);
sub.assign(out.getHolder(), internalOutput);
//hash aggregate uses workspace vectors. Initialization is done in "setup" and does not require "reset" block.
if (!classGenerator.getMappingSet().isHashAggMapping()) {
generateBody(classGenerator, BlockType.RESET, reset(), null, workspaceJVars, false);
}
generateBody(classGenerator, BlockType.CLEANUP, cleanup(), null, workspaceJVars, false);
return out;
}
示例6: process
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
@Override
public void process(Element element, EComponentHolder holder) throws Exception {
// I just copied this block from BeanHandler, I'm not sure I understand it
TypeMirror typeMirror = annotationHelper.extractAnnotationClassParameter(element);
if (typeMirror == null) {
typeMirror = element.asType();
typeMirror = holder.processingEnvironment().getTypeUtils().erasure(typeMirror);
}
JClass injectedClass = refClass(typeMirror.toString());
JFieldRef injectField = ref(element.getSimpleName().toString());
final JBlock initBody = holder.getInitBody();
initBody.assign(injectField, ModuleCodeGenerator.moduleGetInstanceOrAddDefaultIfNeeded(holder, annotationHelper, holder.getGeneratedClass(), holder.getInit(), injectedClass, "", typeHasAnnotation(typeMirror, EBean.class))); // field = Module.getInstance()
}
示例7: generateCreateCopyMethod
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
JMethod generateCreateCopyMethod(final boolean partial) {
final JDefinedClass definedClass = this.classOutline.implClass;
final JMethod cloneMethod = definedClass.method(JMod.PUBLIC, definedClass, this.pluginContext.copyMethodName);
final CopyGenerator cloneGenerator = this.pluginContext.createCopyGenerator(cloneMethod, partial);
cloneMethod.annotate(Override.class);
final JBlock body = cloneMethod.body();
final JVar newObjectVar;
final boolean superPartialCopyable = this.pluginContext.partialCopyableInterface.isAssignableFrom(definedClass._extends());
final boolean superCopyable = this.pluginContext.copyableInterface.isAssignableFrom(definedClass._extends());
if (superPartialCopyable) {
newObjectVar = body.decl(JMod.FINAL, definedClass, this.pluginContext.newObjectVarName, JExpr.cast(definedClass, cloneGenerator.generatePartialArgs(this.pluginContext.invoke(JExpr._super(), this.pluginContext.copyMethodName))));
} else if(superCopyable) {
newObjectVar = body.decl(JMod.FINAL, definedClass, this.pluginContext.newObjectVarName, JExpr.cast(definedClass, JExpr._super().invoke(this.pluginContext.copyMethodName)));
} else {
newObjectVar = body.decl(JMod.FINAL, definedClass, this.pluginContext.newObjectVarName, null);
final JBlock maybeTryBlock = this.pluginContext.catchCloneNotSupported(body, definedClass._extends());
maybeTryBlock.assign(newObjectVar, JExpr.cast(definedClass, JExpr._super().invoke(this.pluginContext.cloneMethodName)));
}
generateFieldCopyExpressions(cloneGenerator, body, newObjectVar, JExpr._this());
body._return(newObjectVar);
return cloneMethod;
}
示例8: loopClassConstructor
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
public JMethod loopClassConstructor(JDefinedClass klass,
String id, Type type,
JDefinedClass indexClass)
{
final JMethod cons = klass.constructor(JMod.NONE);
final JVar index = cons.param(convertTypeToJClass(type), id);
final JBlock body = cons.body();
comment_stamp(body);
klass.field(JMod.FINAL, indexClass, "index");
// work around bug in jcodemodel on using index instead of this.index
body.assign(JExpr.refthis("index"),
JExpr._new(indexClass).arg(index));
body.add(JExpr.invoke("register").arg(id)
.arg(JExpr.refthis("index")));
return cons;
}
示例9: generate
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
private void generate(JDefinedClass traversingVisitor, JTypeVar returnType, JTypeVar exceptionType, JClass implClass) {
// add method impl to traversing visitor
JMethod travViz;
travViz = traversingVisitor.method(JMod.PUBLIC, returnType, visitMethodNamer.apply(implClass.name()));
travViz._throws(exceptionType);
JVar beanVar = travViz.param(implClass, "aBean");
travViz.annotate(Override.class);
JBlock travVizBloc = travViz.body();
addTraverseBlock(travViz, beanVar, true);
JVar retVal = travVizBloc.decl(returnType, "returnVal");
travVizBloc.assign(retVal,
JExpr.invoke(beanVar, "accept").arg(JExpr.invoke("getVisitor")));
travVizBloc._if(JExpr.ref("progressMonitor").ne(JExpr._null()))._then().invoke(JExpr.ref("progressMonitor"), "visited").arg(beanVar);
// case to traverse after the visit
addTraverseBlock(travViz, beanVar, false);
travVizBloc._return(retVal);
}
示例10: generateLazyProxyInitGetter
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
private JMethod generateLazyProxyInitGetter(final ClassOutline classOutline, final FieldOutline fieldOutline) {
final JCodeModel m = classOutline.parent().getCodeModel();
final JDefinedClass definedClass = classOutline.implClass;
final String fieldName = fieldOutline.getPropertyInfo().getName(false);
final String getterName = "get" + fieldOutline.getPropertyInfo().getName(true);
final JFieldVar collectionField = definedClass.fields().get(fieldName);
final JClass elementType = ((JClass) collectionField.type()).getTypeParameters().get(0);
final JClass proxyFieldType = m.ref(BoundList.class).narrow(elementType);
final JFieldRef collectionFieldRef = JExpr._this().ref(collectionField);
final JFieldRef proxyField = JExpr._this().ref(collectionField.name() + BoundPropertiesPlugin.PROXY_SUFFIX);
final JMethod oldGetter = definedClass.getMethod(getterName, new JType[0]);
definedClass.methods().remove(oldGetter);
final JMethod newGetter = definedClass.method(JMod.PUBLIC, proxyFieldType, getterName);
newGetter.body()._if(collectionFieldRef.eq(JExpr._null()))._then().assign(collectionFieldRef, JExpr._new(m.ref(ArrayList.class).narrow(elementType)));
final JBlock ifProxyNull = newGetter.body()._if(proxyField.eq(JExpr._null()))._then();
ifProxyNull.assign(proxyField, JExpr._new(m.ref(BoundListProxy.class).narrow(elementType)).arg(collectionFieldRef));
newGetter.body()._return(proxyField);
return newGetter;
}
示例11: addValueField
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
private JFieldVar addValueField(JDefinedClass _enum, JType type) {
JFieldVar valueField = _enum.field(JMod.PRIVATE | JMod.FINAL, type, VALUE_FIELD_NAME);
JMethod constructor = _enum.constructor(JMod.PRIVATE);
JVar valueParam = constructor.param(type, VALUE_FIELD_NAME);
JBlock body = constructor.body();
body.assign(JExpr._this().ref(valueField), valueParam);
return valueField;
}
示例12: addBuilder
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
private JMethod addBuilder(JDefinedClass c, JFieldVar field) {
JMethod builder = c.method(JMod.PUBLIC, c, getBuilderName(field.name()));
JVar param = builder.param(field.type(), field.name());
JBlock body = builder.body();
body.assign(JExpr._this().ref(field), param);
body._return(JExpr._this());
return builder;
}
示例13: visitQuotedStringConstant
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
@Override
public HoldingContainer visitQuotedStringConstant(QuotedString e, ClassGenerator<?> generator)
throws RuntimeException {
MajorType majorType = Types.required(MinorType.VARCHAR);
JBlock setup = generator.getBlock(BlockType.SETUP);
JType holderType = generator.getHolderType(majorType);
JVar var = generator.declareClassField("string", holderType);
JExpression stringLiteral = JExpr.lit(e.value);
JExpression buffer = generator.getMappingSet().getIncoming().invoke("getContext").invoke("getManagedBuffer");
setup.assign(var,
generator.getModel().ref(ValueHolderHelper.class).staticInvoke("getVarCharHolder").arg(buffer).arg(stringLiteral));
return new HoldingContainer(majorType, var, null, null);
}
示例14: visitIntervalDayConstant
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
@Override
public HoldingContainer visitIntervalDayConstant(IntervalDayExpression e, ClassGenerator<?> generator)
throws RuntimeException {
MajorType majorType = Types.required(MinorType.INTERVALDAY);
JBlock setup = generator.getBlock(BlockType.SETUP);
JType holderType = generator.getHolderType(majorType);
JVar var = generator.declareClassField("intervalday", holderType);
JExpression dayLiteral = JExpr.lit(e.getIntervalDay());
JExpression millisLiteral = JExpr.lit(e.getIntervalMillis());
setup.assign(
var,
generator.getModel().ref(ValueHolderHelper.class).staticInvoke("getIntervalDayHolder").arg(dayLiteral)
.arg(millisLiteral));
return new HoldingContainer(majorType, var, null, null);
}
示例15: addProtectedBlock
import com.sun.codemodel.JBlock; //导入方法依赖的package包/类
protected void addProtectedBlock(ClassGenerator<?> g, JBlock sub, String body, HoldingContainer[] inputVariables,
JVar[] workspaceJVars, boolean decConstInputOnly) {
if (inputVariables != null) {
for (int i = 0; i < inputVariables.length; i++) {
if (decConstInputOnly && !inputVariables[i].isConstant()) {
continue;
}
ValueReference parameter = parameters[i];
HoldingContainer inputVariable = inputVariables[i];
if (parameter.isFieldReader && !inputVariable.isReader() && inputVariable.getCompleteType().isScalar()) {
JType singularReaderClass = g.getModel()._ref(TypeHelper.getHolderReaderImpl(getArrowMinorType(inputVariable.getCompleteType().toMinorType())));
JType fieldReadClass = g.getModel()._ref(FieldReader.class);
sub.decl(fieldReadClass, parameter.name, JExpr._new(singularReaderClass).arg(inputVariable.getHolder()));
} else {
sub.decl(inputVariable.getHolder().type(), parameter.name, inputVariable.getHolder());
}
}
}
JVar[] internalVars = new JVar[workspaceJVars.length];
for (int i = 0; i < workspaceJVars.length; i++) {
if (decConstInputOnly) {
internalVars[i] = sub.decl(g.getModel()._ref(workspaceVars[i].type), workspaceVars[i].name, workspaceJVars[i]);
} else {
internalVars[i] = sub.decl(g.getModel()._ref(workspaceVars[i].type), workspaceVars[i].name, workspaceJVars[i]);
}
}
Preconditions.checkNotNull(body);
sub.directStatement(body);
// reassign workspace variables back to global space.
for (int i = 0; i < workspaceJVars.length; i++) {
sub.assign(workspaceJVars[i], internalVars[i]);
}
}