Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.impl / src / main / java / org / gvsig / installer / lib / impl / DefaultPackageInfo.java @ 34444

History | View | Annotate | Download (6.44 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (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
 * 2010 {Prodevelop}   {Task}
26
 */
27

    
28
package org.gvsig.installer.lib.impl;
29

    
30
import java.io.File;
31
import java.net.URL;
32
import java.util.ArrayList;
33
import java.util.List;
34

    
35
import org.gvsig.installer.lib.api.InstallerManager.ARCH;
36
import org.gvsig.installer.lib.api.InstallerManager.JVM;
37
import org.gvsig.installer.lib.api.InstallerManager.OS;
38
import org.gvsig.installer.lib.api.InstallerManager.STATE;
39
import org.gvsig.installer.lib.api.PackageInfo;
40
import org.gvsig.installer.lib.impl.info.InstallerInfoTags;
41

    
42
/**
43
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
44
 */
45
public class DefaultPackageInfo implements PackageInfo {
46

    
47
    private String code = null;
48
    private String name = null;
49
    private String description = null;
50
    private String version = "0.0.1";
51
    private int build = 0;
52
    private boolean official;
53
    private List<File> selectedFiles = null;
54
    private String antScript = null;
55
    private String type = null;
56

    
57
    private String state = STATE.DEVEL;
58
    private String operatingSystem = OS.ALL;
59
    private String architecture = ARCH.ALL;
60
    private String javaVM = JVM.J1_5;
61

    
62
    private String gvSIGVersion;
63

    
64
    private URL defaultDownloadURL = null;
65

    
66
    private String modelVersion = "1.0.0";
67

    
68
    public DefaultPackageInfo() {
69
        super();
70
        selectedFiles = new ArrayList<File>();
71
    }
72

    
73
    public String getCode() {
74
        return code;
75
    }
76

    
77
    public String getName() {
78
        return name;
79
    }
80

    
81
    public String getDescription() {
82
        return description;
83
    }
84

    
85
    public String getVersion() {
86
        return version;
87
    }
88

    
89
    public int getBuild() {
90
        return build;
91
    }
92

    
93
    public String getState() {
94
        return state;
95
    }
96

    
97
    public boolean isOfficial() {
98
        return official;
99
    }
100

    
101
    public void setCode(String code) {
102
        this.code = code;
103
    }
104

    
105
    public void setName(String name) {
106
        this.name = name;
107
    }
108

    
109
    public void setDescription(String description) {
110
        this.description = description;
111
    }
112

    
113
    public void setVersion(String version) {
114
        this.version = version;
115
    }
116

    
117
    public void setBuild(int build) {
118
        this.build = build;
119
    }
120

    
121
    public void setState(String state) {
122
        this.state = state;
123
    }
124

    
125
    public void setOfficial(boolean official) {
126
        this.official = official;
127
    }
128

    
129
    public String getOperatingSystem() {
130
        return operatingSystem;
131
    }
132

    
133
    public void setOperatingSystem(String operatingSystem) {
134
        this.operatingSystem = operatingSystem;
135
    }
136

    
137
    public String getArchitecture() {
138
        return architecture;
139
    }
140

    
141
    public void setArchitecture(String architecture) {
142
        this.architecture = architecture;
143
    }
144

    
145
    public String getJavaVM() {
146
        return javaVM;
147
    }
148

    
149
    public void setJavaVM(String javaVM) {
150
        this.javaVM = javaVM;
151
    }
152

    
153
    public void addFileToCopy(File file) {
154
        selectedFiles.add(file);
155
    }
156

    
157
    public File getFileToCopyAt(int index) {
158
        return selectedFiles.get(index);
159
    }
160

    
161
    public int getFileToCopySize() {
162
        return selectedFiles.size();
163
    }
164

    
165
    public void removeFileToCopy(int index) {
166
        selectedFiles.remove(index);
167
    }
168

    
169
    public String getAntScript() {
170
        return antScript;
171
    }
172

    
173
    public void setAnScript(String antScript) {
174
        this.antScript = antScript;
175
    }
176

    
177
    public String getType() {
178
        return type;
179
    }
180

    
181
    public void setType(String type) {
182
        this.type = type;
183
    }
184

    
185
    public String getGvSIGVersion() {
186
        return gvSIGVersion;
187
    }
188

    
189
    public void setGvSIGVersion(String gvSIGVersion) {
190
        this.gvSIGVersion = gvSIGVersion;
191
    }
192

    
193
    public URL getDownloadURL() {
194
        return defaultDownloadURL;
195
    }
196

    
197
    public void setDownloadURL(URL defaultDownloadURL) {
198
        this.defaultDownloadURL = defaultDownloadURL;
199
    }
200

    
201
    public String getModelVersion() {
202
        return modelVersion;
203
    }
204

    
205
    public void setModelVersion(String modelVersion) {
206
        this.modelVersion = modelVersion;
207
    }
208

    
209
    @Override
210
    public String toString() {
211
        StringBuffer buffer = new StringBuffer(super.toString()).append(" (");
212

    
213
        append(buffer, InstallerInfoTags.CODE, getCode());
214
        append(buffer, InstallerInfoTags.NAME, getName());
215
        append(buffer, InstallerInfoTags.DESCRIPTION, getDescription());
216
        append(buffer, InstallerInfoTags.GVSIG_VERSION, getGvSIGVersion());
217
        append(buffer, InstallerInfoTags.VERSION, getVersion());
218
        append(buffer, InstallerInfoTags.BUILD, getBuild());
219
        append(buffer, InstallerInfoTags.OS, getOperatingSystem());
220
        append(buffer, InstallerInfoTags.ARCHITECTURE, getArchitecture());
221
        append(buffer, InstallerInfoTags.JVM, getJavaVM());
222
        append(buffer, InstallerInfoTags.DOWNLOAD_URL, getDownloadURL());
223
        append(buffer, InstallerInfoTags.STATE, getState());
224
        append(buffer, InstallerInfoTags.OFFICIAL, isOfficial());
225
        append(buffer, InstallerInfoTags.TYPE, getType());
226
        append(buffer, InstallerInfoTags.MODEL_VERSION, getModelVersion());
227

    
228
        return buffer.append(')').toString();
229
    }
230

    
231
    private DefaultPackageInfo append(StringBuffer buffer, String key,
232
        Object value) {
233
        buffer.append("\n\t").append(key).append(": ")
234
            .append(value == null ? "" : value);
235
        return this;
236
    }
237

    
238
    @Override
239
    public Object clone() throws CloneNotSupportedException {
240
        DefaultPackageInfo clone = (DefaultPackageInfo) super.clone();
241
        clone.selectedFiles = new ArrayList<File>(selectedFiles);
242
        return clone;
243
    }
244
}