Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libCompat / src / org / gvsig / compat / CompatLocator.java @ 25365

History | View | Annotate | Download (2.72 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 initial base implementation
26
 */
27
package org.gvsig.compat;
28

    
29
import org.gvsig.compat.lang.StringUtils;
30
import org.gvsig.tools.locator.BaseLocator;
31
import org.gvsig.tools.locator.Locator;
32
import org.gvsig.tools.locator.LocatorException;
33

    
34
/**
35
 * Locator for the libCompat Library. Returns references to the library's main
36
 * utilities.
37
 * 
38
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
39
 */
40
public class CompatLocator extends BaseLocator {
41
    
42
    /**
43
     * The name of the StringUtils reference.
44
     */
45
    public static final String STRINGUTILS_NAME = "StringUtils";
46

    
47
    /**
48
     * The description of the StringUtils reference.
49
     */
50
    private static final String STRINGUTILS_DESCRIPTION = "Compatible implementation for String Utilities";
51

    
52
    /**
53
     * Unique instance.
54
     */
55
    private static final CompatLocator instance = new CompatLocator();
56

    
57
    /**
58
     * Return the singleton instance.
59
     * 
60
     * @return the singleton instance
61
     */
62
    public static CompatLocator getInstance() {
63
        return instance;
64
    }
65

    
66
    /**
67
     * Return a reference to StringUtils.
68
     * 
69
     * @return a reference to StringUtils
70
     * @throws LocatorException
71
     *             if there is no access to the class or the class cannot be
72
     *             instantiated
73
     * @see Locator#get(String)
74
     */
75
    public static StringUtils getStringUtils() throws LocatorException {
76
        return (StringUtils) getInstance().get(STRINGUTILS_NAME);
77
    }
78
    
79
    /**
80
     * Registers the Class implementing the StringUtils interface.
81
     * 
82
     * @param clazz
83
     *            implementing the StringUtils interface
84
     */
85
    public static void registerStringUtils(Class clazz) {
86
        getInstance()
87
                .register(STRINGUTILS_NAME, STRINGUTILS_DESCRIPTION, clazz);
88
    }
89
}