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