if (mHasSpamTrashSetting || dbOther.mHasSpamTrashSetting) { toRet.mHasSpamTrashSetting = true; } else { toRet.mHasSpamTrashSetting = false; }
    protected QueryOperation combineOps(QueryOperation other, boolean union)     {        if (union) {            // only join on intersection right now...        	if (mConstraints.noResults) {                // a query for (other OR nothing) == other                return other;            }            return null;        } else {            if (mAllResultsQuery) {                // we match all results.  (other AND anything) == other                                assert(mLuceneOp == null);                if (hasSpamTrashSetting()) {                    other.forceHasSpamTrashSetting();                }                return other;            }        }                DBQueryOperation dbOther = null;                if (other instanceof DBQueryOperation) {            dbOther = (DBQueryOperation)other;        } else {            return null;        }        DBQueryOperation toRet = new DBQueryOperation();                if (mLuceneOp != null) {            toRet.mLuceneOp = mLuceneOp;                        if (dbOther.mLuceneOp != null) {                toRet.mLuceneOp.combineOps(dbOther.mLuceneOp, false);            }        } else {            toRet.mLuceneOp = dbOther.mLuceneOp;        }                if (mHasSpamTrashSetting || dbOther.mHasSpamTrashSetting) {            toRet.mHasSpamTrashSetting = true;        } else {            toRet.mHasSpamTrashSetting = false;        }                if (mAllResultsQuery && dbOther.mAllResultsQuery) {            toRet.mAllResultsQuery = true;        } else {            toRet.mAllResultsQuery = false;        }                if (mConstraints.noResults|| dbOther.mConstraints.noResults) {        	toRet.mConstraints.noResults = true;        	return toRet;        }                toRet.mConstraints = mConstraints;        mConstraints.andConstraints(dbOther.mConstraints);//        { // dates//            toRet.mDates = (HashSet<Range>)mDates.clone();//            for (Iterator iter = dbOther.mDates.iterator(); iter.hasNext();) {//                DbSearchConstraints.Range r = (DbSearchConstraints.Range)iter.next();//                toRet.addDateClause(r.lowest, r.highest, !r.negated);//            }//        }//        //        { // sizes//            toRet.mSizes = (HashSet<Range>)mSizes.clone();//            for (Iterator iter = dbOther.mSizes.iterator(); iter.hasNext();) {//                DbSearchConstraints.Range r = (DbSearchConstraints.Range)iter.next();//                toRet.addSizeClause(r.lowest, r.highest, !r.negated);//            }//        }//        //        {   // item-id's are INTERSECTED because they are SETS (ie "one of...") instead of//            // additive required parameters (tags="UNSEEN and TAG1...")//            //            //            // these we have to intersect://            ////            //   Item{A or B or C} AND Item{B or C or D} --> Item{IN-BOTH}//            ////            if (mIncludedItemIds == null) {//                toRet.mIncludedItemIds = dbOther.mIncludedItemIds;//            } else if (dbOther.mIncludedItemIds == null) {//                toRet.mIncludedItemIds = mIncludedItemIds;//            } else {//                toRet.mIncludedItemIds = new HashSet<Integer>(); // start out with EMPTY SET (no results!)//                for (Iterator iter = mIncludedItemIds.iterator(); iter.hasNext();)//                {//                    Integer i = (Integer)(iter.next());//                    if (dbOther.mIncludedItemIds.contains(i)) {//                        toRet.addItemIdClause(i, true);//                    }//                }//            }////            ////            // these we can just combine, since://            ////            // -Item{A or B} AND -Item{C or D} --> //            //   (-Item(A) AND -Item(B)) AND (-C AND -D) -->//            //     (A AND B AND C AND D)//            ////            if (mExcludedItemIds == null) {//                toRet.mExcludedItemIds = dbOther.mExcludedItemIds;//            } else if (dbOther.mExcludedItemIds == null) {//                toRet.mExcludedItemIds = mExcludedItemIds;//            } else {//                toRet.mExcludedItemIds = (HashSet)mExcludedItemIds.clone();//                //                for (Iterator iter = dbOther.mExcludedItemIds.iterator(); iter.hasNext();)//                {//                    Integer i = (Integer)(iter.next());//                    toRet.addItemIdClause(i, false);//                }//            }//        }//     ////        { // conversation id's//            toRet.mProhibitedConvIds = (HashSet)mProhibitedConvIds.clone();//            for (Iterator iter = dbOther.mProhibitedConvIds.iterator(); iter.hasNext();)//            {//                Integer i = (Integer)(iter.next());//                toRet.addConvId(i.intValue(), false);//            }//            //            if (mConvId != 0) {//                toRet.addConvId(mConvId, true);//            }//            if (dbOther.mConvId != 0) {//                toRet.addConvId(dbOther.mConvId, true);//            }//            //        }//        //        { // FOLDERS//            if (mFolder != null) {//                toRet.addInClause(mFolder, true);//            }//            if (dbOther.mFolder != null) {//                toRet.addInClause(dbOther.mFolder, true);//            }//            //            for (Iterator iter = mExcludeFolder.iterator(); iter.hasNext();)//            {//                Folder f = (Folder)(iter.next());//                toRet.addInClause(f, false);//            }//            //            for (Iterator iter = dbOther.mExcludeFolder.iterator(); iter.hasNext();)//            {//                Folder f = (Folder)(iter.next());//                toRet.addInClause(f, false);//            }//        }//        //        { // ...combine types...////            toRet.mTypes = combineByteArraysNoDups(mTypes, dbOther.mTypes);//        	toRet.mTypes = (HashSet<Byte>)mTypes.clone();//        	toRet.mTypes.addAll(dbOther.mTypes);//        	////          toRet.mExcludeTypes = combineByteArraysNoDups(mExcludeTypes, dbOther.mExcludeTypes);//        	toRet.mExcludeTypes = (HashSet<Byte>)mExcludeTypes.clone();//        	toRet.mExcludeTypes.addAll(dbOther.mExcludeTypes);//        }//        //        //        { // ...combine tags...//            toRet.mIncludeTags = (HashSet<Tag>)mIncludeTags.clone();//            for (Iterator iter = dbOther.mIncludeTags.iterator(); iter.hasNext();)//            {//                Tag t = (Tag)(iter.next());//                toRet.addTagClause(t, true);//            }//            //            for (Iterator iter = mExcludeTags.iterator(); iter.hasNext();)//            {//                Tag t = (Tag)(iter.next());//                toRet.addTagClause(t, false);//            }//            //            for (Iterator iter = dbOther.mExcludeTags.iterator(); iter.hasNext();)//            {//                Tag t = (Tag)(iter.next());//                toRet.addTagClause(t, false);//            }//        }                        return toRet;    }