Code example for LinkedList

Methods: add, size, toArray

0
	 *  
	 * @param db 
	 * @return Cursor representing the results of the search 
	 */ 
	public Cursor doQuery(SQLiteDatabase db) {
		LinkedList<String> projectionIn = new LinkedList<String>();
		 
		LinkedList<String> selectPieces = new LinkedList<String>();
		LinkedList<String> fromPieces = new LinkedList<String>();
		LinkedList<String> wherePieces = new LinkedList<String>();
		//LinkedList<String> orderPieces = null; 
		 
		if (0 != (this.columnTypes & COLUMN_TYPE_APP)) {
			selectPieces.add(SELECTPART_COLUMNS_APP);
		} else { 
			if (0 != (this.columnTypes & COLUMN_TYPE_PACKAGENAME)) {
				selectPieces.add(SELECTPART_COLUMNS_PACKAGENAME);
			} 
			if (0 != (this.columnTypes & COLUMN_TYPE_LABEL)) {
				selectPieces.add(SELECTPART_COLUMNS_LABEL);
			} 
		} 
		if (0 != (this.columnTypes & COLUMN_TYPE_STATUSFLAGS)) {
			selectPieces.add(SELECTPART_COLUMNS_STATUSFLAGS);
			fromPieces.add(FROMPART_JOIN_APP_WITH_STATUS);
		} 
		 
 
		if (0 != (this.filterTypes & (FILTER_BY_SETTING_GROUP_ID | FILTER_BY_SETTING_GROUP_TITLE))) {
			fromPieces.add(FROMPART_FILTER_BY_SETTING_DETAILS);
		} else if (0 != (this.filterTypes & FILTER_BY_PERMISSION)) {
			//The tables required for filtering by permissions are included by filtering by setting group or setting group name already 
			fromPieces.add(FROMPART_FILTER_BY_PERMISSION);
		} 
 
		if (0 != (this.filterTypes & FILTER_BY_PERMISSION)) {
			projectionIn.add(this.filterValues[FILTER_TEXT_PERMISSION]);
			wherePieces.add(WHEREPART_FILTER_BY_PERMISSION);
		} 
		if (0 != (this.filterTypes & FILTER_BY_SETTING_GROUP_ID)) {
			projectionIn.add(this.filterValues[FILTER_TEXT_SETTING_GROUP_ID]);
			wherePieces.add(WHEREPART_FILTER_BY_SETTING_GROUP_TITLE);
		} 
		if (0 != (this.filterTypes & FILTER_BY_SETTING_GROUP_TITLE)) {
			projectionIn.add(this.filterValues[FILTER_TEXT_SETTING_GROUP_TITLE]);
			wherePieces.add(WHEREPART_FILTER_BY_SETTING_GROUP_TITLE);
		} 
		if (0 != (this.filterTypes & FILTER_BY_TYPE)) {
			projectionIn.add(this.filterValues[FILTER_TEXT_TYPE]);
			wherePieces.add(WHEREPART_FILTER_BY_TYPE);
		} 
		if (0 != (this.filterTypes & FILTER_BY_LABEL)) {
			projectionIn.add(this.filterValues[FILTER_TEXT_LABEL]);
			wherePieces.add(WHEREPART_FILTER_BY_LABEL);
		} 
		if (0 != (this.filterTypes & FILTER_BY_PACKAGENAME)) {
			projectionIn.add(this.filterValues[FILTER_TEXT_PACKAGENAME]);
			wherePieces.add(WHEREPART_FILTER_BY_PACKAGENAME);
		} 
 
		StringBuilder queryStringBuilder = new StringBuilder("SELECT DISTINCT ")
			.append(TextUtils.join(", ", selectPieces))
			.append(FROMPART_APP_TABLE)
			.append(TextUtils.join("",fromPieces));
		if (wherePieces.size() > 0) {
			queryStringBuilder.append(" WHERE ").append(TextUtils.join(" AND ", wherePieces));
		} 
		queryStringBuilder.append(" ORDER BY ").append(ORDERPART_SORT_BY_LABEL);
 
		this.queryText = queryStringBuilder.toString();
		 
		this.projectionIn = projectionIn.toArray(new String[projectionIn.size()]);
		return db.rawQuery(this.queryText, this.projectionIn);
	} 
	 
	protected static final String SELECTPART_COLUMNS_PACKAGENAME = 
			ApplicationTable.TABLE_NAME + "." + ApplicationTable.COLUMN_NAME_PACKAGENAME;