コード例 #1
0
 private FieldDeclaration createDeleteFlagValueField(
     EmitContext context, ModelDeclaration model, AstLiteral deleteFlagValue) {
   assert context != null;
   assert model != null;
   assert deleteFlagValue != null;
   ModelFactory f = context.getModelFactory();
   Type type;
   Expression value;
   switch (deleteFlagValue.kind) {
     case BOOLEAN:
       type = context.resolve(boolean.class);
       value = Models.toLiteral(f, deleteFlagValue.toBooleanValue());
       break;
     case INTEGER:
       type = context.resolve(int.class);
       value = Models.toLiteral(f, deleteFlagValue.toIntegerValue().intValue());
       break;
     case STRING:
       type = context.resolve(Text.class);
       value =
           new TypeBuilder(f, context.resolve(Text.class))
               .newObject(Models.toLiteral(f, deleteFlagValue.toStringValue()))
               .toExpression();
       break;
     default:
       throw new AssertionError(deleteFlagValue);
   }
   return f.newFieldDeclaration(
       null,
       new AttributeBuilder(f).Private().Static().Final().toAttributes(),
       type,
       f.newSimpleName(FIELD_DELETE_FLAG_VALUE),
       value);
 }
コード例 #2
0
  private Configuration analyzeConfig(
      DmdlSemantics environment,
      AstAttribute attribute,
      Map<String, AstAttributeElement> elements) {
    AstLiteral charset = take(environment, elements, ELEMENT_CHARSET_NAME, LiteralKind.STRING);
    AstLiteral header = take(environment, elements, ELEMENT_HAS_HEADER_NAME, LiteralKind.BOOLEAN);
    AstLiteral codec = take(environment, elements, ELEMENT_CODEC_NAME, LiteralKind.STRING);
    environment.reportAll(AttributeUtil.reportInvalidElements(attribute, elements.values()));

    Configuration result = new Configuration();
    if (charset != null && checkNotEmpty(environment, ELEMENT_CHARSET_NAME, charset)) {
      result.setCharsetName(charset.toStringValue());
    }
    if (header != null) {
      result.setEnableHeader(header.toBooleanValue());
    }
    if (codec != null && checkNotEmpty(environment, ELEMENT_CODEC_NAME, codec)) {
      result.setCodecName(codec.toStringValue());
    }
    return result;
  }