1 |
package skrueger.geotools.io; |
2 |
|
3 |
import java.net.MalformedURLException; |
4 |
import java.util.HashMap; |
5 |
|
6 |
public abstract class ServerSettings<T1, T2> extends HashMap<T1, T2> { |
7 |
|
8 |
abstract public String toPropertiesString(); |
9 |
|
10 |
static Integer intOrNull(String string) { |
11 |
if (string == null) |
12 |
return null; |
13 |
if (string.equals("null")) |
14 |
return null; |
15 |
return Integer.parseInt(string); |
16 |
} |
17 |
|
18 |
/** |
19 |
* Character used to separate the parameters when serializing settings to a |
20 |
* String |
21 |
*/ |
22 |
protected static final String DELIMITER = "|"; |
23 |
|
24 |
private String title; |
25 |
|
26 |
static String stringOrNull(String string) { |
27 |
if (string == null) |
28 |
return null; |
29 |
if (string.equals("null")) |
30 |
return null; |
31 |
return string; |
32 |
} |
33 |
|
34 |
public void setTitle(String title) { |
35 |
if (title != null) { |
36 |
if (title.contains(DELIMITER)) |
37 |
throw new IllegalArgumentException("Title may not contain " |
38 |
+ DELIMITER); |
39 |
if (title.contains(WfsServerList.DELIMITER)) |
40 |
throw new IllegalArgumentException("Title may not contain " |
41 |
+ WfsServerList.DELIMITER); |
42 |
} |
43 |
this.title = title; |
44 |
} |
45 |
|
46 |
public String getTitle() { |
47 |
if (title == null) |
48 |
return toString(); |
49 |
return title; |
50 |
} |
51 |
|
52 |
abstract public boolean parsePropertiesString(String propString) |
53 |
throws MalformedURLException ; |
54 |
|
55 |
} |