public final Object decodeTypedValue(final byte typeDescriptor, final int size) throws IOException { if ( size == 0 ) { // missing value => null in java return null; } else { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); if ( type == BCF2Type.CHAR ) { // special case string decoding for efficiency return decodeLiteralString(size); } else if ( size == 1 ) { return decodeSingleValue(type); } else { final ArrayList<Object> ints = new ArrayList<Object>(size); for ( int i = 0; i < size; i++ ) { final Object val = decodeSingleValue(type); if ( val == null ) continue; // auto-pruning. We remove trailing nulls ints.add(val); } return ints.isEmpty() ? null : ints; // return null when all of the values are null } } }
public final Object decodeTypedValue(final byte typeDescriptor, final int size) throws IOException { if ( size == 0 ) { // missing value => null in java return null; } else { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); if ( type == BCF2Type.CHAR ) { // special case string decoding for efficiency return decodeLiteralString(size); } else if ( size == 1 ) { return decodeSingleValue(type); } else { final ArrayList<Object> ints = new ArrayList<Object>(size); for ( int i = 0; i < size; i++ ) { final Object val = decodeSingleValue(type); if ( val == null ) continue; // auto-pruning. We remove trailing nulls ints.add(val); } return ints.isEmpty() ? null : ints; // return null when all of the values are null } } }
@Requires("size >= 0") public final Object decodeTypedValue(final byte typeDescriptor, final int size) throws IOException { if ( size == 0 ) { // missing value => null in java return null; } else { final BCF2Type type = BCF2Utils.decodeType(typeDescriptor); if ( type == BCF2Type.CHAR ) { // special case string decoding for efficiency return decodeLiteralString(size); } else if ( size == 1 ) { return decodeSingleValue(type); } else { final ArrayList<Object> ints = new ArrayList<Object>(size); for ( int i = 0; i < size; i++ ) { final Object val = decodeSingleValue(type); if ( val == null ) continue; // auto-pruning. We remove trailing nulls ints.add(val); } return ints.isEmpty() ? null : ints; // return null when all of the values are null } } }