public class ContentStream
extends com.saperion.common.io.InputStreamDescriptor
hashWith
is called with a valid hash-method-name a
content-hash is generated and stored in the content-variables 'SvHashAlgorithm' and 'SvHash'. expectedLength
.
expectHash
and state a hash-method via the method hashWith
.Modifier and Type | Field and Description |
---|---|
protected boolean |
calculateHash |
protected String |
expectedHash |
protected long |
expectedLength |
protected MessageDigest |
hashAlgorithm |
static int |
MODE_APPEND
Value for position: given content is appended to the last existing content element in the
document structure.
|
static int |
MODE_CLEAR
Value for position: deletes existing content, leaving an empty document structure.
|
static int |
MODE_CLEAR_AND_CREATE
Value for position: deletes existing content, adding given content as first element.
|
protected Integer |
pos
Position in document structure.
|
protected Boolean |
streaming
true if streaming for content should be switched on.
|
protected Map<String,String> |
variables
Variable of this content.
|
Constructor and Description |
---|
ContentStream(InputStream inputStream,
String fileName)
Constructor.
|
ContentStream(InputStream inputStream,
String fileName,
Integer position)
Constructor.
|
ContentStream(InputStream inputStream,
URL url) |
ContentStream(InputStream inputStream,
URL url,
int position) |
ContentStream(Integer position)
Constructor, creates empty ContentStream with given position.
|
Modifier and Type | Method and Description |
---|---|
ContentStream |
addVariable(String varName,
String varValue)
Adds a Variable to this Binary Object, which will be stored on a Media.
|
boolean |
doCheckLength()
Indicates if an expected content length was set and if actual content length should be
checked against it.
|
boolean |
doCheckLengthLimit()
Returns true if the length limit should be check.
|
boolean |
doHashing()
Get the flag if the hash should be calculated while archiving.
|
ContentStream |
expectedLength(long expectedLength)
Sets the expected length (number of bytes) of the content.
|
ContentStream |
expectHash(String hash)
Set the hash which is expected to be calculated while archiving the content.
|
static ContentStream |
fromDescriptor(com.saperion.common.io.InputStreamDescriptor descriptor) |
String |
getExpectedHash()
Get the hash which was set by client which tries to archive the content.
|
Long |
getExpectedLength()
Returns the expected length (number of bytes) of this stream.
|
String |
getFileName() |
MessageDigest |
getHashAlgorithm()
Get the MessageDigest which will be used for calculating the hash
|
InputStream |
getInputStream() |
Long |
getLengthLimit()
Returns the max allowed stream length limit.
|
Integer |
getPosition() |
Boolean |
getStreaming()
Gets the streaming option.
|
Map<String,String> |
getVariables() |
ContentStream |
hashWith(String algorithm)
Set the algorithm which should be used for calculating the hash while archiving this content
stream.
|
ContentStream |
lengthLimit(long maxLength)
Sets the max allowed stream length limit.
|
void |
setFileName(String fileName) |
void |
setInputStream(InputStream inputStream) |
void |
setPosition(Integer position) |
void |
setStreaming(Boolean doStreaming)
Sets the streaming option.
|
void |
setUrl(URL url) |
public static final int MODE_CLEAR
public static final int MODE_CLEAR_AND_CREATE
public static final int MODE_APPEND
protected Integer pos
protected Boolean streaming
protected boolean calculateHash
protected String expectedHash
protected long expectedLength
protected MessageDigest hashAlgorithm
public ContentStream(Integer position)
position
- position in document structure:
public ContentStream(InputStream inputStream, String fileName)
inputStream
- content streamfileName
- file name of contentpublic ContentStream(InputStream inputStream, String fileName, Integer position)
inputStream
- content streamfileName
- file name of contentposition
- position in document structure:
public ContentStream(InputStream inputStream, URL url)
public ContentStream(InputStream inputStream, URL url, int position)
public InputStream getInputStream()
getInputStream
in class com.saperion.common.io.InputStreamDescriptor
public void setInputStream(InputStream inputStream)
setInputStream
in class com.saperion.common.io.InputStreamDescriptor
public String getFileName()
public void setFileName(String fileName)
fileName
- original file name of contentpublic void setUrl(URL url)
setUrl
in class com.saperion.common.io.InputStreamDescriptor
public Integer getPosition()
public void setPosition(Integer position)
position
- content's position in document structurepublic Map<String,String> getVariables()
public ContentStream addVariable(String varName, String varValue)
varName
- Name of the Variable.varValue
- Value for this Variable.public ContentStream hashWith(String algorithm) throws NoSuchAlgorithmException
algorithm
- the name of the hash algorithm to use.NoSuchAlgorithmException
- if the given algorithm name does not exist.public ContentStream expectHash(String hash)
hash
- the HEX hash string.public ContentStream expectedLength(long expectedLength)
expectedLength
- the expected length of the content.public ContentStream lengthLimit(long maxLength)
maxLength
- the stream length limit to set.ContentStream
instancepublic Long getLengthLimit()
ContentStream
object.public Long getExpectedLength()
public boolean doCheckLength()
public boolean doCheckLengthLimit()
Indicates if an max content length limit was set and should be checked during stream serialization.
public boolean doHashing()
public String getExpectedHash()
public MessageDigest getHashAlgorithm()
public Boolean getStreaming()
public void setStreaming(Boolean doStreaming)
doStreaming
- the streaming optionpublic static ContentStream fromDescriptor(com.saperion.common.io.InputStreamDescriptor descriptor)
Copyright © 2020 Hyland Software Germany GmbH. All rights reserved.