Bidjic file to file
Description
Generates one output file from one input model.
+---+ +---+
| | +---> | |
| | | |
+---+ +---+
Bidjic task parameters
Attribute | Description | Value | Required |
---|---|---|---|
file | inpput file | .<bidji*> | yes |
tofile | output file | . | yes |
overwrite | overwrite output file | true by default | no |
Example
Generates Java POJO classes from a Model driven architecture abstraction: the bidjim entity.
download file2file.tgz sample.
ant file : build.xml
<target name="pojo" description="generate pojo classes">
<bidjic file="MyPackage/MyModule/Foo.bidjim" tofile="gen/Foo.java" template="templates/bidjim2pojo.ftl" overwrite="true" />
</target>
template: bidjim2pojo.ftl
[#assign entity = bidji.entity]
package com.mycompany.${package}.${module};
/**
* ${Model}, generated with bidjim2pojo.ftl
**/
public class ${Model} {
[#foreach property in entity.property]
private ${property.@type} _${property.@name};
[/#foreach]
/**
* Constructor for a ${Model} Object.
**/
public ${Model}(){
}
[#foreach property in entity.property]
public ${property.@type?replace('Integer','int')} get${property.@name?cap_first}() {
return this._${property.@name};
}
public void set${property.@name?cap_first}(${property.@type?replace('Integer','int')} ${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="Integer" />
<property name="name" type="String" />
</entity>
</bidji>
result: Foo.java
package com.mycompany.mypackage.mymodule;
/**
* Foo, generated with bidjim2pojo.ftl
**/
public class Foo {
private int _id;
private String _name;
/**
* Constructor for a Foo Object.
**/
public Foo(){
}
public int getId() {
return this._id;
}
public void setId(int id) {
this._id = id;
}
public String getName() {
return this._name;
}
public void setName(String name) {
this._name = name;
}
}