コード例 #1
0
ファイル: LogManager.java プロジェクト: hoge1e3/soyText2
  public void all(final LogAction action) {
    try {
      sdb.readTransaction(
          new DBAction() {

            @Override
            public void run(SqlJetDb db) throws SqlJetException {
              SqlJetTableHelper t = sdb.logTable();
              ISqlJetCursor c = t.order(null);
              while (!c.eof()) {
                long id = c.getInteger("id");
                LogRecord l = cache.get(id); // TODO: cache
                if (l == null) {
                  l = LogRecord.create((int) id, sdb);
                  fromCursor(c, l);
                }
                if (action.run(l)) break;
                c.next();
              }
              c.close();
            }
          },
          -1);
    } catch (SqlJetException e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
ファイル: LogManager.java プロジェクト: hoge1e3/soyText2
 public void printAll() {
   try {
     sdb.readTransaction(
         new DBAction() {
           @Override
           public void run(SqlJetDb db) throws SqlJetException {
             SqlJetTableHelper t = sdb.logTable();
             ISqlJetCursor c = t.order(null);
             while (!c.eof()) {
               Log.d(
                   "LOG",
                   c.getValue("id")
                       + ","
                       + c.getValue("date")
                       + ","
                       + c.getValue("action")
                       + ","
                       + c.getValue("target"));
               c.next();
             }
             c.close();
           }
         },
         -1);
   } catch (SqlJetException e) {
     e.printStackTrace();
   }
 }
コード例 #3
0
ファイル: LogManager.java プロジェクト: hoge1e3/soyText2
  public LogManager(final SDB sdb) throws SqlJetException {
    super();
    this.sdb = sdb;
    sdb.readTransaction(
        new DBAction() {

          @Override
          public void run(SqlJetDb db) throws SqlJetException {
            SqlJetTableHelper t = sdb.logTable();
            ISqlJetCursor c = t.order(null);
            lastNumber = 0;
            if (c.last()) {
              lastNumber = (int) c.getInteger("id");
            }
          }
        },
        -1);
  }
コード例 #4
0
ファイル: LogManager.java プロジェクト: hoge1e3/soyText2
  public LogRecord byId(final int id) throws SqlJetException {
    if (!cache.containsKey(id)) {
      sdb.readTransaction(
          new DBAction() {

            @Override
            public void run(SqlJetDb db) throws SqlJetException {
              SqlJetTableHelper t = sdb.logTable();
              ISqlJetCursor cur = t.lookup(null, id);
              LogRecord res = LogRecord.create(id, sdb);
              if (!cur.eof()) {
                cache.put(id, res);
                fromCursor(cur, res);
              }
            }
          },
          -1);
    }
    return cache.get(id);
  }