Bidjic file to set
Description
+---+ | | +---+ | | | | +---> +---+ | | +---> +---+ +---+ | | | | +---+
Bidjic task parameters
|Attribute | Description | Value | Required | |-----------|-----------------------|---------------------|---------------| |file | inpput file | <filename>.<bidji*> | yes | |todir | output dir | <dirname> | yes | |overwrite | overwrite output file | true by default | no | |-----------|-----------------------|---------------------|---------------| |Element | Description | Value | Required | |-----------|-----------------------|---------------------|---------------| |templateset| template set | | yes |
Example
Generates Php classes from from a Model driven architecture abstraction: the bidjim entity.
download file2set.tgz sample.
ant file : build.xml
<target name="php" description="generate php files"> <bidjic file="MyPackage/MyModule/Foo.bidjim" todir="gen" overwrite="true"> <templateset dir="templates"> <include name="*.ftl"/> </templateset> </bidjic> </target>
-
Model .php.ftl + MyPackage/MyModule/Foo.bidjim => Foo .php
-
Module .php.ftl + MyPackage/MyModule/Foo.bidjim => MyModule .php
template: iModel.php.ftl
[#assign entity = bidji.entity] <?php namespace ${Package}\${Module}; interface i${Model} { [#foreach property in entity.property] public function get${property.@name?cap_first}(); public function set${property.@name?cap_first}($${property.@name}); [/#foreach] }
template: Model.php.ftl
[#assign entity = bidji.entity] <?php namespace ${Package}\${Module}; class ${Model} implements i${Model} { [#foreach property in entity.property] private $${property.@name}; public function get${property.@name?cap_first}() { return $this->${property.@name}; } public function set${property.@name?cap_first}($${property.@name}) { $this->${property.@name} = $${property.@name}; } [/#foreach] }
model: MyPackage/MyModule/Foo.bidjim
<?xml version="1.0"?> <bidji> <entity name="Foo"> <property name="id" type="int" /> <property name="name" type="string" /> </entity> </bidji>
result: iFoo.php
<?php namespace MyPackage\MyModule; interface iFoo { public function getId(); public function setId($id); public function getName(); public function setName($name); }
result: Foo.php
<?php namespace MyPackage\MyModule; class Foo implements iFoo { private $id; public function getId() { return $this->id; } public function setId($id) { $this->id = $id; } private $name; public function getName() { return $this->name; } public function setName($name) { $this->name = $name; } }