DocumentFormatInstance

Inheritance: java.lang.Object

public abstract class DocumentFormatInstance

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;
     }
 }
 

Constructors

Constructor Description
DocumentFormatInstance()

Methods

Method Description
createInstance(Class docType)
getPassword() Gets a password for password protected documents.
setPassword(String value) Sets a password for password protected documents.
getRequiresRasterization() Gets value, indicating if the format instance is read-only and cannot be saved in original format.
isAccessGranted()
initialize(DocumentFormatConfiguration config, RedactorSettings settings) Performs initialization of the instance of document format handler.
load(InputStream input) Loads the document from a stream.
save(OutputStream output) Saves the document to a stream.
isRedactionAccepted(RedactionDescription description) Checks for IRedactionCallback implementation and invokes it, if specified.
performBinaryCheck(InputStream input) Checks if the given stream contains a document, supported by this format instance.
getDefaultConfiguration() Provides a singleton instance with default configuration of built-in formats.

DocumentFormatInstance()

public DocumentFormatInstance()

createInstance(Class docType)

public static DocumentFormatInstance createInstance(Class docType)

Parameters:

Parameter Type Description
docType java.lang.Class

Returns: DocumentFormatInstance

getPassword()

public final String getPassword()

Gets a password for password protected documents.

Returns: java.lang.String - A password for password protected documents.

setPassword(String value)

public final void setPassword(String value)

Sets a password for password protected documents.

Parameters:

Parameter Type Description
value java.lang.String A password for password protected documents.

getRequiresRasterization()

public boolean getRequiresRasterization()

Gets value, indicating if the format instance is read-only and cannot be saved in original format.

Returns: boolean - Value, indicating if the format instance is read-only and cannot be saved in original format.

isAccessGranted()

public final boolean isAccessGranted()

Returns: boolean

initialize(DocumentFormatConfiguration config, RedactorSettings settings)

public void initialize(DocumentFormatConfiguration config, RedactorSettings settings)

Performs initialization of the instance of document format handler.

Parameters:

Parameter Type Description
config DocumentFormatConfiguration Format configuration
settings RedactorSettings Default settings for redaction process.

load(InputStream input)

public void load(InputStream input)

Loads the document from a stream.

Parameters:

Parameter Type Description
input java.io.InputStream Stream to read from

save(OutputStream output)

public abstract void save(OutputStream output)

Saves the document to a stream.

Parameters:

Parameter Type Description
output java.io.OutputStream Target stream to save the document

isRedactionAccepted(RedactionDescription description)

public final boolean isRedactionAccepted(RedactionDescription description)

Checks for IRedactionCallback implementation and invokes it, if specified.

Parameters:

Parameter Type Description
description RedactionDescription Redaction description

Returns: boolean - True (by default) if redaction is accepted

performBinaryCheck(InputStream input)

public boolean performBinaryCheck(InputStream input)

Checks if the given stream contains a document, supported by this format instance.

Parameters:

Parameter Type Description
input java.io.InputStream Document content stream

Returns: boolean - True, if the document can be loaded by this format instance and false otherwise

getDefaultConfiguration()

public static RedactorConfiguration getDefaultConfiguration()

Provides a singleton instance with default configuration of built-in formats.

Returns: RedactorConfiguration - Configuration instance