net.sf.asyncobjects.io
Class DecoderTextInput

java.lang.Object
  extended by net.sf.asyncobjects.AsyncUnicastServer<FacetType>
      extended by net.sf.asyncobjects.util.CloseableWrapper<ATextInput,AByteInput>
          extended by net.sf.asyncobjects.io.DecoderTextInput
All Implemented Interfaces:
ACloseable, AsyncObject, ExplicitSharing, AInput<TextData>, ATextInput

public class DecoderTextInput
extends CloseableWrapper<ATextInput,AByteInput>
implements ATextInput

A text input that uses CharsetDecoder to convert byte input to character input.

Author:
const

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.asyncobjects.util.CloseableWrapper
CloseableWrapper.InvalidatingWhen<I,R>
 
Field Summary
 
Fields inherited from class net.sf.asyncobjects.util.CloseableWrapper
closeWrapper, requests, wrapped
 
Constructor Summary
DecoderTextInput(BufferProvider buffers, AByteInput stream, boolean closeStream, CharsetDecoder decoder, int replenishLimit)
          A constructor
DecoderTextInput(String encoding, AByteInput in)
          A constructor
 
Method Summary
 Promise<Boolean> isPushbackSupported()
           
 void onMalformedInput(CodingErrorAction newAction)
          Configure decoder to execute specifed action on malformed input
 void onUnmappableCharacter(CodingErrorAction newAction)
          Configure decoder to execute specifed action on unmappable character
 Promise<Void> pushback(TextData data)
          Push back the data
 Promise<TextData> read(int limit)
          Read some data.
 void replaceWith(String newReplacement)
          Configure reprelacement string for decoder
 
Methods inherited from class net.sf.asyncobjects.util.CloseableWrapper
afterInvalidate, beforeClose, close, closed, ensureOpen, ensureValid, invalidate, isValid
 
Methods inherited from class net.sf.asyncobjects.AsyncUnicastServer
dereference, export, isImmediate, myVat, promise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.asyncobjects.ACloseable
close
 
Methods inherited from interface net.sf.asyncobjects.AsyncObject
dereference, isImmediate
 

Constructor Detail

DecoderTextInput

public DecoderTextInput(BufferProvider buffers,
                        AByteInput stream,
                        boolean closeStream,
                        CharsetDecoder decoder,
                        int replenishLimit)
A constructor

Parameters:
buffers - a buffer provider
stream - a stream to decode
closeStream - if true, underlying stream is closed if this stream is closed
decoder - a decoder to use
replenishLimit - a limit for reading data from the underlying stream

DecoderTextInput

public DecoderTextInput(String encoding,
                        AByteInput in)
A constructor

Parameters:
encoding - an encoding
in - an input stream
Method Detail

isPushbackSupported

public Promise<Boolean> isPushbackSupported()
Specified by:
isPushbackSupported in interface AInput<TextData>
Returns:
true if pushback supported for this stream
See Also:
AInput.isPushbackSupported()

replaceWith

public void replaceWith(String newReplacement)
Configure reprelacement string for decoder

Parameters:
newReplacement - a new replacement string.

onMalformedInput

public void onMalformedInput(CodingErrorAction newAction)
Configure decoder to execute specifed action on malformed input

Parameters:
newAction - a new action

onUnmappableCharacter

public void onUnmappableCharacter(CodingErrorAction newAction)
Configure decoder to execute specifed action on unmappable character

Parameters:
newAction - a new action

pushback

public Promise<Void> pushback(TextData data)
Push back the data

Specified by:
pushback in interface AInput<TextData>
Parameters:
data - a data to push back
Returns:
when pushback finished
See Also:
AInput.pushback(net.sf.asyncobjects.io.BatchedData)

read

public Promise<TextData> read(int limit)
Description copied from interface: AInput
Read some data.

Specified by:
read in interface AInput<TextData>
Parameters:
limit - a maximum amount of data elements to read.
Returns:
Promise for non-empty data batch that contains read inforation or null if eof is reached.
See Also:
AInput.read(int)


Copyright © 2002-2007 Constantine Plotnikov. All Rights Reserved.