org.apache.derbyTesting.functionTests.util.streams
Class ByteAlphabet

java.lang.Object
  extended by org.apache.derbyTesting.functionTests.util.streams.ByteAlphabet

public class ByteAlphabet
extends java.lang.Object

A looping alphabet, returning bytes in a specified encoding. The alphabet loops over a list of bytes representing characters. The alphabet-object is used by looping stream, which in turn is used for testing methods requiring streaming inputs. The following alphabets have been defined:


Field Summary
private  int boff
          Offset into the byte array.
private  int byteCount
          The number of byes in the alphabet.
private  byte[] bytes
          The bytes representing the characters in the alphabet.
private  int charCount
          The number of characters in the alphabet.
private  java.lang.String encoding
          The encoding used to represent characters as bytes.
private  java.lang.String name
          The name of the alphabet.
 
Constructor Summary
private ByteAlphabet(java.lang.String name, char[] chars, java.lang.String encoding)
          Create an alphabet with the given name, the given characters and using the specified encoding to represent the characters as bytes.
 
Method Summary
 int byteCount()
          Return the number of bytes in the alphabet.
 int charCount()
          Return the number of characters in the alphabet.
static ByteAlphabet cjkSubsetUTF16BE()
          Create an alphabet returning bytes representing a subset of the CJK alphabet in the UTF-16BE encoding.
static ByteAlphabet cjkSubsetUTF8()
          Create an alphabet returning bytes representing a subset of the CJK alphabet in the UTF-8 encoding.
 java.lang.String getEncoding()
          Return the encoding used to represent characters as bytes.
 java.lang.String getName()
          Return the name of the alphabet.
static ByteAlphabet modernLatinLowercase()
          Create an alphabet returning bytes representing the lowercase letters a-z in the "US-ASCII" encoding.
 byte nextByte()
          Return the next byte in the alphabet.
 int nextByteToRead(int bytesRead)
          Compute the next byte to read after reading the specified number of bytes.
static ByteAlphabet norwegianLowercase()
          Create an alphabet returning bytes representing the 29 lowercase letters in the Norwegian/Danish alphabet in the "ISO-8859-1" encoding.
 void reset()
          Reset the alphabet, the next byte returned is the first byte in the alphabet, which might not be a complete character.
static ByteAlphabet tamilUTF16BE()
          Create an alphabet returning bytes representing a subset of the Tamil alphabet in the UTF-16BE encoding.
static ByteAlphabet tamilUTF8()
          Create an alphabet returning bytes representing a subset of the Tamil alphabet in the UTF-8 encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private final java.lang.String name
The name of the alphabet.


encoding

private final java.lang.String encoding
The encoding used to represent characters as bytes.


bytes

private final byte[] bytes
The bytes representing the characters in the alphabet.


charCount

private final int charCount
The number of characters in the alphabet.


byteCount

private final int byteCount
The number of byes in the alphabet.


boff

private int boff
Offset into the byte array.

Constructor Detail

ByteAlphabet

private ByteAlphabet(java.lang.String name,
                     char[] chars,
                     java.lang.String encoding)
Create an alphabet with the given name, the given characters and using the specified encoding to represent the characters as bytes.

Parameters:
name - the name of the alphabet
chars - the characters in the alphabet
encoding - the encoding to use to represent characters as bytes
Method Detail

modernLatinLowercase

public static ByteAlphabet modernLatinLowercase()
Create an alphabet returning bytes representing the lowercase letters a-z in the "US-ASCII" encoding.


norwegianLowercase

public static ByteAlphabet norwegianLowercase()
Create an alphabet returning bytes representing the 29 lowercase letters in the Norwegian/Danish alphabet in the "ISO-8859-1" encoding.


tamilUTF8

public static ByteAlphabet tamilUTF8()
Create an alphabet returning bytes representing a subset of the Tamil alphabet in the UTF-8 encoding.


tamilUTF16BE

public static ByteAlphabet tamilUTF16BE()
Create an alphabet returning bytes representing a subset of the Tamil alphabet in the UTF-16BE encoding.


cjkSubsetUTF8

public static ByteAlphabet cjkSubsetUTF8()
Create an alphabet returning bytes representing a subset of the CJK alphabet in the UTF-8 encoding.


cjkSubsetUTF16BE

public static ByteAlphabet cjkSubsetUTF16BE()
Create an alphabet returning bytes representing a subset of the CJK alphabet in the UTF-16BE encoding.


getName

public java.lang.String getName()
Return the name of the alphabet.


getEncoding

public java.lang.String getEncoding()
Return the encoding used to represent characters as bytes.


charCount

public int charCount()
Return the number of characters in the alphabet.


byteCount

public int byteCount()
Return the number of bytes in the alphabet. The number of bytes in the alphabet is noramlly different from the number of characters in the alphabet, but it depends on the characters in the alphabet and encoding used to represent them as bytes.


nextByte

public byte nextByte()
Return the next byte in the alphabet.


reset

public void reset()
Reset the alphabet, the next byte returned is the first byte in the alphabet, which might not be a complete character.


nextByteToRead

public int nextByteToRead(int bytesRead)
Compute the next byte to read after reading the specified number of bytes. Besides from returning the index, the internal state of the alphabet is updated.

Parameters:
bytesRead - the number of bytes read
Returns:
the index of the next byte

Built on Fri 2009-11-06 18:44:10-0800, from revision 833282

Apache Derby V10.6 Internals - Copyright © 2004,2008 The Apache Software Foundation. All Rights Reserved.