本文整理汇总了Java中com.sun.codemodel.JExpr.lit方法的典型用法代码示例。如果您正苦于以下问题:Java JExpr.lit方法的具体用法?Java JExpr.lit怎么用?Java JExpr.lit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.codemodel.JExpr
的用法示例。
在下文中一共展示了JExpr.lit方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitDecimal9Constant
import com.sun.codemodel.JExpr; //导入方法依赖的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);
}
示例2: visitDecimal18Constant
import com.sun.codemodel.JExpr; //导入方法依赖的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);
}
示例3: visitDecimalConstant
import com.sun.codemodel.JExpr; //导入方法依赖的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"));
}
示例4: literalExpr
import com.sun.codemodel.JExpr; //导入方法依赖的package包/类
/**
* Calls the correct {@link JExpr} <code>lit</code> method.
*
* @param value
* The literal value that must be output in an expresion.
* @return The matching expression for the real type of value.
*/
public static JExpression literalExpr(Object value) {
if (value == null) {
return JExpr._null();
} else if (value instanceof String) {
return JExpr.lit((String) value);
} else if (value instanceof Integer) {
return JExpr.lit((Integer) value);
}
throw new RuntimeException("Impossible to construct initial value for: " + value);
}
示例5: visitQuotedStringConstant
import com.sun.codemodel.JExpr; //导入方法依赖的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);
}
示例6: visitIntervalDayConstant
import com.sun.codemodel.JExpr; //导入方法依赖的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);
}
示例7: visitDecimal28Constant
import com.sun.codemodel.JExpr; //导入方法依赖的package包/类
@Override
public HoldingContainer visitDecimal28Constant(Decimal28Expression e, ClassGenerator<?> generator)
throws RuntimeException {
MajorType majorType = e.getMajorType();
JBlock setup = generator.getBlock(BlockType.SETUP);
JType holderType = generator.getHolderType(majorType);
JVar var = generator.declareClassField("dec28", holderType);
JExpression stringLiteral = JExpr.lit(e.getBigDecimal().toString());
setup.assign(var,
generator.getModel().ref(ValueHolderHelper.class).staticInvoke("getDecimal28Holder").arg(stringLiteral));
return new HoldingContainer(majorType, var, null, null);
}
示例8: visitDecimal38Constant
import com.sun.codemodel.JExpr; //导入方法依赖的package包/类
@Override
public HoldingContainer visitDecimal38Constant(Decimal38Expression e, ClassGenerator<?> generator)
throws RuntimeException {
MajorType majorType = e.getMajorType();
JBlock setup = generator.getBlock(BlockType.SETUP);
JType holderType = generator.getHolderType(majorType);
JVar var = generator.declareClassField("dec38", holderType);
JExpression stringLiteral = JExpr.lit(e.getBigDecimal().toString());
setup.assign(var,
generator.getModel().ref(ValueHolderHelper.class).staticInvoke("getVarCharHolder").arg(stringLiteral));
return new HoldingContainer(majorType, var, null, null);
}
示例9: visitQuotedStringConstant
import com.sun.codemodel.JExpr; //导入方法依赖的package包/类
@Override
public HoldingContainer visitQuotedStringConstant(QuotedString e, ClassGenerator<?> generator)
throws RuntimeException {
CompleteType completeType = CompleteType.VARCHAR;
JBlock setup = generator.getBlock(BlockType.SETUP);
JType holderType = completeType.getHolderType(generator.getModel());
JVar var = generator.declareClassField("string", holderType);
JExpression stringLiteral = JExpr.lit(e.value);
JExpression buffer = JExpr.direct("context").invoke("getManagedBuffer");
setup.assign(var,
generator.getModel().ref(ValueHolderHelper.class).staticInvoke("getNullableVarCharHolder").arg(buffer).arg(stringLiteral));
return new HoldingContainer((completeType), var, var.ref("value"), var.ref("isSet"));
}
示例10: visitIntervalDayConstant
import com.sun.codemodel.JExpr; //导入方法依赖的package包/类
@Override
public HoldingContainer visitIntervalDayConstant(IntervalDayExpression e, ClassGenerator<?> generator)
throws RuntimeException {
CompleteType completeType = CompleteType.INTERVAL_DAY_SECONDS;
JBlock setup = generator.getBlock(BlockType.SETUP);
JType holderType = completeType.getHolderType(generator.getModel());
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("getNullableIntervalDayHolder").arg(dayLiteral)
.arg(millisLiteral));
return new HoldingContainer(completeType, var, var.ref("value"), var.ref("isSet"));
}
示例11: getDefaultValue
import com.sun.codemodel.JExpr; //导入方法依赖的package包/类
static JExpression getDefaultValue(JType fieldType, JsonNode node) {
fieldType = fieldType.unboxify();
if (fieldType.fullName().equals(String.class.getName())) {
return JExpr.lit(node.asText());
} else if (fieldType.fullName().equals(int.class.getName())) {
return JExpr.lit(Integer.parseInt(node.asText()));
} else if (fieldType.fullName().equals(BigInteger.class.getName())) {
return JExpr._new(fieldType).arg(JExpr.lit(node.asText()));
} else if (fieldType.fullName().equals(double.class.getName())) {
return JExpr.lit(Double.parseDouble(node.asText()));
} else if (fieldType.fullName().equals(BigDecimal.class.getName())) {
return JExpr._new(fieldType).arg(JExpr.lit(node.asText()));
} else if (fieldType.fullName().equals(boolean.class.getName())) {
return JExpr.lit(Boolean.parseBoolean(node.asText()));
} else if (fieldType.fullName().equals(DateTime.class.getName()) || fieldType.fullName().equals(Date.class.getName())) {
long millisecs = parseDateToMillisecs(node.asText());
JInvocation newDateTime = JExpr._new(fieldType);
newDateTime.arg(JExpr.lit(millisecs));
return newDateTime;
} else if (fieldType.fullName().equals(LocalDate.class.getName()) || fieldType.fullName().equals(LocalTime.class.getName())) {
JInvocation stringParseableTypeInstance = JExpr._new(fieldType);
stringParseableTypeInstance.arg(JExpr.lit(node.asText()));
return stringParseableTypeInstance;
} else if (fieldType.fullName().equals(long.class.getName())) {
return JExpr.lit(Long.parseLong(node.asText()));
} else if (fieldType.fullName().equals(float.class.getName())) {
return JExpr.lit(Float.parseFloat(node.asText()));
} else if (fieldType.fullName().equals(URI.class.getName())) {
JInvocation invokeCreate = fieldType.owner().ref(URI.class).staticInvoke("create");
return invokeCreate.arg(JExpr.lit(node.asText()));
} else if (fieldType instanceof JDefinedClass && ((JDefinedClass) fieldType).getClassType().equals(ClassType.ENUM)) {
return getDefaultEnum(fieldType, node);
} else {
return JExpr._null();
}
}