rubbish-db 1.6.2-beta

http://sourceforge.net/projects/rubbish-db
Antから自動生成クラスを拡張できる機能を追加しました。

たとえば、ActiveRecordの生成タスクを以下のように定義すると…


<target name="create.vo">
<vogen type="ar" destdir="${sample.src}" package="sample.activerecord.bean">
<!-- Template Extension -->
<extension>
<![CDATA[
public void additionFunc() {
/* class name */
// ${classname}
// ${classname.lowercase}
// ${classname.uppercase}
// ${classname.capitalize}

/* ant property */
// basedir: ${basedir}
// sample.src: ${sample.src}

Database dbh = DatabaseManager.getDatabase();
// processing...
}
]]>
</extension>

<!-- Template Extension by property -->
<propextension>
<![CDATA[
public void additionFunc${propname.capitalize}() {
/* class name */
// classname: ${classname}
// classname.lowercase: ${classname.lowercase}
// classname.upsercase: ${classname.uppercase}
// classname.capitalize: ${classname.capitalize}

/* property name */
// propname: ${propname}
// propname.lowercase: ${propname.lowercase}
// propname.uppercase: ${propname.uppercase}
// propname.capitalize: ${propname.capitalize}

/* ant property */
// basedir: ${basedir}
// sample.src: ${sample.src}

// processing...
}
]]>
</propextension>
</vogen>
</target>

自動生成されたActiveRecordに以下のメソッドが追加されます。



public void additionFunc() {
/* class name */
// Book
// book
// BOOK
// Book

/* ant property */
// basedir: C:\eclipse\workspace\rubbish-db\sample\hsqldb
// sample.src: C:\eclipse\workspace\rubbish-db\sample\hsqldb/../src

Database dbh = DatabaseManager.getDatabase();
// processing...
}


public void additionFuncPublisher() {
/* class name */
// classname: Book
// classname.lowercase: book
// classname.upsercase: BOOK
// classname.capitalize: Book

/* property name */
// propname: publisher
// propname.lowercase: publisher
// propname.uppercase: PUBLISHER
// propname.capitalize: Publisher

/* ant property */
// basedir: C:\eclipse\workspace\rubbish-db\sample\hsqldb
// sample.src: C:\eclipse\workspace\rubbish-db\sample\hsqldb/../src

// processing...
}


public void additionFuncId() {
/* class name */
// classname: Book
// classname.lowercase: book
// classname.upsercase: BOOK
// classname.capitalize: Book

/* property name */
// propname: id
// propname.lowercase: id
// propname.uppercase: ID
// propname.capitalize: Id

/* ant property */
// basedir: C:\eclipse\workspace\rubbish-db\sample\hsqldb
// sample.src: C:\eclipse\workspace\rubbish-db\sample\hsqldb/../src

// processing...
}


public void additionFuncTitle() {
/* class name */
// classname: Book
// classname.lowercase: book
// classname.upsercase: BOOK
// classname.capitalize: Book

/* property name */
// propname: title
// propname.lowercase: title
// propname.uppercase: TITLE
// propname.capitalize: Title

/* ant property */
// basedir: C:\eclipse\workspace\rubbish-db\sample\hsqldb
// sample.src: C:\eclipse\workspace\rubbish-db\sample\hsqldb/../src

// processing...
}


public void additionFuncAuthor() {
/* class name */
// classname: Book
// classname.lowercase: book
// classname.upsercase: BOOK
// classname.capitalize: Book

/* property name */
// propname: author
// propname.lowercase: author
// propname.uppercase: AUTHOR
// propname.capitalize: Author

/* ant property */
// basedir: C:\eclipse\workspace\rubbish-db\sample\hsqldb
// sample.src: C:\eclipse\workspace\rubbish-db\sample\hsqldb/../src

// processing...
}


public void additionFuncIssue_date() {
/* class name */
// classname: Book
// classname.lowercase: book
// classname.upsercase: BOOK
// classname.capitalize: Book

/* property name */
// propname: issue_date
// propname.lowercase: issue_date
// propname.uppercase: ISSUE_DATE
// propname.capitalize: Issue_date

/* ant property */
// basedir: C:\eclipse\workspace\rubbish-db\sample\hsqldb
// sample.src: C:\eclipse\workspace\rubbish-db\sample\hsqldb/../src

// processing...
}


public void additionFuncUpdate_date() {
/* class name */
// classname: Book
// classname.lowercase: book
// classname.upsercase: BOOK
// classname.capitalize: Book

/* property name */
// propname: update_date
// propname.lowercase: update_date
// propname.uppercase: UPDATE_DATE
// propname.capitalize: Update_date

/* ant property */
// basedir: C:\eclipse\workspace\rubbish-db\sample\hsqldb
// sample.src: C:\eclipse\workspace\rubbish-db\sample\hsqldb/../src

// processing...
}


public void additionFuncCreate_date() {
/* class name */
// classname: Book
// classname.lowercase: book
// classname.upsercase: BOOK
// classname.capitalize: Book

/* property name */
// propname: create_date
// propname.lowercase: create_date
// propname.uppercase: CREATE_DATE
// propname.capitalize: Create_date

/* ant property */
// basedir: C:\eclipse\workspace\rubbish-db\sample\hsqldb
// sample.src: C:\eclipse\workspace\rubbish-db\sample\hsqldb/../src

// processing...
}

追記
${proptype}で、型も取得できます。