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

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream
All Implemented Interfaces:
java.io.Closeable, org.apache.derby.iapi.types.Resetable

public class LoopingAlphabetStream
extends java.io.InputStream
implements org.apache.derby.iapi.types.Resetable

A stream returning a cycle of the 26 lowercase letters of the modern Latin alphabet.


Field Summary
private  ByteAlphabet alphabet
           
private  byte[] buffer
           
private  long length
          Length of the stream.
private static int MAX_BUF_SIZE
          Maximum size of buffer.
private  long remainingBlanks
          Remaining bytes in the stream.
private  long remainingNonBlanks
           
private static byte SPACE
           
private  int trailingBlanks
           
 
Constructor Summary
LoopingAlphabetStream(long length)
          Create a looping modern latin alphabet stream of the specified length.
LoopingAlphabetStream(long length, ByteAlphabet alphabet)
          Create a looping alphabet of the specified type and length.
LoopingAlphabetStream(long length, ByteAlphabet alphabet, int trailingBlanks)
           
LoopingAlphabetStream(long length, int trailingBlanks)
          Creates a looping alphabet stream with the specified length, in which the last characters are blanks.
 
Method Summary
 int available()
          Return remaining bytes in the stream.
 void closeStream()
           
private  int fillBlanks(byte[] buf, int off, int length)
           
private  void fillBuffer(int bufSize)
          Fill internal buffer of bytes (from character sequence).
 void initStream()
           
 int read()
           
 int read(byte[] buf, int off, int length)
           
 void reset()
          Reset the stream.
 void resetStream()
           
 
Methods inherited from class java.io.InputStream
close, mark, markSupported, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_BUF_SIZE

private static final int MAX_BUF_SIZE
Maximum size of buffer. Balance between size and memory usage.

See Also:
Constant Field Values

SPACE

private static final byte SPACE
See Also:
Constant Field Values

length

private final long length
Length of the stream.


trailingBlanks

private final int trailingBlanks

remainingBlanks

private long remainingBlanks
Remaining bytes in the stream.


remainingNonBlanks

private long remainingNonBlanks

buffer

private byte[] buffer

alphabet

private final ByteAlphabet alphabet
Constructor Detail

LoopingAlphabetStream

public LoopingAlphabetStream(long length)
Create a looping modern latin alphabet stream of the specified length.

Parameters:
length - the number of characters (and also the number of bytes)

LoopingAlphabetStream

public LoopingAlphabetStream(long length,
                             int trailingBlanks)
Creates a looping alphabet stream with the specified length, in which the last characters are blanks.

Parameters:
length - total length of the stream
trailingBlanks - number of trailing blanks

LoopingAlphabetStream

public LoopingAlphabetStream(long length,
                             ByteAlphabet alphabet)
Create a looping alphabet of the specified type and length.

Parameters:
length - the number of bytes in the stream
alphabet - the alphabet to loop over

LoopingAlphabetStream

public LoopingAlphabetStream(long length,
                             ByteAlphabet alphabet,
                             int trailingBlanks)
Method Detail

read

public int read()
Specified by:
read in class java.io.InputStream

read

public int read(byte[] buf,
                int off,
                int length)
Overrides:
read in class java.io.InputStream

reset

public void reset()
Reset the stream.

Overrides:
reset in class java.io.InputStream

available

public int available()
Return remaining bytes in the stream.

Overrides:
available in class java.io.InputStream

fillBuffer

private void fillBuffer(int bufSize)
Fill internal buffer of bytes (from character sequence).

Parameters:
bufSize - the wanted size, might be ignored if too big

fillBlanks

private int fillBlanks(byte[] buf,
                       int off,
                       int length)

resetStream

public void resetStream()
Specified by:
resetStream in interface org.apache.derby.iapi.types.Resetable

initStream

public void initStream()
Specified by:
initStream in interface org.apache.derby.iapi.types.Resetable

closeStream

public void closeStream()
Specified by:
closeStream in interface org.apache.derby.iapi.types.Resetable

Built on Wed 2009-11-25 18:43:31-0800, from revision 884373

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