Class StringInputStreamProvider
java.lang.Object
com.helger.base.io.streamprovider.StringInputStreamProvider
- All Implemented Interfaces:
IHasInputStream,IHasInputStreamAndReader,IHasReader
public class StringInputStreamProvider
extends Object
implements IHasInputStreamAndReader, IHasReader
An
InputStream provider based on a String.- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionStringInputStreamProvider(char @NonNull [] aChars, int nOfs, int nLen, @NonNull Charset aCharset) Constructor using a portion of a char array.StringInputStreamProvider(char @NonNull [] aChars, @NonNull Charset aCharset) Constructor using a char array.StringInputStreamProvider(@NonNull CharSequence aData, @NonNull Charset aCharset) Constructor using aCharSequence.StringInputStreamProvider(@NonNull String sData, @NonNull Charset aCharset) Constructor using aString. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinal @NonNull Charsetfinal @NonNull StringgetData()final @NonNull StringInputStreamGet the input stream to read from the object.final @NonNull NonBlockingStringReaderGet the reader to read from the object.final @NonNull NonBlockingStringReaderGet aReaderbased on this input stream provider using the given charset.inthashCode()final booleanCheck if theInputStreamfromIHasInputStream.getInputStream()andIHasInputStream.getBufferedInputStream()can be acquired more than once.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.base.io.iface.IHasInputStream
getBufferedInputStream, withBufferedInputStreamDo, withInputStreamDoMethods inherited from interface com.helger.base.io.iface.IHasInputStreamAndReader
getBufferedReaderMethods inherited from interface com.helger.base.io.iface.IHasReader
getBufferedReader
-
Constructor Details
-
StringInputStreamProvider
Constructor using a char array.- Parameters:
aChars- The char data. May not benull.aCharset- The charset to use. May not benull.
-
StringInputStreamProvider
public StringInputStreamProvider(char @NonNull [] aChars, @Nonnegative int nOfs, @Nonnegative int nLen, @NonNull Charset aCharset) Constructor using a portion of a char array.- Parameters:
aChars- The char data. May not benull.nOfs- Offset into the char array. Must be ≥ 0.nLen- Number of chars to use. Must be ≥ 0.aCharset- The charset to use. May not benull.
-
StringInputStreamProvider
Constructor using aCharSequence.- Parameters:
aData- The char sequence data. May not benull.aCharset- The charset to use. May not benull.
-
StringInputStreamProvider
Constructor using aString.- Parameters:
sData- The string data. May not benull.aCharset- The charset to use. May not benull.
-
-
Method Details
-
getData
- Returns:
- The data string. Never
null.
-
getCharset
- Returns:
- The charset used for encoding. Never
null.
-
getInputStream
Get the input stream to read from the object. Each time this method is called, a newInputStreamneeds to be created.- Specified by:
getInputStreamin interfaceIHasInputStream- Returns:
nullif resolving failed.
-
getReader
Get aReaderbased on this input stream provider using the given charset.- Specified by:
getReaderin interfaceIHasInputStreamAndReader- Parameters:
aCharset- The charset to use. May not benull.- Returns:
nullif no input stream could be retrieved.
-
getReader
Description copied from interface:IHasReaderGet the reader to read from the object. Each time this method is call, a newReaderneeds to be created!- Specified by:
getReaderin interfaceIHasReader- Returns:
- A new reader for the contained string data. Never
null.
-
isReadMultiple
public final boolean isReadMultiple()Check if theInputStreamfromIHasInputStream.getInputStream()andIHasInputStream.getBufferedInputStream()can be acquired more than once.- Specified by:
isReadMultiplein interfaceIHasInputStream- Returns:
trueif the input stream can be acquired more than once,falseif not.
-
equals
-
hashCode
public int hashCode() -
toString
-