public class DigesterRepresentation extends WrapperRepresentation
Representation.isTransient().
UNKNOWN_SIZE
Constructor and Description |
---|
DigesterRepresentation(Representation wrappedRepresentation)
Constructor.
|
DigesterRepresentation(Representation wrappedRepresentation,
java.lang.String algorithm)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkDigest()
Check that the digest computed from the representation content and the
digest declared by the representation are the same.
|
boolean |
checkDigest(java.lang.String algorithm)
Check that the digest computed from the representation content and the
digest declared by the representation are the same.
|
Digest |
computeDigest()
Compute the representation digest according to MD5 algorithm.
|
Digest |
computeDigest(java.lang.String algorithm)
Compute the representation digest according to the given algorithm.
|
long |
exhaust()
Exhausts the content of the representation by reading it and silently
discarding anything read.
|
java.nio.channels.ReadableByteChannel |
getChannel()
Returns a channel with the representation's content.
|
Digest |
getComputedDigest()
Returns the current computed digest value of the representation.
|
java.io.Reader |
getReader()
Returns a characters reader with the representation's content.
|
java.io.InputStream |
getStream()
Returns a stream with the representation's content.
|
java.lang.String |
getText()
Converts the representation to a string value.
|
void |
write(java.io.OutputStream outputStream)
Writes the representation to a byte stream.
|
void |
write(java.nio.channels.WritableByteChannel writableChannel)
Writes the representation to a byte channel.
|
void |
write(java.io.Writer writer)
Writes the representation to a characters writer.
|
getAvailableSize, getCharacterSet, getDigest, getDisposition, getEncodings, getExpirationDate, getLanguages, getLocationRef, getMediaType, getModificationDate, getRange, getRegistration, getSize, getTag, getWrappedRepresentation, isAvailable, isSelectable, isTransient, release, setAvailable, setCharacterSet, setDigest, setDisposition, setEncodings, setExpirationDate, setLanguages, setLocationRef, setLocationRef, setMediaType, setModificationDate, setRange, setSize, setTag, setTransient
append, hasKnownSize, isEmpty, setListener
createClientInfo, equals, hashCode, includes, isCompatible, toString
public DigesterRepresentation(Representation wrappedRepresentation) throws java.security.NoSuchAlgorithmException
Digest.ALGORITHM_MD5
digest algorithm.wrappedRepresentation
- The wrapped representation.java.security.NoSuchAlgorithmException
public DigesterRepresentation(Representation wrappedRepresentation, java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
wrappedRepresentation
- The wrapped representation.algorithm
- The digest algorithm.java.security.NoSuchAlgorithmException
public boolean checkDigest()
computeDigest(String)
method,
and since this method reads entirely the representation's stream, user
must take care of the content of the representation in case the latter is
transient.
WrapperRepresentation.isTransient()
public boolean checkDigest(java.lang.String algorithm)
computeDigest(String)
method,
and since this method reads entirely the representation's stream, user
must take care of the content of the representation in case the latter is
transient.
WrapperRepresentation.isTransient()
algorithm
- The algorithm used to compute the digest to compare with. See
constant values in Digest
.public Digest computeDigest()
public Digest computeDigest(java.lang.String algorithm)
WrapperRepresentation.isTransient()
algorithm
- The algorithm used to compute the digest. See constant values
in Digest
.public long exhaust() throws java.io.IOException
exhaust
in class WrapperRepresentation
java.io.IOException
public java.nio.channels.ReadableByteChannel getChannel() throws java.io.IOException
Representation
getChannel
in class WrapperRepresentation
java.io.IOException
public Digest getComputedDigest()
public java.io.Reader getReader() throws java.io.IOException
Representation
getReader
in class WrapperRepresentation
java.io.IOException
public java.io.InputStream getStream() throws java.io.IOException
DigestInputStream
class, which allows to compute
progressively the digest value.getStream
in class WrapperRepresentation
java.io.IOException
public java.lang.String getText() throws java.io.IOException
Representation
getText
in class WrapperRepresentation
java.io.IOException
public void write(java.io.OutputStream outputStream) throws java.io.IOException
OutputStream
after writing to it as this will be handled by
the Restlet connectors automatically.DigestOutputStream
class, which allows to compute progressively
the digest value.write
in class WrapperRepresentation
outputStream
- The output stream.java.io.IOException
public void write(java.nio.channels.WritableByteChannel writableChannel) throws java.io.IOException
Representation
write
in class WrapperRepresentation
writableChannel
- A writable byte channel.java.io.IOException
public void write(java.io.Writer writer) throws java.io.IOException
Representation
Writer
after writing to it as this will be handled
by the Restlet connectors automatically.write
in class WrapperRepresentation
writer
- The characters writer.java.io.IOException
Copyright © 2005-2024 Restlet.