Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultSettings.java @ 375:33176e6e3c37
Added Override annotations.
artifacts/trunk@3909 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 03 Feb 2012 16:04:09 +0000 |
parents | f93edbfcf2bc |
children | ab3900303f25 |
rev | line source |
---|---|
359
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.artifactdatabase.state; |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import org.w3c.dom.Document; |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.w3c.dom.Element; |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Node; |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifactdatabase.state.Section; |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifactdatabase.state.Settings; |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 /** |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 */ |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 public class DefaultSettings implements Settings { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 protected List<Section> sections; |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 public DefaultSettings() { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 sections = new ArrayList<Section>(); |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 @Override |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 public void addSection(Section section) { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 if (section != null) { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 sections.add(section); |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 @Override |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 public int getSectionCount() { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 return sections.size(); |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 @Override |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 public Section getSection(int pos) { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 if (pos >= 0 && pos < getSectionCount()) { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 return sections.get(pos); |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 return null; |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 @Override |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 public void removeSection(Section section) { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 if (section != null) { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 sections.remove(section); |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 @Override |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 public void toXML(Node parent) { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 Document owner = parent.getOwnerDocument(); |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 Element settings = owner.createElement("settings"); |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 parent.appendChild(settings); |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 for (Section section: sections) { |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 section.toXML(settings); |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 } |
f93edbfcf2bc
Improved the Settings and Section interfaces and added default implementations for both.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |