changeset 771:a0e63136954e

Added and repaired javadoc in de.intevation.gnv.exports package. gnv-artifacts/trunk@827 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 25 Mar 2010 09:01:14 +0000
parents d70cac2bafc0
children cd64ab8a46a7
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/exports/ChartExportHelper.java gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultDataCollector.java gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultExport.java gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultProfile.java gnv-artifacts/src/main/java/de/intevation/gnv/exports/Export.java gnv-artifacts/src/main/java/de/intevation/gnv/exports/ODVExport.java gnv-artifacts/src/main/java/de/intevation/gnv/exports/ShapeDataCollector.java gnv-artifacts/src/main/java/de/intevation/gnv/exports/SimpleOdvDataCollector.java
diffstat 9 files changed, 428 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Wed Mar 24 15:32:07 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Thu Mar 25 09:01:14 2010 +0000
@@ -1,3 +1,15 @@
+2010-03-25  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/java/de/intevation/gnv/exports/Export.java,
+	  src/main/java/de/intevation/gnv/exports/ShapeDataCollector.java,
+	  src/main/java/de/intevation/gnv/exports/ChartExportHelper.java,
+	  src/main/java/de/intevation/gnv/exports/SimpleOdvDataCollector.java,
+	  src/main/java/de/intevation/gnv/exports/DefaultDataCollector.java,
+	  src/main/java/de/intevation/gnv/exports/DefaultProfile.java,
+	  src/main/java/de/intevation/gnv/exports/DefaultExport.java,
+	  src/main/java/de/intevation/gnv/exports/ODVExport.java: Added javadoc and
+	  turned javadoc author tag into a 'mailto' form.
+
 2010-03-24  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/histogram/HistogramHelper.java: Removed a
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/ChartExportHelper.java	Wed Mar 24 15:32:07 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/ChartExportHelper.java	Thu Mar 25 09:01:14 2010 +0000
@@ -37,15 +37,41 @@
 import org.jfree.chart.JFreeChart;
 
 /**
- * @author Ingo Weinzierl <ingo.weinzierl@intevation.de>
+ * This class is a helper class which supports some methods to export charts
+ * into specific formats.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class ChartExportHelper {
 
+    /**
+     * Constant field to define A4 as default page size.
+     */
     private static final String  DEFAULT_PAGE_SIZE = "A4";
+
+    /**
+     * Constant field to define UTF-8 as default encoding.
+     */
     private static final String  DEFAULT_ENCODING  = "UTF-8";
 
+    /**
+     * Logger used for logging with log4j.
+     */
     private static Logger log = Logger.getLogger(ChartExportHelper.class);
 
+
+    /**
+     * A method to export a <code>JFreeChart</code> as image to an 
+     * <code>OutputStream</code> with a given format, width and height.
+     *
+     * @param out OutputStream
+     * @param JFreeChart Chart to be exported
+     * @param format Format (e.g. png, gif, jpg)
+     * @param width Width, the image used to be
+     * @param height Height, the image used to be
+     *
+     * @throws IOException if writing image to OutputStream failed.
+     */
     public static void exportImage(
         OutputStream out,
         JFreeChart chart,
@@ -67,6 +93,18 @@
     }
 
 
+    /**
+     * A method to export a <code>JFreeChart</code> histogram as image to an
+     * <code>OutputStream</code> with a  given format, width and height.
+     *
+     * @param out OutputStream
+     * @param histograms Array of {@link de.intevation.gnv.chart.Chart} objects
+     * @param format A format (e.g. png, gif, jpg)
+     * @param width Width the image used to be
+     * @param height Height the image used to be
+     *
+     * @throws IOException if writing image to OutputStream failed.
+     */
     public static void exportHistograms(
         OutputStream out,
         Chart[]      histograms,
@@ -92,6 +130,16 @@
     }
 
 
