I wrote a Pojo container “wrapper” that I would like to release/post here for others to use. What is the best way to do this?
The container is very easy to use, it parses a pojo and uses the public getters [get(), is(), has()]
as the ID’s. For for example if you passed it “java.io.File” in the TableDemo, the column names would be all of the public getters for File [isDirectory, UseableSpace, Name, Parent …]
.
PojoContainer pc = new PojoContainer("java.io.File");
pc.populatePojoItem( new File("/") );
table.setContainerDataSource(pc);
or anywhere else that you would use a datasource.
I used reflection to get the method names, by default I sort the names, however there is a constructor to disable this. Code is easy to change. I did incorporate the setter()-side too, so if you wanted to update a field. The latter was not tested, just wrote the reflection code to call the pojo setter method as an example/template for others.
The original intentions was: a) to allow me to use any pojo with the toolkit, and avoid having to “hardcode” each container for a particular pojo. b) use it as a start to replace the “tree” functionality with dynamic row where I could use any Java object and it’s representation as the “row” content.
Code is in four small sections:
container.pojo
PojoClassMap.java
PojoClassProperty.java
PojoContainer.java
PojoContainerMap.java
All of the above could be incorporated into a single class, I kept them separate because I re-use them in other classes. It also makes it easier to read the code without it being cluttered.
So, where or how to post this? Paste it here? Zip it and place it somewhere? Thought I would ask before attempting to just post it.
Andy