svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.file / org.gvsig.fmap.dal.file.bsq / src / main / java / org / gvsig / fmap / dal / file / bsq / BSQLibrary.java @ 43876
History | View | Annotate | Download (4.1 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright ? 2007-2016 gvSIG Association
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18 |
* MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.fmap.dal.file.bsq; |
24 |
|
25 |
import java.util.ArrayList; |
26 |
import java.util.List; |
27 |
|
28 |
import org.gvsig.fmap.dal.DALFileLibrary; |
29 |
import org.gvsig.fmap.dal.DALFileLocator; |
30 |
import org.gvsig.fmap.dal.DALLibrary; |
31 |
import org.gvsig.fmap.dal.FileHelper; |
32 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerManager; |
33 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
34 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
35 |
import org.gvsig.metadata.MetadataLocator; |
36 |
import org.gvsig.metadata.MetadataManager; |
37 |
import org.gvsig.metadata.exceptions.MetadataException; |
38 |
import org.gvsig.tools.dynobject.DynClass; |
39 |
import org.gvsig.tools.library.AbstractLibrary; |
40 |
import org.gvsig.tools.library.LibraryException; |
41 |
|
42 |
/**
|
43 |
* BSQ, Band Sequential Format, Library to register provider components
|
44 |
*
|
45 |
*/
|
46 |
public class BSQLibrary extends AbstractLibrary { |
47 |
|
48 |
public static String NAME = "BSQ"; |
49 |
public static String DESCRIPTION = "BSQ provider"; |
50 |
public static String[] FILE_EXTENSIONS = new String[]{"bsq"}; |
51 |
|
52 |
@Override
|
53 |
public void doRegistration() { |
54 |
registerAsServiceOf(DALLibrary.class); |
55 |
require(DALFileLibrary.class); |
56 |
|
57 |
} |
58 |
|
59 |
@Override
|
60 |
protected void doInitialize() throws LibraryException { |
61 |
} |
62 |
|
63 |
@Override
|
64 |
protected void doPostInitialize() throws LibraryException { |
65 |
List<Throwable> exs = new ArrayList<>(); |
66 |
|
67 |
|
68 |
FileHelper.registerParametersDefinition( |
69 |
NAME + "StoreProviderParameters",
|
70 |
FileOpenRasterStoreParameters.class, |
71 |
this.getClass().getClassLoader(),
|
72 |
this.getClass().getResource(NAME + "Parameters.xml")); |
73 |
try {
|
74 |
try {
|
75 |
FileHelper.registerMetadataDefinition( |
76 |
NAME, |
77 |
BSQStoreProvider.class, |
78 |
this.getClass().getClassLoader(),
|
79 |
this.getClass().getResource(NAME + "Metadata.xml")); |
80 |
} catch (MetadataException e) {
|
81 |
exs.add(e); |
82 |
} |
83 |
|
84 |
DataManagerProviderServices datamanager = DALSPILocator.getDataManagerProviderServices(); |
85 |
FilesystemServerExplorerManager explorerManager = DALFileLocator.getFilesystemServerExplorerManager(); |
86 |
|
87 |
if (!datamanager.getStoreProviders().contains(NAME)) {
|
88 |
datamanager.registerStoreProviderFactory( |
89 |
new BSQStoreProviderFactory(
|
90 |
NAME, |
91 |
DESCRIPTION)); |
92 |
} |
93 |
explorerManager.registerProviderFactory( |
94 |
new BSQFileSystemServerProviderFactory(
|
95 |
NAME, |
96 |
DESCRIPTION, |
97 |
FILE_EXTENSIONS |
98 |
) |
99 |
); |
100 |
} catch (Exception e) { |
101 |
exs.add(e); |
102 |
} |
103 |
|
104 |
if (exs.size() > 0) { |
105 |
throw new LibraryException(this.getClass(), exs); |
106 |
} |
107 |
} |
108 |
|
109 |
public static DynClass getMatadataDefinition() { |
110 |
MetadataManager metadataManager = MetadataLocator.getMetadataManager(); |
111 |
DynClass metadataDefinition = (DynClass) metadataManager.getDefinition(NAME); |
112 |
return metadataDefinition;
|
113 |
}} |