public class DigesterRepresentation extends WrapperRepresentation
Representation.isTransient().UNKNOWN_SIZE| Constructor and Description |
|---|
DigesterRepresentation(Representation wrappedRepresentation)
Constructor.
By default, the instance relies on the Digest.ALGORITHM_MD5
digest algorithm. |
DigesterRepresentation(Representation wrappedRepresentation,
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.
Since this method relies on the 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. |
boolean |
checkDigest(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.
If case this algorithm is the same than the one provided at instantiation, the computation operation is made with the current stored computed value and does not require to exhaust entirely the representation's stream. |
Digest |
computeDigest(String algorithm)
Compute the representation digest according to the given algorithm.
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. |
long |
exhaust()
Exhausts the content of the representation by reading it and silently
discarding anything read.
|
ReadableByteChannel |
getChannel()
Returns a channel with the representation's content.
If it is supported by a file, a read-only instance of FileChannel is returned. This method is ensured to return a fresh channel for each invocation unless it is a transient representation, in which case null is returned. |
Digest |
getComputedDigest()
Returns the current computed digest value of the representation.
|
Reader |
getReader()
Returns a characters reader with the representation's content.
|
InputStream |
getStream()
Returns a stream with the representation's content.
|
String |
getText()
Converts the representation to a string value.
|
void |
write(OutputStream outputStream)
Writes the representation to a byte stream.
|
void |
write(WritableByteChannel writableChannel)
Writes the representation to a byte channel.
|
void |
write(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, setTransientappend, hasKnownSize, isEmpty, setListenercreateClientInfo, equals, includes, isCompatible, toStringpublic DigesterRepresentation(Representation wrappedRepresentation) throws NoSuchAlgorithmException
Digest.ALGORITHM_MD5
digest algorithm.wrappedRepresentation - The wrapped representation.NoSuchAlgorithmExceptionpublic DigesterRepresentation(Representation wrappedRepresentation, String algorithm) throws NoSuchAlgorithmException
wrappedRepresentation - The wrapped representation.algorithm - The digest algorithm.NoSuchAlgorithmExceptionpublic 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(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(String algorithm)
WrapperRepresentation.isTransient()algorithm - The algorithm used to compute the digest. See constant values
in Digest.public long exhaust()
throws IOException
exhaust in class WrapperRepresentationIOExceptionpublic ReadableByteChannel getChannel() throws IOException
RepresentationgetChannel in class WrapperRepresentationIOExceptionpublic Digest getComputedDigest()
public Reader getReader() throws IOException
RepresentationgetReader in class WrapperRepresentationIOExceptionpublic InputStream getStream() throws IOException
DigestInputStream class, which allows to compute
progressively the digest value.getStream in class WrapperRepresentationIOExceptionpublic String getText() throws IOException
RepresentationgetText in class WrapperRepresentationIOExceptionpublic void write(OutputStream outputStream) throws 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 WrapperRepresentationoutputStream - The output stream.IOExceptionpublic void write(WritableByteChannel writableChannel) throws IOException
Representationwrite in class WrapperRepresentationwritableChannel - A writable byte channel.IOExceptionpublic void write(Writer writer) throws IOException
RepresentationWriter after writing to it as this will be handled
by the Restlet connectors automatically.write in class WrapperRepresentationwriter - The characters writer.IOExceptionCopyright © 2005-2015 Restlet.