// Fourth search sub-string and case-insensitive.
public List<PlayItem> queryForPlayableItems (final String query1, final String query2, final int maxResults) throws MorriganException {
		List<PlayItem> ret = new LinkedList<PlayItem>();
		List<MediaListReference> items = new LinkedList<MediaListReference>();
		List<MediaListReference> matches = new LinkedList<MediaListReference>();
		items.addAll(this.mediaFactory.getAllLocalMixedMediaDbs());
		items.addAll(RemoteMixedMediaDbHelper.getAllRemoteMmdb(Config.DEFAULT));
		// First search exact.
		for (MediaListReference i : items) {
			if (i.getTitle().equals(query1)) matches.add(i);
		}
		// Second search case-insensitive, but still exact.
		if (matches.size() < 1) {
			for (MediaListReference i : items) {
				if (i.getTitle().equalsIgnoreCase(query1)) matches.add(i);
			}
		}
		// Third search sub-string.
		if (matches.size() < 1) {
			for (MediaListReference i : items) {
				if (i.getTitle().contains(query1)) matches.add(i);
			}
		}
		// Fourth search sub-string and case-insensitive.
		if (matches.size() < 1) {
			for (MediaListReference i : items) {
				if (i.getTitle().toLowerCase().contains(query1.toLowerCase())) matches.add(i);
			}
		}
		for (MediaListReference explorerItem : matches) {
			if (ret.size() >= maxResults) break;
			/*
			 * FIXME this will load the DB (if its not already loaded), which is excessive if we are
			 * just going to show some search results.
			 */
			IMediaTrackDb<?, ? extends IMediaTrack> db = mediaListReferenceToReadTrackDb(explorerItem);
			if (query2 == null) {
				ret.add(new PlayItem(db, null));
			}
			else {
				List<? extends IMediaTrack> results;
				try {
					results = db.simpleSearch(query2, maxResults);
				}
				catch (DbException e) {
					throw new MorriganException(e);
				}
				for (IMediaTrack result : results) {
					if (ret.size() >= maxResults) break;
					ret.add(new PlayItem(db, result));
				}
			}
		}
		return ret;
	}
}
}
// Fourth search sub-string and case-insensitive.
if (matches.size() < 1) {
for (MediaListReference i : items) {
for (MediaListReference i : items) {
if (i.getTitle().equalsIgnoreCase(query1)) matches.add(i);
}
}
// Third search sub-string.
if (matches.size() < 1) {
for (MediaListReference i : items) {
if (i.getTitle().contains(query1)) matches.add(i);
}
}
// Fourth search sub-string and case-insensitive.
if (matches.size() < 1) {
for (MediaListReference i : items) {
if (i.getTitle().toLowerCase().contains(query1.toLowerCase())) matches.add(i);
}
}
for (MediaListReference explorerItem : matches) {
if (ret.size() >= maxResults) break;
/*
* FIXME this will load the DB (if its not already loaded), which is excessive if we are
* just going to show some search results.
List<MediaListReference> items = new LinkedList<MediaListReference>();
List<MediaListReference> matches = new LinkedList<MediaListReference>();
items.addAll(this.mediaFactory.getAllLocalMixedMediaDbs());
items.addAll(RemoteMixedMediaDbHelper.getAllRemoteMmdb(Config.DEFAULT));
// First search exact.
for (MediaListReference i : items) {
if (i.getTitle().equals(query1)) matches.add(i);
}
// Second search case-insensitive, but still exact.
if (matches.size() < 1) {
for (MediaListReference i : items) {
if (i.getTitle().equalsIgnoreCase(query1)) matches.add(i);
}
}
// Third search sub-string.
if (matches.size() < 1) {
for (MediaListReference i : items) {
if (i.getTitle().contains(query1)) matches.add(i);
}
}
// Fourth search sub-string and case-insensitive.
if (matches.size() < 1) {
for (MediaListReference i : items) {
if (i.getTitle().toLowerCase().contains(query1.toLowerCase())) matches.add(i);
}
}
for (MediaListReference explorerItem : matches) {
if (ret.size() >= maxResults) break;
/*
* FIXME this will load the DB (if its not already loaded), which is excessive if we are
* just going to show some search results.
*/
IMediaTrackDb<?, ? extends IMediaTrack> db = mediaListReferenceToReadTrackDb(explorerItem);
if (query2 == null) {
ret.add(new PlayItem(db, null));
}
else {
List<? extends IMediaTrack> results;
try {
results = db.simpleSearch(query2, maxResults);
}