當前位置: 首頁>>代碼示例>>Java>>正文


Java JExpr.lit方法代碼示例

本文整理匯總了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);
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:17,代碼來源:EvaluationVisitor.java

示例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);
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:17,代碼來源:EvaluationVisitor.java

示例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"));
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:17,代碼來源:EvaluationVisitor.java

示例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);
}
 
開發者ID:hibernate,項目名稱:beanvalidation-benchmark,代碼行數:19,代碼來源:Util.java

示例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);
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:14,代碼來源:EvaluationVisitor.java

示例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);
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:16,代碼來源:EvaluationVisitor.java

示例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);
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:13,代碼來源:EvaluationVisitor.java

示例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);
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:13,代碼來源:EvaluationVisitor.java

示例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"));
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:14,代碼來源:EvaluationVisitor.java

示例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"));
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:16,代碼來源:EvaluationVisitor.java

示例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();

        }

    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:57,代碼來源:DefaultRule.java


注:本文中的com.sun.codemodel.JExpr.lit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。