+    /**
+     * A method to export a <code>JFreeChart</code> histogram as SVG to an
+     * <code>OutputStream</code>.
+     * 
+     * @param out OutputStream
+     * @param histograms Array of {@link de.intevation.gnv.chart.Chart}
+     * @param encoding Encoding, defaults to {@link DEFAULT_ENCODING} if null
+     * @param width Width the svg used to be
+     * @param height Height the svg used to be
+     */
     public static void exportHistogramsAsSVG(
         OutputStream out,
         Chart[]      histograms,
@@ -127,6 +175,16 @@
     }
 
 
+    /**
+     * A method to export a <code>JFreeChart</code> as SVG to an
+     * <code>OutputStream</code>.
+     * 
+     * @param out OutputStream
+     * @param chart JFreeChart to be exported
+     * @param encoding Encoding, defaults to {@link DEFAULT_ENCODING} if null
+     * @param width Width the svg used to be
+     * @param height Height the svg used to be
+     */
     public static void exportSVG(
         OutputStream out,
         JFreeChart   chart,
@@ -156,6 +214,21 @@
     }
 
 
+    /**
+     * A method to export a <code>JFreeChart</code> as PDF to an
+     * <code>OutputStream</code>.
+     *
+     * @param out OutputStream
+     * @param chart JFreeChart
+     * @param pageFormat String to specify a page format, {@link
+     * DEFAULT_PAGE_SIZE} is used if no pageFormat is given
+     * @param landscape If this is true, the pdf is delivered in landscape
+     * format
+     * @param marginLeft Space to left border
+     * @param marginRight Space to right border
+     * @param marginTop Space to upper border
+     * @param marginBottom Space to lower border
+     */
     public static void exportPDF(
         OutputStream out,
         JFreeChart   chart,
@@ -220,6 +293,22 @@
     }
 
 
