* @param propertyName the field name of the field which is used to reduce the hits (e.g. foreign key) can be null to access all items
* @param propertyValue the value of the specified field (or null)
* @return always returns a valid vector (which can be empty)
*/
public SortedVector getAll(Class cl, String propertyName, String propertyValue) {
SortedVector ret = new DataModelVector();
try {
XFile dir = getDirectory(cl);
StringVector files = dir.getFiles(false); // get the list of all the files in this directory
for (String id = files.firstItem(); id != null; id = files.nextItem()) {
DataModel model = (DataModel) cl.newInstance(); //create a new instance of the given type
XFile file = new XFile(dir.getPath(), id);
model.dropData(new String(file.getBytes()));
model.setInstanceName(id);
if (propertyValue == null || propertyValue.equals(model.getChildText(propertyName))) {
ret.addElement(model);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}