2 * Copyright 2005 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.photos.model.filesystem;
19 import java.io.IOException;
20 import java.util.List;
22 import org.wamblee.cache.Cache;
23 import org.wamblee.photos.model.PhotoEntry;
26 * Callback interface used to find a photo entry by id.
28 class FindByIdCallback implements EntryFoundCallback {
30 * Id of the entry to look for.
35 * Search result or null if not found yet.
37 private PhotoEntry _entry;
45 * Constructs the callback.
46 * @param aId Photo entry id to look for.
48 public FindByIdCallback(String aId, Cache aCache) {
55 * Gets the entry that was found.
56 * @return Photo entry or null if not found.
58 public PhotoEntry getEntry() {
64 * @see org.wamblee.photos.model.file.EntryFoundCallback#photoFound(java.io.File, java.io.File, java.lang.String)
66 public boolean photoFound(List<PhotoEntry> aEntries, File aThumbnail, File aPhoto, String aPath) {
67 if ( FileSystemPhoto.getId(aPath).equals(_id)) {
68 _entry = new FileSystemPhoto(aThumbnail, aPhoto, aPath);
71 return true; // continue search.
76 * @see org.wamblee.photos.model.file.EntryFoundCallback#albumFound(java.io.File, java.lang.String)
78 public boolean albumFound(List<PhotoEntry> aEntries, File aAlbum, String aPath) throws IOException {
79 FileSystemAlbum albumEntry = new FileSystemAlbum(aAlbum, aPath, _cache);
80 if ( aAlbum.getName().equals(_id)) {
84 return albumEntry.traverse(albumEntry.getPath(), aEntries, aAlbum, this); // continue search.