コード例 #1
0
  public List<Resource> getChildren(Resource parent, boolean includeDeleted) {
    Cursor cursor =
        getReadableDatabase()
            .rawQuery(
                "SELECT name, href, type, content_type, lastmodified "
                    + "FROM files "
                    + "WHERE parent=? "
                    + (!includeDeleted ? "AND flags != " + Resource.DELETED + " " : "")
                    + "ORDER BY type DESC, name ASC",
                new String[] {parent.getHref()});

    List<Resource> resources = new ArrayList<Resource>();

    while (cursor.moveToNext()) {
      Resource resource = new Resource();
      resource.setName(cursor.getString(0));
      resource.setHref(cursor.getString(1));
      resource.setType(ResourceType.valueOf(cursor.getString(2)));
      resource.setContentType(cursor.getString(3));
      resource.setLastModificationDate(new Date(cursor.getLong(4)));
      resources.add(resource);
    }

    return resources;
  }
コード例 #2
0
  public Resource getResource(String baseURI) {
    Cursor cursor =
        getReadableDatabase()
            .rawQuery(
                "SELECT name, href, type, content_type, lastmodified FROM files WHERE href=?",
                new String[] {baseURI});

    if (!cursor.moveToNext()) {
      return null;
    }

    Resource resource = new Resource();
    resource.setName(cursor.getString(0));
    resource.setHref(cursor.getString(1));
    resource.setType(ResourceType.valueOf(cursor.getString(2)));
    resource.setContentType(cursor.getString(3));
    resource.setLastModificationDate(new Date(cursor.getLong(4)));

    return resource;
  }
コード例 #3
0
  public List<Resource> getAllResources() {
    Cursor cursor =
        getReadableDatabase()
            .rawQuery(
                "SELECT name, href, type, content_type, lastmodified, flags FROM files",
                new String[] {});

    List<Resource> resources = new ArrayList<Resource>();

    while (cursor.moveToNext()) {
      Resource resource = new Resource();
      resource.setName(cursor.getString(0));
      resource.setHref(cursor.getString(1));
      resource.setType(ResourceType.valueOf(cursor.getString(2)));
      resource.setContentType(cursor.getString(3));
      resource.setLastModificationDate(new Date(cursor.getLong(4)));
      resource.setFlags(cursor.getInt(5));
      resources.add(resource);
    }

    return resources;
  }
コード例 #4
0
  public Resource getParent(Resource resource) {
    Cursor cursor =
        getReadableDatabase()
            .rawQuery(
                "SELECT p.name, p.href, p.type, p.content_type, p.lastmodified "
                    + "FROM files AS c "
                    + "INNER JOIN files AS p "
                    + "ON c.parent = p.href "
                    + "WHERE c.href=?",
                new String[] {resource.getHref()});

    if (!cursor.moveToNext()) {
      return null;
    }

    Resource parent = new Resource();
    parent.setName(cursor.getString(0));
    parent.setHref(cursor.getString(1));
    parent.setType(ResourceType.valueOf(cursor.getString(2)));
    parent.setContentType(cursor.getString(3));
    parent.setLastModificationDate(new Date(cursor.getLong(4)));

    return parent;
  }