ucar.nc2.iosp.bufr
Class Message

java.lang.Object
  extended by ucar.nc2.iosp.bufr.Message

public class Message
extends Object

Encapsolates a complete BUFR message. A message has a DataDescriptor and one or more "datasets" aka "data subsets" aka "observations" aka "obs".

Since:
May 9, 2008
Author:
caron

Field Summary
 BufrDataSection dataSection
           
 BufrDataDescriptionSection dds
           
 BufrIdentificationSection ids
           
 BufrIndicatorSection is
           
 
Constructor Summary
Message(RandomAccessFile raf, BufrIndicatorSection is, BufrIdentificationSection ids, BufrDataDescriptionSection dds, BufrDataSection dataSection, GregorianCalendar cal)
           
 
Method Summary
 int calcTotalBits(Formatter out)
           
 void close()
           
 void dump(Formatter out)
           
 void dumpHeader(Formatter out)
           
 void dumpHeaderShort(Formatter out)
           
 boolean equals(Object obj)
          BufrMessage is equal if they have the same dds.
 String extractWMO()
           
 BitCounterUncompressed getBitCounterUncompressed(int obsOffsetInMessage)
          Get the offset of this obs from the start of the message data.
 String getCategoryFullName()
           
 String getCategoryName()
           
 String getCategoryNo()
           
 String getCenterName()
           
 String getCenterNo()
           
 int getCountedDataBits()
           
 int getCountedDataBytes()
           
 String getHeader()
           
 long getMessageSize()
          Get the byte length of the entire BUFR record.
 int getNumberDatasets()
          Get number of datasets in this message.
 byte[] getRawBytes()
           
 Date getReferenceTime()
           
 DataDescriptor getRootDataDescriptor()
          Get the root of the DataDescriptor tree.
 long getStartPos()
           
 TableLookup getTableLookup()
           
 String getTableName()
           
 int getTotalBits()
          This is the total number of bits taken by the data in the data section of the message.
 int hashCode()
          Override hashcode to be consistent with equals.
 boolean isBitCountOk()
           
 boolean isTablesComplete()
          Check if all descriptors were found in the tables.
 void setHeader(String header)
           
 void setRawBytes(byte[] raw)
           
 void setStartPos(long startPos)
           
 void showMissingFields(Formatter out)
           
 boolean usesLocalTable()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

is

public BufrIndicatorSection is

ids

public BufrIdentificationSection ids

dds

public BufrDataDescriptionSection dds

dataSection

public BufrDataSection dataSection
Constructor Detail

Message

public Message(RandomAccessFile raf,
               BufrIndicatorSection is,
               BufrIdentificationSection ids,
               BufrDataDescriptionSection dds,
               BufrDataSection dataSection,
               GregorianCalendar cal)
        throws IOException
Throws:
IOException
Method Detail

close

public void close()
           throws IOException
Throws:
IOException

getNumberDatasets

public int getNumberDatasets()
Get number of datasets in this message.

Returns:
number of datasets in this message

getCategoryName

public String getCategoryName()

getCategoryNo

public String getCategoryNo()

getCenterName

public String getCenterName()

getCenterNo

public String getCenterNo()

getTableName

public String getTableName()

getReferenceTime

public final Date getReferenceTime()

setHeader

public void setHeader(String header)

getHeader

public String getHeader()

setStartPos

public void setStartPos(long startPos)

getStartPos

public long getStartPos()

setRawBytes

public void setRawBytes(byte[] raw)

getRawBytes

public byte[] getRawBytes()

extractWMO

public String extractWMO()

getMessageSize

public long getMessageSize()
Get the byte length of the entire BUFR record.

Returns:
length in bytes of BUFR record

getRootDataDescriptor

public DataDescriptor getRootDataDescriptor()
                                     throws IOException
Get the root of the DataDescriptor tree.

Returns:
root DataDescriptor
Throws:
IOException - on read error

usesLocalTable

public boolean usesLocalTable()
                       throws IOException
Throws:
IOException

isTablesComplete

public boolean isTablesComplete()
                         throws IOException
Check if all descriptors were found in the tables.

Returns:
true if all dds were found.
Throws:
IOException - on read error

showMissingFields

public void showMissingFields(Formatter out)
                       throws IOException
Throws:
IOException

getTableLookup

public TableLookup getTableLookup()

isBitCountOk

public boolean isBitCountOk()
                     throws IOException
Throws:
IOException

getCountedDataBytes

public int getCountedDataBytes()

getCountedDataBits

public int getCountedDataBits()

getBitCounterUncompressed

public BitCounterUncompressed getBitCounterUncompressed(int obsOffsetInMessage)
Get the offset of this obs from the start of the message data. Use only for non compressed data

Parameters:
obsOffsetInMessage - index of obs in the message
Returns:
offset in bits

public int getBitOffset(int obsOffsetInMessage) { if (dds.isCompressed()) throw new IllegalArgumentException("cant call BufrMessage.getBitOffset() on compressed message");

if (!root.isVarLength) return root.total_nbits * obsOffsetInMessage;

getTotalBits(); // make sure its been set return nestedTableCounter[obsOffsetInMessage].getStartBit(); }


getTotalBits

public int getTotalBits()
This is the total number of bits taken by the data in the data section of the message. This is the counted number.

Returns:
total number of bits

calcTotalBits

public int calcTotalBits(Formatter out)

hashCode

public int hashCode()
Override hashcode to be consistent with equals.

Overrides:
hashCode in class Object
Returns:
the hash code of dds.getDescriptors()

equals

public boolean equals(Object obj)
BufrMessage is equal if they have the same dds.

Overrides:
equals in class Object
Parameters:
obj - other BufrMessage
Returns:
true if equals

dump

public void dump(Formatter out)
          throws IOException
Throws:
IOException

getCategoryFullName

public String getCategoryFullName()
                           throws IOException
Throws:
IOException

dumpHeader

public void dumpHeader(Formatter out)

dumpHeaderShort

public void dumpHeaderShort(Formatter out)


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.