+    /**
+     * A method to export <code>JFreeChart</code> histograms as PDF to an
+     * <code>OutputStream</code>. Each histogram contained in histograms is
+     * drawn to an own page in the resulting pdf.
+     *
+     * @param out OutputStream
+     * @param histograms JFreeChart histograms
+     * @param pageFormat String to specify a page format, {@link
+     * DEFAULT_PAGE_SIZE} is used if no pageFormat is given
+     * @param landscape If this is true, the pdf is delivered in landscape
+     * format
+     * @param marginLeft Space to left border
+     * @param marginRight Space to right border
+     * @param marginTop Space to upper border
+     * @param marginBottom Space to lower border
+     */
     public static void exportHistogramsAsPDF(
         OutputStream out,
         Chart[]      histograms,
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultDataCollector.java	Wed Mar 24 15:32:07 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultDataCollector.java	Thu Mar 25 09:01:14 2010 +0000
@@ -11,25 +11,60 @@
 
 
 /**
- * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ * This is the default implementation of {@link Export.DataCollector}. This
+ * class serves a method to extract required data from <code>Result</code>
+ * objects.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class DefaultDataCollector
 implements Export.DataCollector
 {
+    /**
+     * Logger used to log via log4j.
+     */
     private   Logger log = Logger.getLogger(DefaultDataCollector.class);
 
+    /**
+     * ResultDescriptor used to extract specific attributes from
+     * <code>Result</code> object.
+     */
     protected ResultDescriptor rd;
+
+    /**
+     * Atrribute names in <code>Result</code> object which should be used for
+     * data extraction.
+     */
     protected String []        names;
 
 
+    /**
+     * Constructor
+     *
+     * @param names See {@link #names}
+     */
     public DefaultDataCollector(String[] names) {
         this.names = names;
     }
 
+    /**
+     * This method initializes the <code>ResultDescriptor</code> rd for a faster
+     * data extraction.
+     *
+     * @param res A <code>Result</code> object used to get its description.
+     */
     public void init(Result res) {
         rd = res.getResultDescriptor();
     }
 
+    /**
+     * This method is used to extract the required data specified by {@link
+     * #names}.
+     *
+     * @param result <code>Result</code> object.
+     *
+     * @return Extracted data.
+     */
     public String[] getData(Result result)
     throws StateException {
 
@@ -46,3 +81,4 @@
         return (String[]) entries.toArray((new String[entries.size()]));
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultExport.java	Wed Mar 24 15:32:07 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultExport.java	Thu Mar 25 09:01:14 2010 +0000
@@ -14,20 +14,43 @@
 import de.intevation.gnv.state.exception.StateException;
 
 /**
- * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
- * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ * This class is the default implementation of {@link Export}.
+ *
+ * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class DefaultExport
 implements   Export
 {
+    /**
+     * Logger used for logging via log4j.
+     */
     private static Logger log = Logger.getLogger(DefaultExport.class);
 
+    /**
+     * DataCollector used to extract data from <code>Result</code> objects.
+     */
     protected Export.DataCollector collector;
 
+    /**
+     * Constructor
+     *
+     * @param collector See {@link #collector}
+     */
     public DefaultExport(Export.DataCollector collector) {
         this.collector = collector;
     }
 
+    /**
+     * This method writes data stored in <code>result</code> into a CSV document
+     * using <code>writer</code>.
+     *
+     * @param profile {@link #Profile} used to specify the format and columns.
+     * @param result Collection storing the required data.
+     * @param writer CSVWriter to write the csv document.
+     *
+     * @throws StateException
+     */
     protected void writeData(
         Profile    profile, 
         Collection result,
@@ -48,6 +71,20 @@
         }
     }
 
+    /**
+     * This method takes a data Collection and writes it to
+     * <code>outputStream</code> using the the format specified by
+     * <code>profile</code>.
+     *
+     * @param profile used to specify the format and columns.
+     * @param outputStream OutputStream which is used for writing the export
+     * document to.
+     * @param result Collection storing the data.
+     *
+     * @throws IOException if writing to OutputStream failed.
+     * @throws UnsupportedEncodingException if the encoding was not accepted.
+     * @throws StateException if result is null.
+     */
     public void create(
         Profile      profile,
         OutputStream outputStream, 
@@ -78,3 +115,4 @@
         writer.close();
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultProfile.java	Wed Mar 24 15:32:07 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultProfile.java	Thu Mar 25 09:01:14 2010 +0000
@@ -1,25 +1,71 @@
 package de.intevation.gnv.exports;
 
-
 /**
- * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
- * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ * This class is the default implementation of  {@link Export.Profile} and
+ * serves information about the format used to create an export document.
+ *
+ * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class DefaultProfile
 implements   Export.Profile
 {
+    /**
+     * Used to collect the required data from <code>Result</code> object.
+     */
     protected Export.DataCollector collector;
+
+    /**
+     * Column headers.
+     */
     protected String []            header;
+
+    /**
+     * 
+     */
     protected String []            names;
+
+    /**
+     * Character used to separate columns.
+     */
     protected char                 separator;
+
+    /**
+     * Escape character.
+     */
     protected char                 escapeCharacter;
+
+    /**
+     * Quote character.
+     */
     protected char                 quoteCharacter;
+
+    /**
+     * Format type.
+     */
     protected String               type;
+
+    /**
+     * Encoding used for export.
+     */
     protected String               encoding;
 
-    public DefaultProfile() {
+    /**
+     * Constructor
+     */
+    private DefaultProfile() {
     }
 
+    /**
+     * Constructor
+     *
+     * @param header See {@link #header}
+     * @param separator See {@link #separator}
+     * @param escapeCharacter See {@link #escapeCharacter}
+     * @param quoteCharacter See {@link #quoteCharacter}
+     * @param type See {@link #type}
+     * @param encoding See {@link #encoding}
+     */
     public DefaultProfile(
         String []            header,
         char                 separator,
@@ -36,31 +82,70 @@
         this.encoding        = encoding;
     }
 
+    /**
+     * Returns the given value.
+     *
+     * @param index Index
+     * @param value Value
+     *
+     * @return value
+     */
     public String toString(int index, String value) {
         return value;
     }
 
+    /**
+     * Returns the separator.
+     *
+     * @return Separator
+     */
     public char getSeparator() {
         return separator;
     }
 
+    /**
+     * Returns the escape character.
+     *
+     * @return Escape character
+     */
     public char getEscapeCharacter() {
         return escapeCharacter;
     }
 
+    /**
+     * Returns the quote character.
+     *
+     * @return Quote character.
+     */
     public char getQuoteCharacter() {
         return quoteCharacter;
     }
 
+    /**
+     * Returns the format type.
+     *
+     * @return Type.
+     */
     public String getType() {
         return type;
     }
 
+    /**
+     * Returns the encoding.
+     *
+     * @return Encoding
+     */
     public String getEncoding() {
         return encoding;
     }
 
+    /**
+     * Returns the column headers.
+     *
+     * @return header
+     */
     public String[] getHeader() {
         return header;
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/Export.java	Wed Mar 24 15:32:07 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/Export.java	Thu Mar 25 09:01:14 2010 +0000
@@ -10,26 +10,104 @@
 import de.intevation.gnv.state.exception.StateException;
 
 /**
- * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
- * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ * This interface should be implemented by a class whose instances are intended
+ * to export a <code>Collection</code> of <code>Result</code>s into a specific 
+ * format (e.g. CSV or ODV).
+ *
+ * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public interface Export {
 
+    /**
+     * This interface provides some methods which describe the format used by an
+     * <code>Export</code>.
+     */
     public interface Profile {
         String toString(int column, String value);
+
+        /**
+         * This method serves information about the character used to separate
+         * columns.
+         *
+         * @return Character used to separate
+         */
         char      getSeparator();
+
+        /**
+         * This method serves information about the character used as escape
+         * character.
+         *
+         * @return Escape character
+         */
         char      getEscapeCharacter();
+
+        /**
+         * This method serves informatin about the character used as quote
+         * character.
+         *
+         * @return Quote character
+         */
         char      getQuoteCharacter();
+
+        /**
+         * This method serves information about the format.
+         *
+         * @return Format as string.
+         */
         String    getType();
+
+        /**
+         * This method serves information about the encoding to be used.
+         *
+         * @return Encoding
+         */
         String    getEncoding();
+
+        /**
+         * This method returns the header as array.
+         *
+         * @return Header as string array.
+         */
         String [] getHeader();
     }
 
+    /**
+     * This interface should be implemeted to collect the required data from
+     * <code>Result</code> object.
+     */
     public interface DataCollector {
+
+        /**
+         * This method serves the required data stored in a <code>Result</code>
+         * object.
+         *
+         * @return String[] which contains all required data.
+         *
+         * @throws StateException
+         */
         String[] getData(Result result)
         throws StateException;
     }
 
+    /**
+     * This method creates an export document specified by {@link Profile} which
+     * contains the data stored in <code>result</code> and writes it to
+     * <code>outputStream</code>.
+     *
+     * @param profile Profile used to specify the format of the resulting export
+     * document.
+     * @param outputStream Resulting export document is written to this
+     * OutputStream.
+     * @param result Collection which contains the data used to be written into
+     * the export document.
+     *
+     * @throws IOException if an error occured while writing the export document
+     * to OutputStream
+     * @throws UnsupportedEncodingException if the given encoding is not
+     * accepted
+     * @throws StateException if <code>result</code> is null
+     */
     public void create(
         Profile      profile,
         OutputStream outputStream, 
@@ -38,3 +116,4 @@
     throws IOException, UnsupportedEncodingException, StateException;
 
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/ODVExport.java	Wed Mar 24 15:32:07 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/ODVExport.java	Thu Mar 25 09:01:14 2010 +0000
@@ -1,9 +1,5 @@
-/**
- *
- */
 package de.intevation.gnv.exports;
 
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -19,13 +15,21 @@
 
 
 /**
- * @author Tim Englich <tim.englich@intevation.de>
+ * This class is used to create a specific export document which is similar to
+ * an CSV document.
  *
+ * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
  */
 public class ODVExport extends DefaultExport {
 
+    /**
+     * Logger used for logging via log4j.
+     */
     private static Logger log = Logger.getLogger(ODVExport.class);
     
+    /**
+     * Collection of parameters.
+     */
     private Collection parameters = null;
     
     /**
@@ -37,6 +41,10 @@
         this.parameters = parameters;
     }
 
+    /**
+     * @see de.intevation.gnv.exports.Export#writeData(Profile, Collection,
+     * CSVWriter)
+     */
     @Override
     protected void writeData(Profile profile, Collection result,
                              CSVWriter writer) throws StateException {
@@ -102,6 +110,15 @@
         }
     }
     
+    /**
+     * This method is used to search specific value coresponding to its key
+     * <code>id</code> and return its description.
+     *
+     * @param values Collection of parameters.
+     * @param id Key used to find the value.
+     *
+     * @return Description of searched value.
+     */
     protected String findParamTitle(Collection values, String id) {
         log.debug("find description of dataset");
 
@@ -119,3 +136,4 @@
     
 
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/ShapeDataCollector.java	Wed Mar 24 15:32:07 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/ShapeDataCollector.java	Thu Mar 25 09:01:14 2010 +0000
@@ -11,19 +11,40 @@
 
 
 /**
- * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ * This class is a specialization of {@link #DefaultDataCollector}. The
+ * difference between these classes is, that this class extracts points served
+ * by a wkt string.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class ShapeDataCollector
 extends DefaultDataCollector
 {
+    /**
+     * Logger used for logging with log4j.
+     */
     private Logger log = Logger.getLogger(ShapeDataCollector.class);
 
+    /**
+     * WKTReader to parse points from wkt strings.
+     */
     protected WKTReader wktReader = new WKTReader();
 
+    /**
+     * Constructor
+     *
+     * @param names Attributes used to be extracted.
+     */
     public ShapeDataCollector(String[] names) {
         super(names);
     }
 
+    /**
+     * This method takes point from wkt strings as well and split them into x
+     * and y coordinate.
+     *
+     * @see de.intevation.gnv.exports.Export.DataCollector#getData(Result)
+     */
     public String[] getData(Result result) 
     throws StateException {
 
@@ -55,3 +76,4 @@
         }
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/SimpleOdvDataCollector.java	Wed Mar 24 15:32:07 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/SimpleOdvDataCollector.java	Thu Mar 25 09:01:14 2010 +0000
@@ -13,23 +13,54 @@
 import de.intevation.gnv.state.exception.StateException;
 
 /**
- * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ * This class is a specialization of {@link ShapeDataCollector} and turns
+ * furthermore a given datetime string into a specific format.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class SimpleOdvDataCollector
 extends ShapeDataCollector
 {
+    /**
+     * Logger used for logging with log4j.
+     */
     private static Logger log = Logger.getLogger(SimpleOdvDataCollector.class);
 
+    /**
+     * Constant field which defines the source format of a given datetime.
+     */
     public static final String SRC_FORMAT  = "yyyy.MM.dd HH:mm:ss";
+
+    /**
+     * Constant field which defines the target format of a given datetime.
+     */
     public static final String DEST_FORMAT = "yyyy-MM-dd HH:mm";
 
+    /**
+     * Source format.
+     */
     public static DateFormat srcFormat  = new SimpleDateFormat(SRC_FORMAT);
+
+    /**
+     * Target format.
+     */
     public static DateFormat destFormat = new SimpleDateFormat(DEST_FORMAT);
 
+    /**
+     * Constructor
+     *
+     * @param names See {@link #names}
+     */
     public SimpleOdvDataCollector(String[] names) {
         super(names);
     }
 
+    /**
+     * Given datetime values which corresponds to the attribute key 'TIMEVALUE'
+     * are transformed from {@link #SRC_FORMAT} into {@link #DEST_FORMAT}.
+     *
+     * @see de.intevation.gnv.exports.Export.DataCollector#getData(Result)
+     */
     public String[] getData(Result result)
     throws StateException
     {
@@ -72,3 +103,4 @@
         }
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org