view src/java/de/intevation/mxd/reader/GdbRasterCatalogLayerReader.java @ 43:ef7ca23c4233

Added comments, done some code styling and removed typos.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 15 Apr 2011 15:44:54 +0200
parents 472aa36d0e01
children 7eba97e8201b
line wrap: on
line source
package de.intevation.mxd.reader;

import java.io.IOException;

import org.apache.log4j.Logger;

import com.esri.arcgis.carto.ILayer;
import com.esri.arcgis.carto.GdbRasterCatalogLayer;

import org.w3c.dom.Element;

import de.intevation.mxd.utils.MapToXMLUtils;

/**
 * Reads Layer information.
 *
 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
 */
public class GdbRasterCatalogLayerReader
implements ILayerReader {

    /**
     * The logger.
     */
    private static final Logger logger =
        Logger.getLogger(GdbRasterCatalogLayerReader.class);

    /**
     * Privte member.
     */
    private GdbRasterCatalogLayer  layer;
    private MapToXMLUtils util;


    public GdbRasterCatalogLayerReader(ILayer layer)
    throws Exception {
        if(layer instanceof GdbRasterCatalogLayer) {
            this.layer = (GdbRasterCatalogLayer)layer;
        }
        else {
            throw new Exception("Not an instance of GdbRastaCatalogLayer: " +
                layer.getClass().toString());
        }
    }

    /**
     * Setter for XML document helper.
     *
     * @param util The helper for storing map information.
     */
    public void setUtil(MapToXMLUtils util) {
        this.util = util;
    }

    /**
     * Reads the Layer content.
     *
     * @return The layer XML element.
     */
    public Element read()
    throws IOException {
        logger.debug("read()");
        Element layerElement;
        try {
            layerElement = util.addLayer();
        }
        catch(Exception e) {
            e.printStackTrace();
            return null;
        }

        layerElement.setAttribute("name", layer.getName());
        layerElement.setAttribute("min_scale",
            String.valueOf(layer.getMinimumScale()));
        layerElement.setAttribute("max_scale",
            String.valueOf(layer.getMaximumScale()));
        if(layer.isVisible()) {
            layerElement.setAttribute("status", "on");
        }
        else {
            layerElement.setAttribute("status", "off");
        }

        layerElement.setAttribute("definition_query",
            layer.getDefinitionExpression());

        return layerElement;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)