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 BufrDataSection
dataSection
BufrDataDescriptionSection
dds
BufrIdentificationSection
ids
BufrIndicatorSection
is
-
Constructor Summary
Constructors Constructor Description Message(RandomAccessFile raf, BufrIndicatorSection is, BufrIdentificationSection ids, BufrDataDescriptionSection dds, BufrDataSection dataSection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
calcTotalBits(Formatter out)
void
close()
boolean
containsBufrTable()
Check if this message contains a BUFR tablevoid
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.int
getCountedDataBits()
int
getCountedDataBytes()
int
getDDShashcode()
String
getHeader()
BufrTableLookup
getLookup()
long
getMessageSize()
Get the byte length of the entire BUFR record.int
getNumberDatasets()
Get number of datasets in this message.byte[]
getRawBytes()
CalendarDate
getReferenceTime()
DataDescriptor
getRootDataDescriptor()
Get the root of the DataDescriptor tree.long
getStartPos()
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()
-
-
-
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) 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 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)
-
-