svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.xml2db / org.gvsig.xml2db.lib / org.gvsig.xml2db.lib.api / src / main / java / org / gvsig / xml2db / lib / api / Xml2dbLocator.java @ 47245
History | View | Annotate | Download (3.24 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright ? 2007-2014 gvSIG Association
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
|
25 |
package org.gvsig.xml2db.lib.api; |
26 |
|
27 |
import org.gvsig.tools.locator.BaseLocator; |
28 |
import org.gvsig.tools.locator.Locator; |
29 |
import org.gvsig.tools.locator.LocatorException; |
30 |
|
31 |
/**
|
32 |
* This locator is the entry point for the XML library, providing
|
33 |
* access to all XML services through the {@link Xml2dbManager}
|
34 |
*
|
35 |
*/
|
36 |
public class Xml2dbLocator extends BaseLocator { |
37 |
|
38 |
/**
|
39 |
* XML locator name
|
40 |
*/
|
41 |
private static final String LOCATOR_NAME = "XMLLocator"; |
42 |
|
43 |
/**
|
44 |
* XML manager name
|
45 |
*/
|
46 |
public static final String MANAGER_NAME = "XML.manager"; |
47 |
|
48 |
/**
|
49 |
* XML manager description
|
50 |
*/
|
51 |
private static final String MANAGER_DESCRIPTION = |
52 |
"XML Manager of gvSIG";
|
53 |
|
54 |
/**
|
55 |
* Unique instance
|
56 |
*/
|
57 |
private static final Xml2dbLocator instance = new Xml2dbLocator(); |
58 |
|
59 |
/**
|
60 |
* Returns the singleton instance.
|
61 |
*
|
62 |
* @return the singleton instance
|
63 |
*/
|
64 |
public static Xml2dbLocator getInstance() { |
65 |
return instance;
|
66 |
} |
67 |
|
68 |
/**
|
69 |
* Returns the Locator's name
|
70 |
*
|
71 |
* @return a String with the Locator's name
|
72 |
*/
|
73 |
@Override
|
74 |
public String getLocatorName() { |
75 |
return LOCATOR_NAME;
|
76 |
} |
77 |
|
78 |
/**
|
79 |
* Return a reference to XMLLocator.
|
80 |
*
|
81 |
* @return a reference to XMLLocator
|
82 |
* @throws LocatorException
|
83 |
* if there is no access to the class or the class
|
84 |
* cannot be instantiated
|
85 |
* @see Locator#get(String)
|
86 |
*/
|
87 |
public static Xml2dbManager getManager() throws LocatorException { |
88 |
return getXml2dbManager();
|
89 |
} |
90 |
|
91 |
public static Xml2dbManager getXml2dbManager() throws LocatorException { |
92 |
return (Xml2dbManager) getInstance().get(MANAGER_NAME);
|
93 |
} |
94 |
|
95 |
/**
|
96 |
* Registers the Class implementing the XMLLocator interface.
|
97 |
*
|
98 |
* @param clazz
|
99 |
* implementing the XMLLocator interface
|
100 |
*/
|
101 |
public static void registerXMLManager(Class clazz) { |
102 |
getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
103 |
} |
104 |
|
105 |
/**
|
106 |
* Registers the default Class implementing the XMLLocator interface
|
107 |
*
|
108 |
* @param clazz
|
109 |
* implementing the XMLLocator interface
|
110 |
*/
|
111 |
public static void registerDefaultXMLManager(Class clazz) { |
112 |
getInstance().registerDefault(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
113 |
} |
114 |
|
115 |
} |