Bidjic file to set
Description
Generates multiple output files from one input model, using a templateset.
+---+
| |
+---+ | |
| | +---> +---+
| | +---> +---+
+---+ | |
| |
+---+
Bidjic task parameters
Attribute | Description | Value | Required |
---|---|---|---|
file | inpput file | .<bidji*> | yes |
todir | output dir | 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>
Note
Output file names are processed from template names:
- 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}(BJDOLLAR${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 BJDOLLAR${property.@name};
public function get${property.@name?cap_first}() {
return $this->${property.@name};
}
public function set${property.@name?cap_first}(BJDOLLAR${property.@name}) {
$this->${property.@name} = BJDOLLAR${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;
}
}