KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > patterns > listdata > util > AsyncDataLoaderOwner


1 /*
2  * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: AsyncDataLoaderOwner.java,v 1.2 2007/01/07 06:14:15 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21  
22 package org.opensubsystems.patterns.listdata.util;
23
24 import java.util.List JavaDoc;
25
26 import org.opensubsystems.patterns.listdata.data.ListOptions;
27
28 /**
29  * This interface should be implemented by the class which uses AsyncDataLoader
30  * to load items in the background.
31  *
32  * @version $Id: AsyncDataLoaderOwner.java,v 1.2 2007/01/07 06:14:15 bastafidli Exp $
33  * @author Miro Halas
34  * @code.reviewer Miro Halas
35  * @code.reviewed Initial revision
36  */

37 public interface AsyncDataLoaderOwner
38 {
39    /**
40     * Get the initial ListOptions structure used to load the list of data
41     * objects. This method may be modify the default listoptions passed in if
42     * some parameters should be preset.
43     *
44     * @param loader - loader invoking this call
45     * @param defaultOptions - default options which can be modified or replaced
46     * with new initial options
47     * @return ListOptions - initialized list options
48     */

49    ListOptions getInitialListOptions(
50       AsyncDataLoader loader,
51       ListOptions defaultOptions
52    );
53    
54    /**
55     * This method should return true if the async thread should stop loading
56     * data. It can be for example implemented in such a way that the owner
57     * stores the reference to the latest asynchronous loader constructed. If
58     * some previous constructed loader is still running and calls this method,
59     * it will compare it with the cached value and return true if they are not
60     * equal.
61     *
62     * @param loader - loader invoking this call
63     * @return boolean - true if the async thread should stop loading data, false
64     * to continue loading
65     */

66    boolean stopLoading(
67       AsyncDataLoader loader
68    );
69    
70    /**
71     * Process data which were asynchronously loaded.
72     *
73     * @param loader - loader invoking this call
74     * @param lstDataToAdd - list of data items to add to the container
75     * @param iOriginalObjectVersion - version of the object by which the data
76     * should be processed, which is the version which was used to
77     * construct this object. If the version of the object at the time when
78     * the data are being processed is different from this version, then
79     * the data will not be processed or the processing of the data stops.
80     */

81    void processData(
82       AsyncDataLoader loader,
83       List JavaDoc lstDataToAdd,
84       int iOriginalObjectVersion
85    );
86
87    /**
88     * This function is called where data loading finished. It is useful if you
89     * want do same changes or ask for information relevant to the whole dataset.
90     *
91     * @param loader - loader invoking this call
92     */

93    void allDataLoaded(
94       AsyncDataLoader loader
95    );
96 }
97
Popular Tags