Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
Classes | Static Public Member Functions | List of all members
Lucene.Net.Util.IndexableBinaryStringTools Class Reference

Provides support for converting byte sequences to Strings and back again. The resulting Strings preserve the original byte sequences' sort order. More...

Classes

class  CodingCase
 

Static Public Member Functions

static int GetEncodedLength (System.Collections.Generic.List< byte > original)
 Returns the number of chars required to encode the given byte sequence.
 
static int GetDecodedLength (System.Collections.Generic.List< char > encoded)
 Returns the number of bytes required to decode the given char sequence.
 
static void Encode (System.Collections.Generic.List< byte > input, System.Collections.Generic.List< char > output)
 Encodes the input byte sequence into the output char sequence. Before calling this method, ensure that the output CharBuffer has sufficient capacity by calling GetEncodedLength(System.Collections.Generic.List{byte}).
 
static void Decode (System.Collections.Generic.List< char > input, System.Collections.Generic.List< byte > output)
 Decodes the input char sequence into the output byte sequence. Before calling this method, ensure that the output ByteBuffer has sufficient capacity by calling GetDecodedLength(System.Collections.Generic.List{char}).
 
static
System.Collections.Generic.List
< byte > 
Decode (System.Collections.Generic.List< char > input)
 Decodes the given char sequence, which must have been encoded by Encode(System.Collections.Generic.List{byte}) or Encode(System.Collections.Generic.List{byte}, System.Collections.Generic.List{char}).
 
static
System.Collections.Generic.List
< char > 
Encode (System.Collections.Generic.List< byte > input)
 Encodes the input byte sequence.
 

Detailed Description

Provides support for converting byte sequences to Strings and back again. The resulting Strings preserve the original byte sequences' sort order.

The Strings are constructed using a Base 8000h encoding of the original binary data - each char of an encoded String represents a 15-bit chunk from the byte sequence. Base 8000h was chosen because it allows for all lower 15 bits of char to be used without restriction; the surrogate range [U+D8000-U+DFFF] does not represent valid chars, and would require complicated handling to avoid them and allow use of char's high bit.

Although unset bits are used as padding in the final char, the original byte sequence could contain trailing bytes with no set bits (null bytes): padding is indistinguishable from valid information. To overcome this problem, a char is appended, indicating the number of encoded bytes in the final content char.

This class's operations are defined over CharBuffers and ByteBuffers, to allow for wrapped arrays to be reused, reducing memory allocation costs for repeated operations. Note that this class calls array() and arrayOffset() on the CharBuffers and ByteBuffers it uses, so only wrapped arrays may be used. This class interprets the arrayOffset() and limit() values returned by its input buffers as beginning and end+1 positions on the wrapped array, resprectively; similarly, on the output buffer, arrayOffset() is the first position written to, and limit() is set to one past the final output array position.

Definition at line 54 of file IndexableBinaryStringTools.cs.

Member Function Documentation

static void Lucene.Net.Util.IndexableBinaryStringTools.Decode ( System.Collections.Generic.List< char >  input,
System.Collections.Generic.List< byte >  output 
)
static

Decodes the input char sequence into the output byte sequence. Before calling this method, ensure that the output ByteBuffer has sufficient capacity by calling GetDecodedLength(System.Collections.Generic.List{char}).

Parameters
inputThe char sequence to decode
outputWhere the byte sequence decoding result will go. The limit is set to one past the position of the final char.

<throws> IllegalArgumentException If either the input or the output buffer </throws>

is not backed by an array

Definition at line 193 of file IndexableBinaryStringTools.cs.

static System.Collections.Generic.List<byte> Lucene.Net.Util.IndexableBinaryStringTools.Decode ( System.Collections.Generic.List< char >  input)
static

Decodes the given char sequence, which must have been encoded by Encode(System.Collections.Generic.List{byte}) or Encode(System.Collections.Generic.List{byte}, System.Collections.Generic.List{char}).

Parameters
inputThe char sequence to decode
Returns
A byte sequence containing the decoding result. The limit is set to one past the position of the final char.

<throws> IllegalArgumentException If the input buffer is not backed by an </throws>

array

Definition at line 287 of file IndexableBinaryStringTools.cs.

static void Lucene.Net.Util.IndexableBinaryStringTools.Encode ( System.Collections.Generic.List< byte >  input,
System.Collections.Generic.List< char >  output 
)
static

Encodes the input byte sequence into the output char sequence. Before calling this method, ensure that the output CharBuffer has sufficient capacity by calling GetEncodedLength(System.Collections.Generic.List{byte}).

Parameters
inputThe byte sequence to encode
outputWhere the char sequence encoding result will go. The limit is set to one past the position of the final char.

<throws> IllegalArgumentException If either the input or the output buffer </throws>

is not backed by an array

Definition at line 113 of file IndexableBinaryStringTools.cs.

static System.Collections.Generic.List<char> Lucene.Net.Util.IndexableBinaryStringTools.Encode ( System.Collections.Generic.List< byte >  input)
static

Encodes the input byte sequence.

Parameters
inputThe byte sequence to encode
Returns
A char sequence containing the encoding result. The limit is set to one past the position of the final char.

<throws> IllegalArgumentException If the input buffer is not backed by an </throws>

array

Definition at line 306 of file IndexableBinaryStringTools.cs.

static int Lucene.Net.Util.IndexableBinaryStringTools.GetDecodedLength ( System.Collections.Generic.List< char >  encoded)
static

Returns the number of bytes required to decode the given char sequence.

Parameters
encodedThe char sequence to be encoded. Must be backed by an array.
Returns
The number of bytes required to decode the given char sequence

<throws> IllegalArgumentException If the given CharBuffer is not backed by an array </throws>

Definition at line 85 of file IndexableBinaryStringTools.cs.

static int Lucene.Net.Util.IndexableBinaryStringTools.GetEncodedLength ( System.Collections.Generic.List< byte >  original)
static

Returns the number of chars required to encode the given byte sequence.

Parameters
originalThe byte sequence to be encoded. Must be backed by an array.
Returns
The number of chars required to encode the given byte sequence

<throws> IllegalArgumentException If the given ByteBuffer is not backed by an array </throws>

Definition at line 72 of file IndexableBinaryStringTools.cs.


The documentation for this class was generated from the following file: