【问题标题】:How do I generate FTL code reading text?如何生成 FTL 代码阅读文本?
【发布时间】:2015-04-03 06:04:12
【问题描述】:

这是我的 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 代码。这是怎么做到的?

#

【问题讨论】:

    标签: java freemarker filereader


    【解决方案1】:

    没有你要问的这样的事情。这是一个单向过程。我什至不知道“数学上”怎么可能。

    【讨论】:

    • 无需按原样生成确切的代码。即使我知道这样做是不可能的。 Bt有什么办法,我们可以生成一些模板代码来读取文本输入。然后我们就可以按照我们想要的方式对其进行修改。
    • 我不知道这样的实用程序。
    猜你喜欢
    • 2016-04-20
    • 2023-02-18
    • 2021-09-13
    • 1970-01-01
    • 2011-09-12
    • 2017-09-28
    • 2019-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多