These are my sample classes on what I what to perform queries.
class TObject
{
String id;
public String getId()
{
return id;
}
public void setId(String id)
{
this.id=id;
}
}
class TStructure
{
TObject tObject;
public TObject getTObject()
{
return tObject;
}
public void setTObject(TObject tObject)
{
this.tObject=tObject;
}
}
class TStructureRow
{
TStructure tStructure;
TObject tObject;
public TStructure getTStructure()
{
return tStructure;
}
public void setTStructure(TStructure tStructure)
{
this.tStructure=tStructure;
}
public TObject getTObject()
{
return tObject;
}
public void setTObject(TObject tObject)
{
this.tObject=tObject;
}
}
I have created this classes for my sample xml data to query them. I have created Lists(data) for these classes to maitain the data in them. How can i query these lists to retrieve the results in less overhead.
For ex, these are queries:
1) o<-tobject{tstructure}<-tstructure{tstructure_row})
Meaning: for every object o, as tobject in tstructure, return tstructure_row of tstructure…this is the syntactic meaning
2) o<-tobject{tstructure}<-tstructure{tstructure_row}::tobject{tobject | id = "XYZ"}<-tobject{tstructure}<-tstructure{structure_row}
Meaning: for every object o, as tobject in tstructure, as tstructure in tstructurerow,tobject in tstructurerow whose id is “XYZ”,for such tobject, as tobject in tstructure, as tstructure in tstructure row, return tstructurerow….this is the syntactic meaning
I have written bunch of nested for statements but I believe they are killing my processor if the data huge. I have to quickly find the dat from these lists on even complex queries like searching for tObjects of more than one relevant type in the child tobjects of their respective structures.
If you only wish to query based on
TObjectid, use HashMapHashMap<String,List<TStructureRow>.Store List against the id of TObject.You can retrieve list of allTStructureRowcorresponding to a particularTObjectid in (theoretically)constant average time.