net.sourceforge.jgrib
Class GribFile

Object
  extended by GribFile

public final class GribFile
extends Object

A class that represents a GRIB file. It consists of a number of records which are represented by GribRecord objects.

Author:
Simone Giannecchini, Benjamin Stark, Peter Gylling 2002-04-16

Nested Class Summary
static class GribFile.AccessType
          Access type enumeration.
 
Field Summary
static int DEF_RECORDS
          Default number of records.
 
Method Summary
 void addRecord(GribRecord rec)
           
 void addRecord(GribRecord rec, int pos)
          addRecord
static boolean canDecodeInput(Object input)
          The goal of this method is to check the provided object to see if it can be decoded as a GribFile.
 void clean()
          clean, cleans the GribFile from anything it contains.
 void dispose()
          Release all the used resource for this grib file.
 boolean equals(Object obj)
          DO NOT USE THIS ONE
 Object getOriginatingSource()
           
 GribRecord getRecord(int i)
          Get a specific GRIB record of this GRIB file as GribRecord object.
 int getRecordCount()
          Get the number of records this GRIB file contains.
static GribFile open(Object source, GribFile.AccessType accessType)
           
 void parseGribFile()
          Parse a GribFile.
 boolean removeRecord(int pos)
          This method is responsible for removing a record from the record map.
 void writeTo(OutputStream out)
          writeTo
 
Methods inherited from class Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_RECORDS

public static final int DEF_RECORDS
Default number of records.

See Also:
Constant Field Values
Method Detail

parseGribFile

public void parseGribFile()
                   throws IOException
Parse a GribFile.

Throws:
IOException - if stream can not be opened etc.
NotSupportedException - DOCUMENT ME!
NoValidGribException - if stream does not contain a valid GRIB file

getRecord

public GribRecord getRecord(int i)
                     throws NoSuchElementException,
                            IndexOutOfBoundsException
Get a specific GRIB record of this GRIB file as GribRecord object.

Parameters:
i - number of GRIB record, first record is number 1
Returns:
GRIB record object
Throws:
NoSuchElementException - if record number does not exist
IndexOutOfBoundsException - if JGrib doesn't yet support the operation

getRecordCount

public int getRecordCount()
Get the number of records this GRIB file contains.

Returns:
number of records in this GRIB file

writeTo

public void writeTo(OutputStream out)
             throws NoSuchElementException,
                    IOException
writeTo

Parameters:
out - OutputStream
Throws:
NoSuchElementException - DOCUMENT ME!
IOException - DOCUMENT ME!

equals

public boolean equals(Object obj)
DO NOT USE THIS ONE

Overrides:
equals in class Object
Parameters:
obj - Object
Returns:
boolean

clean

public void clean()
clean, cleans the GribFile from anything it contains. We might use this method to clean a file before adding new records


addRecord

public void addRecord(GribRecord rec)

addRecord

public void addRecord(GribRecord rec,
                      int pos)
addRecord

Parameters:
rec - GribRecord
pos - DOCUMENT ME!
Throws:
IndexOutOfBoundsException - DOCUMENT ME!

removeRecord

public boolean removeRecord(int pos)
This method is responsible for removing a record from the record map. A GribFile is made of a certain number of records.

Parameters:
pos - int The position of the record to be removed
Returns:
boolean True if the record was found and remove, false otherwise.

canDecodeInput

public static boolean canDecodeInput(Object input)
The goal of this method is to check the provided object to see if it can be decoded as a GribFile. The avalaible options for the input object are:
    • A File object.
        A String object which contain a path to a file or a URL.
          A URL object.
            An object of an ImageInputStream's subclass.
          • The check for compatibility is pretty simple at this stage in order to keep things as simple as possible. We just look for the opening string 'GRIB' and the closing string '777' which have to come in ordered pairs (see the GRIB edition 2 specification on the web).

            Parameters:
            input - The provided object to be checked for decodeability.
            Returns:
            True if decodeable, false otherwise.

  • open

    public static GribFile open(Object source,
                                GribFile.AccessType accessType)
                         throws FileNotFoundException,
                                IOException
    Throws:
    FileNotFoundException
    IOException

    dispose

    public void dispose()
    Release all the used resource for this grib file.


    getOriginatingSource

    public Object getOriginatingSource()
    Returns:
    the originatingSource
    UML property:
    name="originatingSource"


    Copyright © 2006-2010 GeoSolutions. All Rights Reserved.