@Override public int length( Object value ) { return Integer.BYTES + UTF8.encode( (String)value ).length * Character.BYTES; // pessimistic }
public static String decodeString( byte[] byteArray ) { return UTF8.decode( byteArray ); }
public static String getDecodedStringFrom( ByteBuffer source ) { // Currently only one key is supported although the data format supports multiple int count = source.getInt(); int remaining = source.remaining(); if ( count > remaining ) { throw badStringFormatException( count, remaining ); } byte[] data = new byte[count]; source.get( data ); return UTF8.decode( data ); }
/** * Compute the byte size needed to serialize the provided IndexRule using serialize. * @param indexDescriptor the StoreIndexDescriptor * @return the byte size of StoreIndexDescriptor */ static int lengthOf( StoreIndexDescriptor indexDescriptor ) { int length = 4; // legacy label or relType id length += 1; // schema rule type IndexProviderDescriptor providerDescriptor = indexDescriptor.providerDescriptor(); length += UTF8.computeRequiredByteBufferSize( providerDescriptor.getKey() ); length += UTF8.computeRequiredByteBufferSize( providerDescriptor.getVersion() ); length += 1; // index type if ( indexDescriptor.type() == IndexDescriptor.Type.UNIQUE ) { length += 8; // owning constraint id } length += indexDescriptor.schema().computeWith( schemaSizeComputer ); length += UTF8.computeRequiredByteBufferSize( indexDescriptor.getName() ); return length; }
/** * Compute the byte size needed to serialize the provided ConstraintRule using serialize. * @param constraintRule the ConstraintRule * @return the byte size of ConstraintRule */ static int lengthOf( ConstraintRule constraintRule ) { int length = 4; // legacy label or relType id length += 1; // schema rule type length += 1; // constraint type ConstraintDescriptor constraintDescriptor = constraintRule.getConstraintDescriptor(); if ( constraintDescriptor.enforcesUniqueness() ) { length += 8; // owned index id } length += constraintDescriptor.schema().computeWith( schemaSizeComputer ); length += UTF8.computeRequiredByteBufferSize( constraintRule.getName() ); return length; }
@Override public void writeString( String value ) { bytes = UTF8.encode( value ); bytesLength = bytes.length; bytesDereferenced = false; }
static String asValueRaw( byte[] byteArray, long long0 ) { return byteArray == null ? null : UTF8.decode( byteArray, 0, (int) long0 ); }
public static String getDecodedStringFrom( ByteBuffer source ) { // Currently only one key is supported although the data format supports multiple int count = source.getInt(); int remaining = source.remaining(); if ( count > remaining ) { throw badStringFormatException( count, remaining ); } byte[] data = new byte[count]; source.get( data ); return UTF8.decode( data ); }
/** * Compute the byte size needed to serialize the provided IndexRule using serialize. * @param indexDescriptor the StoreIndexDescriptor * @return the byte size of StoreIndexDescriptor */ static int lengthOf( StoreIndexDescriptor indexDescriptor ) { int length = 4; // legacy label or relType id length += 1; // schema rule type IndexProviderDescriptor providerDescriptor = indexDescriptor.providerDescriptor(); length += UTF8.computeRequiredByteBufferSize( providerDescriptor.getKey() ); length += UTF8.computeRequiredByteBufferSize( providerDescriptor.getVersion() ); length += 1; // index type if ( indexDescriptor.type() == IndexDescriptor.Type.UNIQUE ) { length += 8; // owning constraint id } length += indexDescriptor.schema().computeWith( schemaSizeComputer ); length += UTF8.computeRequiredByteBufferSize( indexDescriptor.getName() ); return length; }
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 ); }
/** * Compute the byte size needed to serialize the provided ConstraintRule using serialize. * @param constraintRule the ConstraintRule * @return the byte size of ConstraintRule */ static int lengthOf( ConstraintRule constraintRule ) { int length = 4; // legacy label or relType id length += 1; // schema rule type length += 1; // constraint type ConstraintDescriptor constraintDescriptor = constraintRule.getConstraintDescriptor(); if ( constraintDescriptor.enforcesUniqueness() ) { length += 8; // owned index id } length += constraintDescriptor.schema().computeWith( schemaSizeComputer ); length += UTF8.computeRequiredByteBufferSize( constraintRule.getName() ); return length; }
Input( String data ) { bytes = UTF8.encode( data ); }
public List<S> deserializeRecords( byte[] bytes ) throws FormatException { return deserializeRecords( Arrays.asList( UTF8.decode( bytes ).split( "\n" ) ) ); }
public static byte[] encodeString( String string ) { return UTF8.encode( string ); }
private TextValue string( RecordPropertyCursor cursor, long reference, PageCursor page ) { ByteBuffer buffer = cursor.buffer = read.loadString( reference, cursor.buffer, page ); buffer.flip(); return Values.stringValue( UTF8.decode( buffer.array(), 0, buffer.limit() ) ); }
public static void putEncodedStringInto( String text, ByteBuffer target ) { byte[] data = encode( text ); target.putInt( data.length ); target.put( data ); }
private static String entityAsString( Response response ) { byte[] bytes = (byte[]) response.getEntity(); return UTF8.decode( bytes ); }
@Override public void writeString( String value ) { builder.append( base64Encoder.encodeToString( UTF8.encode( value ) ) ); builder.append( '|' ); }
private String decode( final Response response ) { return UTF8.decode( (byte[]) response.getEntity() ); }