Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libTools / src / org / gvsig / tools / locator / Locator.java @ 24064

History | View | Annotate | Download (3.76 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}   {Create a base Locator implementation}
26
 */
27
package org.gvsig.tools.locator;
28

    
29
/**
30
 * Manages references to the objects of a Library or module.
31
 *
32
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
33
 */
34
public interface Locator {
35

    
36
    /**
37
     * Returns a reference to the object with the given name.
38
     *
39
     * @param name
40
     *            of the object to return
41
     * @return an instance of an object, or null if not found
42
     * @throws LocatorException
43
     *             if there is no access to the class or the class cannot be
44
     *             instantiated
45
     */
46
    Object get(String name) throws LocatorException;
47

    
48
    /**
49
     * Returns the list of names of references available through this Locator.
50
     * Must return null if there are not any registered names.
51
     *
52
     * @return the list of names of references
53
     */
54
    String[] getNames();
55

    
56
    /**
57
     * Registers a class related to a name. The class is used to create an
58
     * instance of the object to return in the {@link #get(String)} method.
59
     *
60
     * @param name
61
     *            of the object to register
62
     * @param clazz
63
     *            the Class of the object to register
64
     */
65
    void register(String name, Class clazz);
66

    
67
    void registerDefault(String name, Class clazz);
68

    
69
    /**
70
     * Registers a class related to a name. The class is used to create an
71
     * instance of the object to return in the {@link #get(String)} method.
72
     *
73
     * @param name
74
     *            of the object to register
75
     * @param description
76
     *            of the object to register
77
     * @param clazz
78
     *            the Class of the object to register
79
     */
80
    void register(String name, String description, Class clazz);
81

    
82
    void registerDefault(String name, String description, Class clazz);
83

    
84
    /**
85
     * Registers an object factory related to a name. The factory is used to
86
     * create an instance of the object to return in the {@link #get(String)}
87
     * method.
88
     *
89
     * @param name
90
     *            of the object to register
91
     * @param factory
92
     *            the factory of objects to register
93
     */
94
    void register(String name, LocatorObjectFactory factory);
95

    
96
    /**
97
     * Registers an object factory related to a name. The factory is used to
98
     * create an instance of the object to return in the {@link #get(String)}
99
     * method.
100
     *
101
     * @param name
102
     *            of the object to register
103
     * @param description
104
     *            of the object to register
105
     * @param factory
106
     *            the factory of objects to register
107
     */
108
    void register(String name, String description, LocatorObjectFactory factory);
109

    
110
    /**
111
     * Returns the name of the Locator, for registration, logging, and other
112
     * uses.
113
     *
114
     * @return the name of the Locator
115
     */
116
    String getLocatorName();
117
}