SQLLogger.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import java.util.ArrayList;
  3. import android.content.Context;
  4. /**
  5. * Implementation of the Logger interface using the {@link DatabaseHandler} to create a SQL database.
  6. * @author Lars Pandikow
  7. *
  8. */
  9. public class SQLLogger implements Logger{
  10. Context context;
  11. DatabaseHandler dbh;
  12. public SQLLogger(Context context){
  13. this.context = context;
  14. dbh = new DatabaseHandler(context);
  15. }
  16. public synchronized void write(Record record) {
  17. dbh.addRecord(record);
  18. }
  19. public ArrayList<Record> getAllRecords() {
  20. return dbh.getAllRecords();
  21. }
  22. public ArrayList<Record> getRecordOfEachAttack(int lastUploadedAttackId) {
  23. return dbh.getRecordOfEachAttack(lastUploadedAttackId);
  24. }
  25. public Record getRecordOfAttackId(long attack_id) {
  26. return dbh.getRecordOfAttackId(attack_id);
  27. }
  28. public int getAttackCount() {
  29. return dbh.getAttackCount();
  30. }
  31. public int getAttackPerProtokolCount(String protocol) {
  32. return dbh.getAttackPerProtokolCount(protocol);
  33. }
  34. public long getSmallestAttackId() {
  35. return dbh.getSmallestAttackId();
  36. }
  37. public long getHighestAttackId() {
  38. return dbh.getHighestAttackId();
  39. }
  40. public boolean bssidSeen(String protocol, String bssid) {
  41. return dbh.bssidSeen(protocol, bssid);
  42. }
  43. public String[] getAllBSSIDS() {
  44. return dbh.getAllBSSIDS();
  45. }
  46. public String getSSID(String bssid) {
  47. return dbh.getSSID(bssid);
  48. }
  49. public void deleteByDate(long time) {
  50. dbh.deleteByDate(time);
  51. }
  52. public void deleteByBSSID(String bssid) {
  53. dbh.deleteByBSSID(bssid);
  54. }
  55. public void clearData() {
  56. dbh.clearData();
  57. }
  58. }