/[schmitzm]/trunk/src/skrueger/geotools/io/GsServerSettings.java
ViewVC logotype

Annotation of /trunk/src/skrueger/geotools/io/GsServerSettings.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1295 - (hide annotations)
Mon Nov 22 15:09:59 2010 UTC (14 years, 3 months ago) by alfonx
File MIME type: text/plain
File size: 2105 byte(s)
Refactored ServerSettings and ServerList classes in schmitzm for more usablility ;-)
1 alfonx 1291 package skrueger.geotools.io;
2    
3     import java.util.HashMap;
4 alfonx 1295 import java.util.regex.Pattern;
5 alfonx 1291
6 alfonx 1295 import org.apache.commons.lang.StringUtils;
7     import org.jfree.util.Log;
8    
9 alfonx 1291 /**
10 alfonx 1295 * This class describes all settings needed to connect to a Geoserver server via
11     * REST configuration. This class extends a {@link HashMap} and contains two
12     * groups of keys:<br/>
13     * The first group of keys, are all keys provided by Geotools to create a WFS <br/>
14 alfonx 1291 * This class can serialize all important parameters needed to define the
15     * connection into a {@link String} with {@link #toPropertiesString()} and
16     * re-import the String with {@link #parsePropertiesString(String)}.
17     */
18 alfonx 1295 public class GsServerSettings extends AbstractGTServerSettings<Void, Void> {
19 alfonx 1291
20 alfonx 1295 public GsServerSettings() {
21 alfonx 1291 }
22    
23 alfonx 1295 public GsServerSettings(String s) {
24     super(s);
25     }
26    
27 alfonx 1291 @Override
28 alfonx 1295 public boolean parsePropertiesString(String propString) {
29     if (propString == null || propString.isEmpty())
30     return false;
31     try {
32    
33     String[] split = propString.split(Pattern.quote(DELIMITER));
34    
35     int i = 0;
36     setUrl(split[i++]);
37     setTitle(split[i++]);
38     setUsername(StringUtils.stripToNull(split[i++]));
39     setPassword(split[i++]);
40    
41     return true;
42     } catch (Exception e) {
43     Log.warn("couldn't parse " + propString, e);
44     return false;
45     }
46 alfonx 1291 }
47    
48     String url;
49 alfonx 1295
50 alfonx 1291 public String getUrl() {
51     return url;
52     }
53    
54     public void setUrl(String url) {
55     this.url = url;
56     }
57    
58     public String getUsername() {
59     return username;
60     }
61    
62     public void setUsername(String username) {
63     this.username = username;
64     }
65    
66     public String getPassword() {
67     return password;
68     }
69    
70     public void setPassword(String password) {
71     this.password = password;
72     }
73    
74     String username;
75     String password;
76    
77 alfonx 1295 @Override
78     public String toPropertiesString() {
79     StringBuffer serialized = new StringBuffer(100);
80    
81     serialized.append(getUrl());
82     serialized.append(DELIMITER);
83    
84     serialized.append(getTitle());
85     serialized.append(DELIMITER);
86    
87     serialized.append(getUsername());
88     serialized.append(DELIMITER);
89    
90     serialized.append(getPassword());
91     serialized.append(DELIMITER);
92    
93     return serialized.toString();
94     }
95 alfonx 1291 }

Properties

Name Value
svn:mime-type text/plain

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26