You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Barry Andrews <ti...@earthlink.net> on 2004/07/01 16:55:36 UTC
BeanGen
Hi Dev,
I have a task that I wrote that will take a file containing types and identifiers and creates a compilable Java source file with all the getter/setter methods. Saves me a lot of typing. So the task looks like this: (minus a couple other options)
<target name="test">
<taskdef name="BeanGen" classname="swerdna.ant.BeanGen" classpath="${jar}"/>
<BeanGen input_file="test.txt" package="swerdna.test" srcdir="src" class="Test">
</BeanGen>
</target>
The test.txt file looks like this:
int id
String name
and from that I generate the following code.
package swerdna.test;
import java.io.Serializable;
public class Test implements Serializable
{
private String m_strname;
private int m_nid;
public Test()
{
}
public void setName(String name)
{
m_strname = name;
}
public String getName()
{
return m_strname;
}
public void setId(int id)
{
m_nid = id;
}
public int getId()
{
return m_nid;
}
public boolean equals(Object obj)
{
//TODO Implement
return false;
}
public int hashCode()
{
//TODO Implement
return 0;
}
public String toString()
{
//TODO Implement
return null;
}
}
If anyone thinks this task has any value and wants to take the time and effort to do all the required steps to get it in the package I will gladly submit the source code. Or maybe someone else had already thought of this task? If so that's fine. Just thought I would make it known.
thanks,
Barry
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org