if (targetFolders != null)
if (targetFolders != null) {
    private static int setSearchVars(PreparedStatement stmt, DbSearchConstraintsNode node, int param) throws SQLException {        DbSearchConstraintsNode.NodeType ntype = node.getNodeType();        if (ntype == DbSearchConstraintsNode.NodeType.AND || ntype == DbSearchConstraintsNode.NodeType.OR) {            for (DbSearchConstraintsNode subnode : node.getSubNodes())                param = setSearchVars(stmt, subnode, param);            return param;        }        // we're here, so we must be in a DbSearchConstraints leaf node        DbSearchConstraints c = node.getSearchConstraints();        assert(ntype == DbSearchConstraintsNode.NodeType.LEAF && c != null);        // if there are no possible matches, short-circuit here...        if (c.automaticEmptySet())            return param;        if (!ListUtil.isEmpty(c.types))            for (byte type : c.types)                stmt.setByte(param++, type);        if (!ListUtil.isEmpty(c.excludeTypes))            for (byte type : c.excludeTypes)                stmt.setByte(param++, type);         if (c.tagConstraints.searchTagsets != null)            for (long tagset : c.tagConstraints.searchTagsets)                stmt.setLong(param++, tagset);        if (c.tagConstraints.searchFlagsets != null)            for (long flagset : c.tagConstraints.searchFlagsets)                stmt.setLong(param++, flagset);        if (c.tagConstraints.unread != null)            stmt.setInt(param++, c.tagConstraints.unread ? 1 : 0);        Collection<Folder> targetFolders = (!ListUtil.isEmpty(c.folders)) ? c.folders : c.excludeFolders;        if (targetFolders != null)            for (Folder folder : targetFolders)                stmt.setInt(param++, folder.getId());        if (c.convId > 0)            stmt.setInt(param++, c.convId);        else if (!ListUtil.isEmpty(c.prohibitedConvIds))            for (int id : c.prohibitedConvIds)                stmt.setInt(param++, id);        if (!ListUtil.isEmpty(c.itemIds))            for (int id : c.itemIds)                stmt.setInt(param++, id);        if (!ListUtil.isEmpty(c.prohibitedItemIds))            for (int id : c.prohibitedItemIds)                stmt.setInt(param++, id);        if (!ListUtil.isEmpty(c.indexIds))            for (int id : c.indexIds)                stmt.setInt(param++, id);        if (!ListUtil.isEmpty(c.dates))            for (DbSearchConstraints.NumericRange date : c.dates) {                if (date.lowest > 0)                    stmt.setInt(param++, (int) Math.min(date.lowest / 1000, Integer.MAX_VALUE));                if (date.highest > 0)                    stmt.setInt(param++, (int) Math.min(date.highest / 1000, Integer.MAX_VALUE));            }        if (!ListUtil.isEmpty(c.modified))             for (DbSearchConstraints.NumericRange modified : c.modified) {                if (modified.lowest > 0)                    stmt.setLong(param++, modified.lowest);                if (modified.highest > 0)                    stmt.setLong(param++, modified.highest);            }        if (!ListUtil.isEmpty(c.sizes))            for (DbSearchConstraints.NumericRange size : c.sizes) {                if (size.lowest >= 0)                    stmt.setInt(param++, (int) size.lowest);                if (size.highest >= 0)                    stmt.setInt(param++, (int) size.highest);            }        if (!ListUtil.isEmpty(c.subjectRanges))            for (DbSearchConstraints.StringRange cur: c.subjectRanges) {                if (cur.lowest != null)                     stmt.setString(param++, cur.lowest);                if (cur.highest != null)                     stmt.setString(param++, cur.highest);            }        if (!ListUtil.isEmpty(c.senderRanges))            for (DbSearchConstraints.StringRange cur: c.senderRanges) {                if (cur.lowest != null)                     stmt.setString(param++, cur.lowest);                if (cur.highest != null)                     stmt.setString(param++, cur.highest);            }        return param;    }