# HG changeset patch # User Ingo Weinzierl # Date 1323855704 0 # Node ID 03a8f9796571e5032b5ae2d3a97f917d8660af6b # Parent 1d11a053124232844422bfeb8988fe511e4928a1 Added interfaces for a Settings hierachy currently used for Outputs. artifacts/trunk@3408 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 1d11a0531242 -r 03a8f9796571 ChangeLog --- a/ChangeLog Fri Dec 09 16:03:19 2011 +0000 +++ b/ChangeLog Wed Dec 14 09:41:44 2011 +0000 @@ -1,3 +1,30 @@ +2011-12-14 Ingo Weinzierl + + * artifact-database/src/main/java/de/intevation/artifactdatabase/state/Settings.java: + An interface that describes a flat API for specifying settings for + something. A Settings object can store one or more Section instances and + defines a toXML() operation that should append a XML representation of + itself to a given parent Node. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/state/Section.java: + This interface is used to describe an API for storing and retrieving + Attribute objects. Just as the Settings interface, it defines a toXML() + operation that should append a XML representation of itself to a given + parent Node. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/state/Attribute.java: + The interface for concrete attributes in a Section instance. An Attribute + is the placed on the lowest level of the Settings hierachy and should be + used to save concrete key value pairs. Even the Attribute defines the + toXML() operation described above. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/state/Output.java: + Added a getSettings() and setSettings(Settings) operation. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultOutput.java: + A DefaultOutput is now able to store a Settings instance. It implements + getSettings() and setSettings(Settings) defined in the Output interface. + 2011-12-09 Felix Wolfsteller * artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.java, diff -r 1d11a0531242 -r 03a8f9796571 artifact-database/src/main/java/de/intevation/artifactdatabase/state/Attribute.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Attribute.java Wed Dec 14 09:41:44 2011 +0000 @@ -0,0 +1,34 @@ +package de.intevation.artifactdatabase.state; + +import java.io.Serializable; + +import org.w3c.dom.Node; + + +/** + * @author Ingo Weinzierl + */ +public interface Attribute extends Serializable { + + /** + * Returns the name of this Attribute. + * + * @return the name of this Attribute. + */ + String getName(); + + /** + * Returns the value of this Attribute. + * + * @return the value of this Attribute. + */ + Object getValue(); + + /** + * Transforms this Attribute into XML. + * + * @param parent The parent node. + */ + void toXML(Node parent); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 1d11a0531242 -r 03a8f9796571 artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultOutput.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultOutput.java Fri Dec 09 16:03:19 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultOutput.java Wed Dec 14 09:41:44 2011 +0000 @@ -20,6 +20,8 @@ protected List facets; + protected Settings settings; + /** * The default constructor that instantiates a new DefaultOutput object. @@ -137,5 +139,17 @@ public void addFacets(List facets) { this.facets.addAll(facets); } + + + @Override + public void setSettings(Settings settings) { + this.settings = settings; + } + + + @Override + public Settings getSettings() { + return settings; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 1d11a0531242 -r 03a8f9796571 artifact-database/src/main/java/de/intevation/artifactdatabase/state/Output.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Output.java Fri Dec 09 16:03:19 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Output.java Wed Dec 14 09:41:44 2011 +0000 @@ -57,5 +57,17 @@ * @param facets A list of facets. */ public void addFacets(List facets); + + /** + * Returns a Settings object for this Output. + */ + public Settings getSettings(); + + /** + * Sets the Settings for this Output. + * + * @param settings the Settings for this Output. + */ + public void setSettings(Settings settings); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 1d11a0531242 -r 03a8f9796571 artifact-database/src/main/java/de/intevation/artifactdatabase/state/Section.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Section.java Wed Dec 14 09:41:44 2011 +0000 @@ -0,0 +1,46 @@ +package de.intevation.artifactdatabase.state; + +import java.io.Serializable; +import java.util.Set; + +import org.w3c.dom.Node; + + +/** + * @author Ingo Weinzierl + */ +public interface Section extends Serializable { + + /** + * Adds a new Attribute to this Section. + * + * @param key The key that is used to store/retrieve the Attribute. + * @param attribute The new Attribute. + */ + void addAttribute(String key, Attribute attribute); + + /** + * Returns an Attribute for the specified key. + * + * @param key The key that is used to retrieve the target Attribute. + * + * @return the Attribute specified by key. + */ + Attribute getAttribute(String key); + + /** + * Returns all keys of all Attributes currently stored in this Section. + * + * @return all keys of all Attributes. + */ + Set getKeys(); + + /** + * Transforms this Section into XML using Attribute.toXML() for each + * Attribute stored in this Section. + * + * @param parent The parent node. + */ + void toXML(Node parent); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 1d11a0531242 -r 03a8f9796571 artifact-database/src/main/java/de/intevation/artifactdatabase/state/Settings.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/Settings.java Wed Dec 14 09:41:44 2011 +0000 @@ -0,0 +1,46 @@ +package de.intevation.artifactdatabase.state; + +import java.io.Serializable; + +import org.w3c.dom.Node; + + +/** + * @author Ingo Weinzierl + */ +public interface Settings extends Serializable { + + /** + * Adds a new Section to this Settings object. + * + * @param section the new Section. + */ + void addSection(Section section); + + /** + * Returns the number of Sections in this Settings object. + * + * @return the number of sections. + */ + int getSectionCount(); + + /** + * Returns the section at position pos. + * + * @param pos the position of the target Section. + * + * @return the Section at position pos or null if no Section is + * existing at pos. + */ + Section getSection(int pos); + + /** + * Transforms this Settings object into a XML representation. Therefore, + * each Section object's toXML method is called to append its XML + * representation to the final document. + * + * @param parent The parent node. + */ + void toXML(Node parent); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :