Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.spi / src / main / java / org / gvsig / fmap / dal / resource / spi / MultiResourceParameters.java @ 42609

History | View | Annotate | Download (3.32 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.dal.resource.spi;
24

    
25
import org.gvsig.fmap.dal.feature.spi.memory.MemoryResource;
26
import org.gvsig.tools.ToolsLocator;
27
import org.gvsig.tools.dynobject.DelegatedDynObject;
28
import org.gvsig.tools.dynobject.DynClass;
29
import org.gvsig.tools.dynobject.DynObjectManager;
30

    
31
/**
32
 * Parameters for the creation of a multi resource.
33
 *
34
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
35
 */
36
public class MultiResourceParameters extends AbstractResourceParameters {
37

    
38
    public static final String DYNCLASS_NAME = "MultiResourceParameters";
39

    
40
    private static final String FIELD_NAME = "name";
41

    
42
    private DelegatedDynObject delegatedDynObject;
43

    
44
    /**
45
     * Creates a new {@link MultiResourceParameters}.
46
     */
47
    public MultiResourceParameters() {
48
        this.delegatedDynObject
49
                = (DelegatedDynObject) ToolsLocator.getDynObjectManager()
50
                .createDynObject(registerDynClass());
51
    }
52

    
53
    /**
54
     * Creates a new {@link MultiResourceParameters}.
55
     *
56
     * @param name for the parameters. Will be used as the name of the
57
     * {@link MemoryResource} created with this parametres.
58
     */
59
    @SuppressWarnings("OverridableMethodCallInConstructor")
60
    public MultiResourceParameters(String name) {
61
        this();
62
        setName(name);
63
    }
64

    
65
    @Override
66
    protected DelegatedDynObject getDelegatedDynObject() {
67
        return delegatedDynObject;
68
    }
69

    
70
    @Override
71
    public String getTypeName() {
72
        return MultiResource.TYPE_NAME;
73
    }
74

    
75
    public String getName() {
76
        return (String) getDelegatedDynObject().getDynValue(FIELD_NAME);
77
    }
78

    
79
    public void setName(String name) {
80
        getDelegatedDynObject().setDynValue(FIELD_NAME, name);
81
    }
82

    
83
    @Override
84
    public String getResurceID() {
85
        return "name=" + this.encodeIDValue(this.getName());
86
    }
87

    
88
    /**
89
     * Registers the {@link DynClass} of this parameters attributes.
90
     *
91
     * @return the dyn class of this parameters
92
     */
93
    private static synchronized DynClass registerDynClass() {
94
        DynObjectManager dynman = ToolsLocator.getDynObjectManager();
95
        DynClass dynClass = dynman.get(DYNCLASS_NAME);
96
        if (dynClass == null) {
97
            dynClass = dynman.add(DYNCLASS_NAME);
98
            dynClass.addDynFieldString(FIELD_NAME).setDescription(
99
                    "The name of the multi resource");
100
        }
101
        return dynClass;
102
    }
103
}