1 /*
2 Copyright (C) 2000 - 2007 Grid Systems, S.A.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2, as
6 published by the Free Software Foundation.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18 /*
19 * Project: IGUtils
20 * Created on 17-jun-2004
21 *
22 * Copyright (c)2004 Grid Systems
23 */
24 package com.gridsystems.storage;
25
26 import java.util.Map;
27
28 /**
29 * Data Access Object.
30 *
31 * @author <a href="mailto:rruiz@gridsystems.com">Rodrigo Ruiz Aguayo</a>
32 * @author Xmas (Generics)
33 * @param <T> Class to store/load.
34 * @version 1.0
35 */
36 public interface DAO<T> {
37 /**
38 * Loads an object from the speficied file list.
39 *
40 * @param fileNames The names of the files where the object data is stored
41 * @return The loaded object instance
42 * @throws Exception in case of error
43 */
44 T load(String[] fileNames) throws Exception;
45
46 /**
47 * Stores an object in the specified file list.
48 *
49 * @param fileNames The names of the files where the object data must be stored
50 * @param obj The object to store
51 * @throws Exception In case of error
52 */
53 void store(String[] fileNames, T obj) throws Exception;
54
55 /**
56 * Gets the list of file names from where to load an object from the specified
57 * Map.
58 *
59 * @param initData A map containing data that can be used to find out the file
60 * names from where to load an object
61 * @return The list of file names
62 */
63 String[] getFileNames(Map<String, String> initData);
64
65 /**
66 * Gets the list of file names where an object must be stored, from the object itself.
67 * <p>
68 * It can also be used to obtain the list of files to delete on object removal.
69 *
70 * @param obj The object to store
71 * @return The list of file names
72 */
73 String[] getFileNames(T obj);
74 }