001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.coverage.grid.io;
017:
018: import java.io.IOException;
019: import java.util.logging.Level;
020: import java.util.logging.Logger;
021:
022: import javax.imageio.stream.ImageOutputStream;
023:
024: import org.geotools.factory.Hints;
025: import org.geotools.util.logging.Logging;
026: import org.opengis.coverage.MetadataNameNotFoundException;
027: import org.opengis.coverage.grid.GridCoverageWriter;
028:
029: /**
030: * An {@link AbstractGridCoverageWriter} is the base class for all
031: * {@link GridCoverageWriter} implementations in GeoTools toolkit.
032: *
033: *
034: * <p>
035: * We expect it to become the place where to move functionalities common to all
036: * {@link GridCoverageWriter}.
037: *
038: * @author Simone Giannecchini
039: * @since 2.3.x
040: *
041: */
042: public abstract class AbstractGridCoverageWriter implements
043: GridCoverageWriter {
044:
045: /** The {@link Logger} for this {@link AbstractGridCoverageWriter}. */
046: private final static Logger LOGGER = Logging
047: .getLogger("org.geotools.data.coverage.grid");
048:
049: /** the destination object where we will do the writing */
050: protected Object destination;
051:
052: /** Hints to be used for the writing process. */
053: protected Hints hints = new Hints(null);
054:
055: /** The destination {@link ImageOutputStream}. */
056: protected ImageOutputStream outStream = null;
057:
058: /**
059: * Default constructor for an {@link AbstractGridCoverageWriter}.
060: */
061:
062: public AbstractGridCoverageWriter() {
063:
064: }
065:
066: /**
067: * Releases resources held by this {@link AbstractGridCoverageWriter}.
068: */
069: public void dispose() {
070: if (outStream != null) {
071: try {
072: outStream.flush();
073: outStream.close();
074:
075: } catch (IOException e) {
076: if (LOGGER.isLoggable(Level.FINE))
077: LOGGER.log(Level.FINE, e.getLocalizedMessage(), e);
078:
079: }
080: }
081:
082: }
083:
084: /**
085: * (non-Javadoc)
086: *
087: * @see org.opengis.coverage.grid.GridCoverageWriter#getDestination()
088: */
089: public final Object getDestination() {
090: return destination;
091: }
092:
093: /**
094: * Implementation of getMetadataNames. Currently unimplemented because it
095: * has not been specified where to retrieve the metadata
096: *
097: * @return null
098: *
099: * @see org.opengis.coverage.grid.GridCoverageWriter#getMetadataNames()
100: */
101: public String[] getMetadataNames() {
102: throw new UnsupportedOperationException("Unsupported method");
103: }
104:
105: /**
106: * @see org.opengis.coverage.grid.GridCoverageWriter#setCurrentSubname(java.lang.String)
107: */
108: public void setCurrentSubname(String name) throws IOException {
109: throw new UnsupportedOperationException("Unsupported method");
110: }
111:
112: /**
113: * @see org.opengis.coverage.grid.GridCoverageWriter#setMetadataValue(java.lang.String,
114: * java.lang.String)
115: */
116: public void setMetadataValue(String name, String value)
117: throws IOException, MetadataNameNotFoundException {
118: throw new UnsupportedOperationException("Unsupported method");
119: }
120:
121: }
|