org.geotools.data.coverage.grid.stream
Class IOExchange

java.lang.Object
  extended byorg.geotools.data.coverage.grid.stream.IOExchange

public class IOExchange
extends java.lang.Object

This class is used to exchange between different input and output sources and destinations If a format, for example arcgrid, needs a Reader object then IOExchange will create one from the Source object

Author:
jeichar

Method Summary
static int determineSourceFormat(java.lang.Object arg0)
          When implemented this method will determine the format of a source object
 java.io.PrintWriter getGZIPPrintWriter(java.lang.Object destination)
          Returns a PrintWriter that wraps a GZIPOutputStream.
 java.io.Reader getGZIPReader(java.lang.Object source)
          Returns a Reader that wraps a GZIPInputStream.
static IOExchange getIOExchange()
          Factory method for creating a new IOExchange
 java.io.PrintWriter getPrintWriter(java.lang.Object destination)
          Takes a destination object and creates a PrintWriter from it
 java.io.Reader getReader(java.lang.Object source)
          Uses the source object to create a Reader object for client
 java.io.Writer getWriter(java.lang.Object destination)
          Takes a destination object and converts it to it's appropriate subclass of Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getIOExchange

public static IOExchange getIOExchange()
Factory method for creating a new IOExchange

Returns:
an instance of a IOExchange

getReader

public java.io.Reader getReader(java.lang.Object source)
                         throws java.io.IOException
Uses the source object to create a Reader object for client

Parameters:
source - An object that identifies an input Current Implementation accepts: Reader, URL, String, File, InputStream
Returns:
Returns a Reader that reads from the source identified by the source object
Throws:
java.io.IOException - If Source object cannot be identified or if an unexpected problem occurs.

getGZIPReader

public java.io.Reader getGZIPReader(java.lang.Object source)
                             throws java.io.IOException
Returns a Reader that wraps a GZIPInputStream. WARNING. If source is a reader it assumes that the Reader is of the correct type. There is no way to be certain aside from trying to read the data.

Parameters:
source - An object that identifies an input Current Implementation. accepts: Reader, URL, String, File, InputStream Note: if source is a reader it MUST already wrap a GZIPInputStream.
Returns:
Reader that wraps a GZIPInputStream.
Throws:
java.io.IOException - if the destination cannot be converted to a Writer

getWriter

public java.io.Writer getWriter(java.lang.Object destination)
                         throws java.io.IOException
Takes a destination object and converts it to it's appropriate subclass of Writer.

Takes the destination object and casts it to one of: Writer (Returns Writer) OutputStream (Returns OutputStreamWriter) String (Returns OutputStreamWriter) URL (Returns OutputStreamWriter) File (Returns FileWriter) It then constructs a new Writer out of the destination and returns it.

Parameters:
destination - the destination object to be converted
Returns:
a new Writer that can write to the destination
Throws:
java.io.IOException - if the destination cannot be converted to a Writer

getPrintWriter

public java.io.PrintWriter getPrintWriter(java.lang.Object destination)
                                   throws java.io.IOException
Takes a destination object and creates a PrintWriter from it

Parameters:
destination - the destination object to be converted
Returns:
a new PrintWriter that can write to the destination
Throws:
java.io.IOException - if the destination cannot be converted to a Writer

getGZIPPrintWriter

public java.io.PrintWriter getGZIPPrintWriter(java.lang.Object destination)
                                       throws java.io.IOException
Returns a PrintWriter that wraps a GZIPOutputStream. WARNING. If source is a PrintWriter or a Writer it assumes that stream is of the correct type. There is no way to be certain aside from trying to write the data.

Returns:
Writer that wraps a GZIPOutputStream.
Throws:
java.io.IOException - if the destination cannot be converted to a Writer

determineSourceFormat

public static int determineSourceFormat(java.lang.Object arg0)
When implemented this method will determine the format of a source object

Parameters:
arg0 - The source object
Returns:
an integer indicating a particular format


Copyright © GeoTools. All Rights Reserved.