public abstract class DocumentFormatInstance extends Object
Represents a specific format of a document. Implement this class to add your own document types.
Learn more
The following example demonstrates how to create an empty stub for a custom format handler.
public class DummyDocument extends DocumentFormatInstance
{
{@literal @}Override
public void load(InputStream output) throws java.lang.Exception
{
// load file content
}
{@literal @}Override
public void save(OutputStream output) throws java.lang.Exception
{
// save changes to file;
}
}
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.
|
boolean |
getRequiresRasterization()
Gets value, indicating if the format instance is read-only and cannot be saved in original format.
|
void |
initialize(DocumentFormatConfiguration config,
RedactorSettings settings)
Performs initialization of the instance of document format handler.
|
boolean |
isAccessGranted() |
boolean |
isRedactionAccepted(RedactionDescription description)
Checks for
IRedactionCallback implementation and invokes it, if specified. |
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 boolean getRequiresRasterization()
Gets value, indicating if the format instance is read-only and cannot be saved in original format.
public final boolean isAccessGranted()
public void initialize(DocumentFormatConfiguration config, RedactorSettings settings)
Performs initialization of the instance of document format handler.
config
- Format configurationsettings
- Default settings for redaction process.public 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 final boolean isRedactionAccepted(RedactionDescription description)
Checks for IRedactionCallback
implementation and invokes it, if specified.
description
- Redaction descriptionpublic 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.