Class RandomHandler.RandomEntity
- java.lang.Object
-
- org.apache.hc.core5.http.io.entity.AbstractHttpEntity
-
- org.apache.hc.client5.testing.classic.RandomHandler.RandomEntity
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,org.apache.hc.core5.http.EntityDetails,org.apache.hc.core5.http.HttpEntity
- Enclosing class:
- RandomHandler
public static class RandomHandler.RandomEntity extends org.apache.hc.core5.http.io.entity.AbstractHttpEntityAn entity that generates random data. This is an outgoing entity, it supportswriteTobut notgetContent.
-
-
Constructor Summary
Constructors Constructor Description RandomEntity(long len)Creates a new entity generating the given amount of data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()java.io.InputStreamgetContent()Not supported.longgetContentLength()Obtains the size of the random data.booleanisRepeatable()Tells that this entity is repeatable, in a way.booleanisStreaming()Tells that this entity is not streaming.voidwriteTo(java.io.OutputStream out)Generates the random content.
-
-
-
Method Detail
-
isStreaming
public final boolean isStreaming()
Tells that this entity is not streaming.- Returns:
- false
-
isRepeatable
public boolean isRepeatable()
Tells that this entity is repeatable, in a way. Repetitions will generate different random data, unless perchance the same random data is generated twice.- Specified by:
isRepeatablein interfaceorg.apache.hc.core5.http.HttpEntity- Overrides:
isRepeatablein classorg.apache.hc.core5.http.io.entity.AbstractHttpEntity- Returns:
true
-
getContentLength
public long getContentLength()
Obtains the size of the random data.- Returns:
- the number of random bytes to generate
-
getContent
public java.io.InputStream getContent()
Not supported. This method throws an exception.- Returns:
- never anything
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOExceptionGenerates the random content.- Specified by:
writeToin interfaceorg.apache.hc.core5.http.HttpEntity- Overrides:
writeToin classorg.apache.hc.core5.http.io.entity.AbstractHttpEntity- Parameters:
out- where to write the content to- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Throws:
java.io.IOException
-
-