@Override public String toString() { return "Credential{" + "salt=0x" + HexString.encodeHexString( salt ) + ", passwordHash=0x" + HexString.encodeHexString( passwordHash ) + '}'; }
@Override public int length( Object value ) { return Integer.BYTES + UTF8.encode( (String)value ).length * Character.BYTES; // pessimistic }
static String asValueRaw( byte[] byteArray, long long0 ) { return byteArray == null ? null : UTF8.decode( byteArray, 0, (int) long0 ); }
private static IndexProviderDescriptor readIndexProviderDescriptor( ByteBuffer source ) { String providerKey = getDecodedStringFrom( source ); String providerVersion = getDecodedStringFrom( source ); return new IndexProviderDescriptor( providerKey, providerVersion ); }
@Override public void writeString( String value ) { bytes = UTF8.encode( value ); bytesLength = bytes.length; bytesDereferenced = false; }
public static String decodeString( byte[] byteArray ) { return UTF8.decode( byteArray ); }
private static IndexProviderDescriptor readIndexProviderDescriptor( ByteBuffer serialized ) { String providerKey = getDecodedStringFrom( serialized ); String providerVersion = getDecodedStringFrom( serialized ); return new IndexProviderDescriptor( providerKey, providerVersion ); }
public static int computeRequiredByteBufferSize( String text ) { return encode( text ).length + 4; }
public static String readString( ReadableChannel channel, int length ) throws IOException { assert length >= 0 : "invalid array length " + length; byte[] chars = new byte[length]; channel.get( chars, length ); return UTF8.decode( chars ); }
public static byte[] encodeString( String string ) { return UTF8.encode( string ); }
private static String entityAsString( Response response ) { byte[] bytes = (byte[]) response.getEntity(); return UTF8.decode( bytes ); }
Input( String data ) { bytes = UTF8.encode( data ); }
@Override public Object read( ReadableClosableChannel from ) throws IOException { int length = from.getInt(); byte[] bytes = new byte[length]; // TODO wasteful from.get( bytes, length ); return UTF8.decode( bytes ); }
public static void putEncodedStringInto( String text, ByteBuffer target ) { byte[] data = encode( text ); target.putInt( data.length ); target.put( data ); }
public static String read3bLengthAndString( ReadableChannel channel ) throws IOException { short lengthShort = channel.getShort(); byte lengthByte = channel.get(); int length = (lengthByte << 16) | (lengthShort & 0xFFFF); byte[] chars = new byte[length]; channel.get( chars, length ); return UTF8.decode( chars ); }
static Map<String,Object> newCustomAuthToken( String principle, String credentials, String realm, String scheme, Map<String,Object> parameters ) { return newCustomAuthToken( principle, UTF8.encode( credentials ), realm, scheme, parameters ); }
@Override public void writeString( String value ) { writeStringBytes( UTF8.encode( value ), false ); }
@Override public void write( Object value, FlushableChannel into ) throws IOException { byte[] bytes = UTF8.encode( (String)value ); into.putInt( bytes.length ).put( bytes, bytes.length ); } } );
@Override public boolean matchesPassword( String password ) { return byteEquals( passwordHash, hash( salt, UTF8.encode( password ) ) ); }
private byte[] toBytes( String entity, boolean mustFail ) { byte[] entityAsBytes = UTF8.encode( entity ); if ( !mustFail ) { representationWriteHandler.onRepresentationWritten(); } representationWriteHandler.onRepresentationFinal(); return entityAsBytes; }