001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.wms;
006:
007: import org.vfny.geoserver.ServiceException;
008: import java.io.IOException;
009: import java.io.OutputStream;
010:
011: /**
012: * Provides the skeleton for producers of map image, as required by the
013: * GetMap WMS request.
014: *
015: * <p>
016: * To incorporate a new producer specialized in one or many output formats,
017: * there must be a {@linkplain org.vfny.geoserver.wms.responses.GetMapProducerFactorySpi} registered
018: * that can provide instances of that concrete implementation.
019: * </p>
020: *
021: * <p>
022: * The methods defined in this interface respects the general parse
023: * request/produce response/get mime type/write content workflow, so they
024: * should raise an exception if are called in the wrong order (which is
025: * produceMap -> getContentType -> writeTo)
026: * </p>
027: *
028: * @author Gabriel Roldan, Axios Engineering
029: * @author Simone Giannecchini, GeoSolutions
030: * @version $Id: GetMapProducer.java 7467 2007-08-28 22:29:03Z afabiani $
031: */
032: public interface GetMapProducer {
033: /**
034: * Asks this map producer to create a map image for the passed {@linkPlain
035: * WMSMapContext}, which contains enough information for doing such a
036: * process.
037: *
038: *
039: * @throws WmsException something goes wrong
040: */
041: void produceMap() throws WmsException;
042:
043: /**
044: * Writes the map created in produceMap to the destination stream, though
045: * it could be used to encode the map to the proper output format,
046: * provided that there are almost no risk that the encoding fails.
047: *
048: * @param out an open stream where to send the produced legend graphic to.
049: *
050: * @throws ServiceException if something else goes wrong.
051: * @throws IOException if something goes wrong in the actual process of
052: * writing content to <code>out</code>.
053: */
054: void writeTo(OutputStream out) throws ServiceException, IOException;
055:
056: /**
057: * asks the legend graphic producer to stop processing since it will be no
058: * longer needed (for example, because the request was interrupted by the
059: * user)
060: */
061: void abort();
062:
063: /**
064: * Sets the {@link MapContext} for this MapProducer.
065: *
066: * @param mapContext
067: * to use for producing a map.
068: */
069: public void setMapContext(WMSMapContext mapContext);
070:
071: /**
072: * Gets the {@link MapContext} for this MapProducer.
073: *
074: * @return the {@link WMSMapContext} for this map producer.
075: */
076: public WMSMapContext getMapContext();
077:
078: /**
079: * Returns the MIME type of the content to be written at
080: * <code>writeTo(OutputStream)</code>
081: *
082: * @return the output format
083: */
084: public String getContentType()
085: throws java.lang.IllegalStateException;
086:
087: /**
088: * Sets the MIME Type to be used for this {@link GetMapProducer}.
089: *
090: */
091: public void setContentType(String mime);
092:
093: /**
094: * Gets the output map type of the output image.
095: *
096: * @return the desired output map format.
097: */
098: public String getOutputFormat();
099:
100: /**
101: * Sets the MIME type of the output image.
102: *
103: * @param format
104: * the desired output map format.
105: */
106: public void setOutputFormat(String format);
107:
108: /**
109: * The content disposition is the file name of the returned result. If there
110: * is no file name, null is returned. The returned string should be in the
111: * form: "inline; filename=name.ext" You need the "inline;" prefix and the
112: * filename can be whatever you want. An example would be: "inline;
113: * filename=states.pdf"
114: *
115: * @return Header information for setting the file name
116: */
117: String getContentDisposition();
118: }
|