Hi Litty,
Actually I am not doing this for some particular domain, but its a kind of generalized pattern which can be used in any specific domains.
For instance, consider that I want to store some table structure with values in the database.
Here consider Cell as Component, Row & Table as Containers.
Try to understand following pattern. I verified this in "in memory" form. But I want to store this table in the database. But I am just blocked at one point, just breaking down the problem, and will post as soon as I identify the same.
Finally, I just want to map this hierarchy in the xml. How do I do that... As its verified "in memory", I believe that it shouldn't be impossible, if it is, then its a bug of Hibernate.
Code:
abstract class Component{
protected long componentID;
protected List containers = new ArrayList();
//Getter and Setters
}
abstract class Container extends Component{
protected List components = new ArrayList();
//Getter and Setters
}
class Cell extends Component{
String value;
//Getter and setters.
}
class Row extends Container{
}
class Table extends Container{
}
class Driver{
public static void main(String[] args){
Cell cell = new Cell();
cell.setValue("3");
Row row = new Row();
row.addComponent(cell);
Table table = new Table();
table.addComponent(row);
table.addComponent(row);
Table t2 = new Table();
t2.addComponent(row);
t2.addComponent(row);
}
}