Mercurial > dive4elements > framework
changeset 358:03a8f9796571
Added interfaces for a Settings hierachy currently used for Outputs.
artifacts/trunk@3408 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 14 Dec 2011 09:41:44 +0000 |
parents | 1d11a0531242 |
children | f93edbfcf2bc |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/state/Attribute.java artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultOutput.java artifact-database/src/main/java/de/intevation/artifactdatabase/state/Output.java artifact-database/src/main/java/de/intevation/artifactdatabase/state/Section.java artifact-database/src/main/java/de/intevation/artifactdatabase/state/Settings.java |
diffstat | 6 files changed, 179 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <ingo@intevation.de> + + * 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 <felix.wolfsteller@intevation.de> * artifact-database/src/main/java/de/intevation/artifactdatabase/state/Facet.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 <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +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 :
--- 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<Facet> facets; + protected Settings settings; + /** * The default constructor that instantiates a new DefaultOutput object. @@ -137,5 +139,17 @@ public void addFacets(List<Facet> 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 :
--- 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<Facet> 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 :
--- /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 <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +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 <i>key</i>. + * + * @param key The key that is used to retrieve the target Attribute. + * + * @return the Attribute specified by <i>key</i>. + */ + Attribute getAttribute(String key); + + /** + * Returns all keys of all Attributes currently stored in this Section. + * + * @return all keys of all Attributes. + */ + Set<String> 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 :
--- /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 <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +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 <i>pos</i>. + * + * @param pos the position of the target Section. + * + * @return the Section at position <i>pos</i> or null if no Section is + * existing at <i>pos</i>. + */ + Section getSection(int pos); + + /** + * Transforms this Settings object into a XML representation. Therefore, + * each Section object's <i>toXML</i> 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 :