@Override
public void update(DataAccess data, String[] fieldNames, Object[] fieldValues) throws DatabaseWriteException {
File file = new File("db/" + data.getName() + ".xml");
if (!file.exists()) {
throw new DatabaseWriteException("Table " + data.getName() + " does not exist!");
}
if (fieldNames.length != fieldValues.length) {
throw new DatabaseWriteException("Field and Value field lenghts are inconsistent!");
}
try {
FileInputStream in = new FileInputStream(file);
Document table = fileBuilder.build(in);
in.close();
updateData(file, table, data, fieldNames, fieldValues);
}
catch (JDOMException e) {
throw new DatabaseWriteException(e.getMessage(), e);
}
catch (IOException e) {
throw new DatabaseWriteException(e.getMessage(), e);
}
catch (DatabaseTableInconsistencyException e) {
throw new DatabaseWriteException(e.getMessage(), e);
}
}