Package ucar.nc2.iosp.bufr
Class Message
- java.lang.Object
-
- 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". Table lookup is done through getLookup().
-
-
Field Summary
Fields Modifier and Type Field Description BufrDataSectiondataSectionBufrDataDescriptionSectionddsBufrIdentificationSectionidsBufrIndicatorSectionis
-
Constructor Summary
Constructors Constructor Description Message(ucar.unidata.io.RandomAccessFile raf, BufrIndicatorSection is, BufrIdentificationSection ids, BufrDataDescriptionSection dds, BufrDataSection dataSection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcalcTotalBits(Formatter out)voidclose()booleancontainsBufrTable()Check if this message contains a BUFR tablevoiddump(Formatter out)voiddumpHeader(Formatter out)voiddumpHeaderShort(Formatter out)booleanequals(Object obj)BufrMessage is equal if they have the same dds.StringextractWMO()BitCounterUncompressedgetBitCounterUncompressed(int obsOffsetInMessage)Get the offset of this obs from the start of the message data.intgetCountedDataBits()intgetCountedDataBytes()intgetDDShashcode()StringgetHeader()BufrTableLookupgetLookup()longgetMessageSize()Get the byte length of the entire BUFR record.intgetNumberDatasets()Get number of datasets in this message.byte[]getRawBytes()ucar.nc2.time.CalendarDategetReferenceTime()DataDescriptorgetRootDataDescriptor()Get the root of the DataDescriptor tree.longgetStartPos()intgetTotalBits()This is the total number of bits taken by the data in the data section of the message.inthashCode()Override hashcode to be consistent with equals.booleanisBitCountOk()booleanisTablesComplete()Check if all descriptors were found in the tables.voidsetHeader(String header)voidsetRawBytes(byte[] raw)voidsetStartPos(long startPos)voidshowMissingFields(Formatter out)booleanusesLocalTable()
-
-
-
Field Detail
-
is
public BufrIndicatorSection is
-
ids
public BufrIdentificationSection ids
-
dds
public BufrDataDescriptionSection dds
-
dataSection
public BufrDataSection dataSection
-
-
Constructor Detail
-
Message
public Message(ucar.unidata.io.RandomAccessFile raf, BufrIndicatorSection is, BufrIdentificationSection ids, BufrDataDescriptionSection dds, BufrDataSection dataSection) 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
-
getReferenceTime
public ucar.nc2.time.CalendarDate 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()
Get the root of the DataDescriptor tree.- Returns:
- root DataDescriptor
-
usesLocalTable
public boolean usesLocalTable() throws IOException- Throws:
IOException
-
containsBufrTable
public boolean containsBufrTable()
Check if this message contains a BUFR table- Returns:
- true if message contains a BUFR table
-
isTablesComplete
public boolean isTablesComplete()
Check if all descriptors were found in the tables.- Returns:
- true if all dds were found.
-
getLookup
public BufrTableLookup getLookup()
-
isBitCountOk
public boolean isBitCountOk()
-
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.
-
getDDShashcode
public int getDDShashcode()
-
equals
public boolean equals(Object obj)
BufrMessage is equal if they have the same dds.
-
showMissingFields
public void showMissingFields(Formatter out) throws IOException
- Throws:
IOException
-
dump
public void dump(Formatter out)
-
dumpHeader
public void dumpHeader(Formatter out)
-
dumpHeaderShort
public void dumpHeaderShort(Formatter out)
-
-