diff gnv/src/main/java/de/intevation/gnv/action/mapviewer/parser/XMLExternalCallParser.java @ 953:4b64b4d1f0cf

Add more Javadocs gnv/trunk@1097 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 18 May 2010 07:32:45 +0000
parents 57fa8019fbdc
children 28a0628b11b0
line wrap: on
line diff
--- a/gnv/src/main/java/de/intevation/gnv/action/mapviewer/parser/XMLExternalCallParser.java	Mon May 17 14:21:19 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/mapviewer/parser/XMLExternalCallParser.java	Tue May 18 07:32:45 2010 +0000
@@ -1,24 +1,25 @@
 package de.intevation.gnv.action.mapviewer.parser;
 
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
 import de.intevation.gnv.artifactdatabase.objects.map.DefaultLayer;
 import de.intevation.gnv.artifactdatabase.objects.map.DefaultMapService;
 import de.intevation.gnv.artifactdatabase.objects.map.Layer;
 import de.intevation.gnv.artifactdatabase.objects.map.MapService;
-
 import de.intevation.gnv.util.XMLUtils;
 
-import java.io.InputStream;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.apache.log4j.Logger;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
 /**
+ * This class provides an XMl-Parser which try's to create an DOM from
+ * an given Inputstream. Is this is possible it try to read the required
+ * informations e.g. Mapservices, Layer, SRID and Geometry from the 
+ * document.
  * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
  */
 public class XMLExternalCallParser implements ExternalCallParser {
@@ -37,47 +38,54 @@
     private static String ATTRIBUTE_TYPE = "type";
     private static String ATTRIBUTE_URL = "url";
 
+    /**
+     * The geometry which was parsed from the document.
+     */
     private String geometry = null;
+    
+    /**
+     * The srid which was parsed from the document.
+     */
     private String srs = null;
 
+    /**
+     * The mapservices that were parsed from the document.
+     */
     private Collection<MapService> mapServices = null;
 
+    /**
+     * The inputstream where the data should be read from.
+     */
     private InputStream inputStream = null;
 
     /**
      * Constructor
+     * @param inputStream The stream where the data should be read from
      */
     public XMLExternalCallParser(InputStream inputStream) {
         this.inputStream = inputStream;
     }
 
-    /**
-     * @see de.intevation.gnv.action.mapviewer.parser.ExternalCallParser#getGeometry()
-     */
     public String getGeometry() {
         return this.geometry;
     }
 
-    /**
-     * @see de.intevation.gnv.action.mapviewer.parser.ExternalCallParser#getMapServices()
-     */
     public Collection<MapService> getMapServices() {
         return this.mapServices;
     }
 
-    /**
-     * @see de.intevation.gnv.action.mapviewer.parser.ExternalCallParser#parse()
-     */
     public void parse() throws ExternalCallParserException {
         if (inputStream != null){
             XMLUtils xmlUtils = new XMLUtils();
             Document document = xmlUtils.readDocument(this.inputStream);
             if (document != null){
 
-                this.geometry = xmlUtils.getStringXPath(document, XPATH_GEOMETRY);
+                this.geometry = xmlUtils.getStringXPath(document, 
+                                                        XPATH_GEOMETRY);
                 this.srs = xmlUtils.getStringXPath(document, XPATH_SRS);
                 NodeList mapservicesNodes =
-                      xmlUtils.getNodeSetXPath(document, XPATH_MAPSERVICES_NODESET);
+                      xmlUtils.getNodeSetXPath(document, 
+                                               XPATH_MAPSERVICES_NODESET);
                 if (mapservicesNodes != null){
                     this.mapServices = new ArrayList<MapService>(mapservicesNodes.getLength());
                     for (int i = 0; i < mapservicesNodes.getLength(); i++){
@@ -100,13 +108,15 @@
                     }
 
                 }else{
-                    String errMsg = "XML-Document does not contain any Mapservices which are required.";
+                    String errMsg = "XML-Document does not contain any " +
+                                    "Mapservices which are required.";
                     log.error(errMsg);
                     throw new ExternalCallParserException(errMsg);
                 }
 
             }else{
-                String errMsg = "XML-Document could not be read from InputStream.";
+                String errMsg = "XML-Document could not " +
+                                "be read from InputStream.";
                 log.error(errMsg);
                 throw new ExternalCallParserException(errMsg);
             }
@@ -119,18 +129,21 @@
 
     /**
      * This Method extracts all Layers and put them into the Collection.
-     * @param layer
-     * @param groupId
-     * @param layerNodes
-     * @return
+     * @param layer the collection where the layer should be add to.
+     * @param groupId the id of the group of the layers
+     * @param layerNodes the Nodes which should contain the intormations 
+     *                   about layers
+     * @return the layer
      */
-    private Collection<Layer> extractLayer(Collection<Layer> layer, String groupId, NodeList layerNodes){
-        XMLUtils xmlUtils = new XMLUtils();
+    private Collection<Layer> extractLayer(Collection<Layer> layer, 
+                                           String groupId, 
+                                           NodeList layerNodes){
         for (int i = 0; i < layerNodes.getLength(); i++){
             Element layerNode = (Element)layerNodes.item(i);
             String id = layerNode.getAttribute(ATTRIBUTE_ID);
             String name = layerNode.getAttribute(ATTRIBUTE_NAME);
-            NodeList localLayerNodes = xmlUtils.getNodeSetXPath(layerNode, XPATH_LAYER);
+            NodeList localLayerNodes = XMLUtils.getNodeSetXPath(layerNode, 
+                                                                XPATH_LAYER);
             Layer tmpLayer = new DefaultLayer(id, name,
                                               (localLayerNodes != null &&
                                                localLayerNodes.getLength() > 0),
@@ -143,9 +156,6 @@
         return layer;
     }
 
-    /**
-     * @see de.intevation.gnv.action.mapviewer.parser.ExternalCallParser#getSRS()
-     */
     public String getSRS() {
         return this.srs;
     }

http://dive4elements.wald.intevation.org