ByteBuffer encodeTextValue(Object obj,int minChars,int maxChars,boolean forceUncompressed) throws IOException {
  CharSequence text=toCharSequence(obj);
  if ((text.length() > maxChars) || (text.length() < minChars)) {
    throw new IOException(withErrorContext("Text is wrong length for " + getType() + " column, max "+ maxChars+ ", min "+ minChars+ ", got "+ text.length()));
  }
  if (!forceUncompressed && isCompressedUnicode() && (text.length() <= getFormat().MAX_COMPRESSED_UNICODE_SIZE)&& isUnicodeCompressible(text)) {
    byte[] encodedChars=new byte[TEXT_COMPRESSION_HEADER.length + text.length()];
    encodedChars[0]=TEXT_COMPRESSION_HEADER[0];
    encodedChars[1]=TEXT_COMPRESSION_HEADER[1];
    for (int i=0; i < text.length(); ++i) {
      encodedChars[i + TEXT_COMPRESSION_HEADER.length]=(byte)text.charAt(i);
    }
    return ByteBuffer.wrap(encodedChars);
  }
  return encodeUncompressedText(text,getCharset());
}

ByteBuffer encodeTextValue ( Object obj , int minChars , int maxChars , boolean forceUncompressed ) throws IOException { CharSequence text = toCharSequence ( obj ) ; if ( ( text . length ( ) > maxChars ) || ( text . length ( ) < minChars ) ) { throw new IOException ( withErrorContext ( "Text is wrong length for " + getType ( ) + " column, max " + maxChars + ", min " + minChars + ", got " + text . length ( ) ) ) ; } if ( ! forceUncompressed && isCompressedUnicode ( ) && ( text . length ( ) <= getFormat ( ) . MAX_COMPRESSED_UNICODE_SIZE ) && isUnicodeCompressible ( text ) ) { byte [ ] encodedChars = new byte [ TEXT_COMPRESSION_HEADER . length + text . length ( ) ] ; encodedChars [ 0 ] = TEXT_COMPRESSION_HEADER [ 0 ] ; encodedChars [ 1 ] = TEXT_COMPRESSION_HEADER [ 1 ] ; for ( int i = 0 ; i < text . length ( ) ; ++ i ) { encodedChars [ i + TEXT_COMPRESSION_HEADER . length ] = ( byte ) text . charAt ( i ) ; } return ByteBuffer . wrap ( encodedChars ) ; } return encodeUncompressedText ( text , getCharset ( ) ) ; }
encodes a text value , possibly compressing .
