示例#1
0
 private static String encodeBookmark(DB.Bookmark bm) {
   // NOTE : Check strictly to keep DB safe!!!
   eAssert(bm.pos > 0 && Utils.isValidValue(bm.name));
   return ((Integer) bm.pos).toString() // to avoid implicit casting to 'char' type,
       //   because following DB.BOOKMARK_NAME_DELIMIETER is 'char'.
       + DB.BOOKMARK_NAME_DELIMIETER
       + bm.name;
 }
示例#2
0
  static ContentValues copyContent(Cursor c, DB.Col[] cols) {
    ContentValues cvs = new ContentValues();
    for (Col col : cols) {
      if (BaseColumns._ID.equals(col.getName())) continue; // ID SHOULD NOT be copied.

      if ("text".equals(col.getType())) {
        cvs.put(col.getName(), c.getString(c.getColumnIndex(col.getName())));
      } else if ("integer".equals(col.getType())) {
        cvs.put(col.getName(), c.getLong(c.getColumnIndex(col.getName())));
      } else if ("blob".equals(col.getType())) {
        cvs.put(col.getName(), c.getBlob(c.getColumnIndex(col.getName())));
      } else eAssert(false);
    }
    return cvs;
  }
示例#3
0
  /**
   * Build SQL from joining video and video-ref tables
   *
   * @param plid
   * @param cols
   * @param field for "WHERE 'field' = 'value'"
   * @param value for "WHERE 'field' = 'value'"
   * @param colOrderBy
   * @param asc
   * @return
   */
  static String buildQueryVideosSQL(
      long plid, ColVideo[] cols, ColVideo field, Object value, ColVideo colOrderBy, boolean asc) {
    eAssert(cols.length > 0);

    String sql = "SELECT ";
    String sel = "";
    String tableVideoNS = DB.getVideoTableName() + "."; // NS : NameSpace
    String[] cnames = getColNames(cols);
    for (int i = 0; i < cnames.length - 1; i++) sel += tableVideoNS + cnames[i] + ", ";
    sel += tableVideoNS + cnames[cnames.length - 1];

    String where = "";
    if (null != field && null != value)
      where =
          " AND "
              + tableVideoNS
              + field.getName()
              + " = "
              + DatabaseUtils.sqlEscapeString(value.toString());

    String orderBy = buildSQLOrderBy(true, colOrderBy, asc);
    // NOTE
    // There is NO USE CASE requiring sorted cursor for videos.
    // result of querying videos don't need to be sorted cursor.
    String mrefTable = DB.getVideoRefTableName(plid);
    sql +=
        sel
            + " FROM "
            + DB.getVideoTableName()
            + ", "
            + mrefTable
            + " WHERE "
            + mrefTable
            + "."
            + ColVideoRef.VIDEOID.getName()
            + " = "
            + tableVideoNS
            + ColVideo.ID.getName()
            + where
            + " "
            + (null != orderBy ? orderBy : "")
            + ";";
    return sql;
  }