本文整理了Java中org.neo4j.string.UTF8
类的一些代码示例,展示了UTF8
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UTF8
类的具体详情如下:
包路径:org.neo4j.string.UTF8
类名称:UTF8
[英]Utilities for working with UTF8 encoding and decoding.
[中]使用UTF8编码和解码的实用程序。
代码示例来源:origin: neo4j/neo4j
@Override
public int length( Object value )
{
return Integer.BYTES + UTF8.encode( (String)value ).length * Character.BYTES; // pessimistic
}
代码示例来源:origin: neo4j/neo4j
public static String decodeString( byte[] byteArray )
{
return UTF8.decode( byteArray );
}
代码示例来源:origin: neo4j/neo4j
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 );
}
代码示例来源:origin: neo4j/neo4j
/**
* 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;
}
代码示例来源:origin: neo4j/neo4j
/**
* 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;
}
代码示例来源:origin: neo4j/neo4j
@Override
public void writeString( String value )
{
bytes = UTF8.encode( value );
bytesLength = bytes.length;
bytesDereferenced = false;
}
代码示例来源:origin: neo4j/neo4j
static String asValueRaw( byte[] byteArray, long long0 )
{
return byteArray == null ? null : UTF8.decode( byteArray, 0, (int) long0 );
}
代码示例来源:origin: org.neo4j/neo4j-common
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 );
}
代码示例来源:origin: org.neo4j/neo4j-kernel
/**
* 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;
}
代码示例来源:origin: neo4j/neo4j
public static int computeRequiredByteBufferSize( String text )
{
return encode( text ).length + 4;
}
代码示例来源:origin: neo4j/neo4j
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 );
}
代码示例来源:origin: org.neo4j/neo4j-kernel
/**
* 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;
}
代码示例来源:origin: neo4j/neo4j
Input( String data )
{
bytes = UTF8.encode( data );
}
代码示例来源:origin: neo4j/neo4j
public List<S> deserializeRecords( byte[] bytes ) throws FormatException
{
return deserializeRecords( Arrays.asList( UTF8.decode( bytes ).split( "\n" ) ) );
}
代码示例来源:origin: neo4j/neo4j
public static byte[] encodeString( String string )
{
return UTF8.encode( string );
}
代码示例来源:origin: neo4j/neo4j
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() ) );
}
代码示例来源:origin: neo4j/neo4j
public static void putEncodedStringInto( String text, ByteBuffer target )
{
byte[] data = encode( text );
target.putInt( data.length );
target.put( data );
}
代码示例来源:origin: neo4j/neo4j
private static String entityAsString( Response response )
{
byte[] bytes = (byte[]) response.getEntity();
return UTF8.decode( bytes );
}
代码示例来源:origin: neo4j/neo4j
@Override
public void writeString( String value )
{
builder.append( base64Encoder.encodeToString( UTF8.encode( value ) ) );
builder.append( '|' );
}
代码示例来源:origin: neo4j/neo4j
private String decode( final Response response )
{
return UTF8.decode( (byte[]) response.getEntity() );
}
内容来源于网络,如有侵权,请联系作者删除!