Package org.firebirdsql.gds.ng.wire
Class DefaultBlrCalculator
- java.lang.Object
- 
- org.firebirdsql.gds.ng.wire.DefaultBlrCalculator
 
- 
- All Implemented Interfaces:
- BlrCalculator
 
 public class DefaultBlrCalculator extends java.lang.Object implements BlrCalculator Default BLR calculator for the wire protocol.Most likely this can be used without change for other protocol versions as well, although we may need to investigate the TODOs specified in calculateBlr(org.firebirdsql.gds.ng.fields.RowDescriptor).- Since:
- 3.0
- Author:
- Mark Rotteveel
 
- 
- 
Field SummaryFields Modifier and Type Field Description static DefaultBlrCalculatorCALCULATOR_DIALECT_3Cached instance ofDefaultBlrCalculatorfor dialect 3 databases.
 - 
Constructor SummaryConstructors Constructor Description DefaultBlrCalculator(short dialect)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intcalculateBatchMessageLength(RowDescriptor rowDescriptor)Calculates the batch message length.byte[]calculateBlr(RowDescriptor rowDescriptor)Calculates the blr for the row descriptor.byte[]calculateBlr(RowDescriptor rowDescriptor, RowValue rowValue)Calculates the blr for a specific row value.intcalculateIoLength(FieldDescriptor fieldDescriptor)Calculates the io length for the field descriptor.intcalculateIoLength(FieldDescriptor fieldDescriptor, byte[] fieldData)Calculates the io length for the field descriptor and actual data.
 
- 
- 
- 
Field Detail- 
CALCULATOR_DIALECT_3public static final DefaultBlrCalculator CALCULATOR_DIALECT_3 Cached instance ofDefaultBlrCalculatorfor dialect 3 databases.
 
- 
 - 
Method Detail- 
calculateBlrpublic byte[] calculateBlr(RowDescriptor rowDescriptor) throws java.sql.SQLException Description copied from interface:BlrCalculatorCalculates the blr for the row descriptor.- Specified by:
- calculateBlrin interface- BlrCalculator
- Parameters:
- rowDescriptor- Row descriptor
- Returns:
- Byte array with the blr
- Throws:
- java.sql.SQLException- When the- RowDescriptorcontains an unsupported field type.
 
 - 
calculateBlrpublic byte[] calculateBlr(RowDescriptor rowDescriptor, RowValue rowValue) throws java.sql.SQLException Description copied from interface:BlrCalculatorCalculates the blr for a specific row value.This allows to optimize for the actual length of the field. - Specified by:
- calculateBlrin interface- BlrCalculator
- Parameters:
- rowDescriptor- Row descriptor
- rowValue- Row value
- Returns:
- Byte array with the blr
- Throws:
- java.sql.SQLException- When the- RowValuecontains an unsupported field type.
 
 - 
calculateIoLengthpublic int calculateIoLength(FieldDescriptor fieldDescriptor) throws java.sql.SQLException Description copied from interface:BlrCalculatorCalculates the io length for the field descriptor.The return value indicates the length and padding of the type in the buffer - < 0 : Type is of specified length * -1 and not padded
- == 0 : Type is of dynamic length (which is specified in the buffer as an integer) and padded
- > 0 : Type is of specified length minus 1 (subtracting 1 is required to avoid 0 for types of zero length) and padded
 - Specified by:
- calculateIoLengthin interface- BlrCalculator
- Parameters:
- fieldDescriptor- Field descriptor
- Returns:
- The io length
- Throws:
- java.sql.SQLException
 
 - 
calculateIoLengthpublic int calculateIoLength(FieldDescriptor fieldDescriptor, byte[] fieldData) throws java.sql.SQLException Description copied from interface:BlrCalculatorCalculates the io length for the field descriptor and actual data.The return value indicates the length and padding of the type in the buffer - < 0 : Type is of specified length * -1 and not padded
- == 0 : Type is of dynamic length (which is specified in the buffer as an integer) and padded
- > 0 : Type is of specified length minus 1 (subtracting 1 is required to avoid 0 for types of zero length) and padded
 This allows to optimize for the actual length of the field. For CHAR(ISCConstants.SQL_TEXTthe implementation should be consistent with the lengths as given byBlrCalculator.calculateIoLength(FieldDescriptor).- Specified by:
- calculateIoLengthin interface- BlrCalculator
- Parameters:
- fieldDescriptor- Field descriptor
- fieldData- byte array (can be- null) with field data.
- Returns:
- The io length
- Throws:
- java.sql.SQLException
 
 - 
calculateBatchMessageLengthpublic int calculateBatchMessageLength(RowDescriptor rowDescriptor) throws java.sql.SQLException Description copied from interface:BlrCalculatorCalculates the batch message length.- Specified by:
- calculateBatchMessageLengthin interface- BlrCalculator
- Parameters:
- rowDescriptor- row descriptor
- Returns:
- batch message length
- Throws:
- java.sql.SQLException- when the- RowDescriptorcontains an unsupported field type.
 
 
- 
 
-