public abstract class DocumentFormatInstance extends Object
Represents a specific format of a document. Implement this class to add your own document types.
Constructor and Description |
---|
DocumentFormatInstance() |
Modifier and Type | Method and Description |
---|---|
static DocumentFormatInstance |
createInstance(Class docType) |
static RedactorConfiguration |
getDefaultConfiguration()
Provides a singleton instance with default configuration of built-in formats.
|
String |
getPassword()
Gets a password for password protected documents.
|
void |
initialize(DocumentFormatConfiguration config)
Performs initialization of the instance of document format handler.
|
boolean |
isAccessGranted() |
void |
load(InputStream input)
Loads the document from a stream.
|
boolean |
performBinaryCheck(InputStream input)
Checks if the given stream contains a document, supported by this format instance.
|
abstract void |
save(OutputStream output)
Saves the document to a stream.
|
protected void |
setAccessGranted(boolean isGranted)
Sets a validation status, if the document requires password.
|
void |
setPassword(String value)
Sets a password for password protected documents.
|
public static DocumentFormatInstance createInstance(Class docType) throws Exception
Exception
public final String getPassword()
Gets a password for password protected documents.
public final void setPassword(String value)
Sets a password for password protected documents.
value
- A password for password protected documents.public final boolean isAccessGranted()
public void initialize(DocumentFormatConfiguration config)
Performs initialization of the instance of document format handler.
config
- Format configurationpublic void load(InputStream input) throws Exception
Loads the document from a stream.
input
- Stream to read fromException
public abstract void save(OutputStream output) throws Exception
Saves the document to a stream.
output
- Target stream to save the documentjava.lang.Exception;
Exception
protected final void setAccessGranted(boolean isGranted)
Sets a validation status, if the document requires password.
isGranted
- True, if password is correctpublic boolean performBinaryCheck(InputStream input) throws Exception
Checks if the given stream contains a document, supported by this format instance.
input
- Document content streamException
public static RedactorConfiguration getDefaultConfiguration()
Provides a singleton instance with default configuration of built-in formats.
Copyright © 2019. All rights reserved.