如何生成FTL代码读取文本?

时间:2015-04-03 06:04:12

标签: java freemarker filereader

这是我想要生成读取一些文本输入的FTL代码

<#include "BuiltInFunctions">
     @Rule (name = "${SOPName}_ErrorCheckParameters")
    <#assign _oppPreCondition>
      <@getOppositePrecondition/><#t>
      </#assign>
      if (${_oppPreCondition})
      {
        (Log (Insufficient parameters or values.))
        (Eject)
      }

      <#assign _USEPRECONDITION = "true">
    <#assign _preCondition>
       <@getPrecondition/><#t>
      </#assign>
    <#-- For loop for Parents -->
    <#if this.parents??>
    <#list this.parents as parent>
      <#if parent_index != 0>
      <#-- Insert a blank line -->
      </#if>
      <#if (getEntityOperatorCall(parent,"Check"))??>
    <#assign _operatorCall = getEntityOperatorCall(parent,"Check")>
    <#if _operatorCall??>
    <#if getReturnAndOutputSuccess("parentCheck_return","parentCheck_output")??>
    <#assign _successpredicate=getReturnAndOutputSuccess("parentCheck_return","parentCheck_output")>
    </#if>
     @Rule (name = "${SOPName}_Check${parent.name}")
      if (<#if _USEPRECONDITION = "true">${_preCondition} <#assign _USEPRECONDITION = "false"><#else>${_successpredicate}</#if>)
      {
        (parentCheck_return, parentCheck_output) = ${_operatorCall}
        (Log (${_operatorCall} output = ${"$"}{parentCheck_output}))
        (Log ((${_operatorCall} return = ${"$"}{parentCheck_return}))
      }
    <#if getReturnAndOutputFailure("parentCheck_return","parentCheck_output")??>
    <#assign _failurepredicate=getReturnAndOutputFailure("parentCheck_return","parentCheck_output")>
    </#if>
    @Rule (name = "${SOPName}_ErrorCheck${parent.name}")
        if(${_failurepredicate})
        {
            (Eject)
        }
      <#--<@getRules sopname=_rulename returnval="parentCheck_return" outputval="parentCheck_output"/><#t>-->

      </#if>
      </#if>
    </#list>
    </#if>

    <#if (getEntityOperatorCall(this,"Check"))??>
    <#assign _selfCheck = getEntityOperatorCall(this,"Check")>
    <#if _selfCheck??>
     @Rule (name = "${SOPName}_${this.operators["Check"].name}")
       if (<#if _USEPRECONDITION = "true">${_preCondition} <#assign _USEPRECONDITION = "false"><#else>${_successpredicate}</#if>)
      {
        (selfCheck_return, selfCheck_output) = ${_selfCheck}
        (Log (${_selfCheck} output = ${"$"}{selfCheck_output}))
        (Log (${_selfCheck} return = ${"$"}{selfCheck_return}))
      }
     <#if getReturnAndOutputSuccess("selfCheck_return","selfCheck_output")??>
    <#assign _successpredicate=getReturnAndOutputSuccess("selfCheck_return","selfCheck_output")>
    </#if>
    <#if getReturnAndOutputFailure("selfCheck_return","selfCheck_output")??>
    <#assign _failurepredicate=getReturnAndOutputFailure("selfCheck_return","selfCheck_output")>
    </#if>
    @Rule (name = "${SOPName}_ErrorCheck${this.name}")
        if(${_failurepredicate})
        {
            (Eject)
        }
    <#--  <@getRules sopname=_rulename returnval="selfCheck_return" outputval="selfCheck_output"/><#t> -->

    </#if>
    </#if>
    <#if (getEntityOperatorCall(this,Verb))??>
    <#assign _mainTask = getEntityOperatorCall(this,Verb)>
    <#if _mainTask??>
    <#if _selfCheck??>
      @Rule (name = "${SOPName}_${this.operators[Verb].name}")
      if (${_failurepredicate})
      {
        (mainTask_return, mainTask_output) = ${_mainTask}
        (Log (${_mainTask} output = ${"$"}{mainTask_output}))
        (Log (${_mainTask} return = ${"$"}{mainTask_return}))
      }

    <#else>
    @Rule (name = "${SOPName}_${this.operators[Verb].name}")
     if (<#if _USEPRECONDITION = "true">${_preCondition} <#assign _USEPRECONDITION = "false"><#else>${_successpredicate}</#if>)
      {
        (mainTask_return, mainTask_output) = ${_mainTask}
        (Log (${_mainTask} output = ${"$"}{mainTask_output}))
        (Log (${_mainTask} return = ${"$"}{mainTask_return}))
      }

    </#if>
    <#if getReturnAndOutputSuccess("mainTask_return","mainTask_output")??>
    <#assign _successpredicate=getReturnAndOutputSuccess("mainTask_return","mainTask_output")>
    </#if>
    <#if getReturnAndOutputFailure("mainTask_return","mainTask_output")??>
    <#assign _failurepredicate=getReturnAndOutputFailure("mainTask_return","mainTask_output")>
    </#if>
    @Rule (name = "${SOPName}_Error${this.operators[Verb].name}")
        if(${_failurepredicate})
        {
            (Eject)
        }
    <#--  <@getRules sopname=_rulename returnval="mainTask_return" outputval="mainTask_output"/><#t>-->

       @Rule (name = "${SOPName}_Success${this.operators[Verb].name}")
      if (${_successpredicate})
      {
        (Log (${Verb} ${this.name} resulted in success ))
        (Resolve)
      }

    </#if>
    </#if>

##########################################################
 @Rule (name = "SetEntityB_ErrorCheckParameters")
  if ()
  {
    (Log (Insufficient parameters or values.))
    (Eject)
  }

 @Rule (name = "SetEntityB_CheckB")
  if ( )
  {
    (parentCheck_return, parentCheck_output) = A:CheckEntityB()
    (Log (A:CheckEntityB() output = ${parentCheck_output}))
    (Log ((A:CheckEntityB() return = ${parentCheck_return}))
  }
@Rule (name = "SetEntityB_ErrorCheckB")
    if(parentCheck_return != 0)
    {
        (Eject)
    }


@Rule (name = "SetEntityB_SetattrB")
 if (parentCheck_return = 0)
  {
    (mainTask_return, mainTask_output) = A:SetattrB()
    (Log (A:SetattrB() output = ${mainTask_output}))
    (Log (A:SetattrB() return = ${mainTask_return}))
  }

@Rule (name = "SetEntityB_ErrorSetattrB")
    if(mainTask_return != 0)
    {
        (Eject)
    }

   @Rule (name = "SetEntityB_SuccessSetattrB")
  if (mainTask_return = 0)
  {
    (Log (Set attrB resulted in success ))
    (Resolve)
  }

ftl代码生成上面显示的文本作为输出。但如果我想以相反的方式做到这一点。读取文本时,应生成FTL代码。怎么做的?

1 个答案:

答案 0 :(得分:0)

没有你要问的事情。这是一种单向过程。我甚至不知道这将如何“以数学方式”实现。