lv.eparaksts.edoc

## Interface EDoc2

- All Superinterfaces:
    Validatable

      public interface EDoc2
      extends Validatable

  An `EDoc2` represents interface for EDOC 2.0 document format. Use `EDoc2Builder` to create new or open existing documents.
  See Also:
    `EDoc2Builder.newEDoc()`, `EDoc2Builder.openEDoc(File)`, `EDoc2Builder.openEDoc(InputStream)`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `DataObject` | `addDataObject(File file)` Adds data object to the document from `File`
    `DataObject` | `addDataObject(InputStream inputStream, String name, String mimeType)` Adds data object to the document from `InputStream`
    `EDoc2BasicSignature` | `addSignature()` Adds a new signature to the document with default properties
    `EDoc2BasicSignature` | `addSignature(Map<String,String> properties)` Adds a new signature to the document with specified properties.
    `void` | `close()` Cleans all temporary files and frees resources
    `DataObject` | `getDataObject(int index)` Returns a data object by index of data object list of the document
    `int` | `getDataObjectCount()` Returns count of data objects of the document
    `EDoc2Signature` | `getSignature(int index)` Returns signature by index from the signature list of the document
    `EDoc2Signature` | `getSignature(String signatureId)` Returns signature by id from the signature list of the document
    `int` | `getSignatureCount()` Returns count of signatures of the document
    `String` | `getVersion()` Returns the document format version number
    `void` | `removeDataObject(int index)` Removes a data object from the document by index of the document's data object list
    `void` | `removeSignature(int index)` Removes signature from the document by index of the signature list
    `void` | `removeSignature(String signatureId)` Removes signature from the document by id of the signature list
    `void` | `writeTo(File file)` Validates all signature states and writes the document content to file.
    `void` | `writeTo(OutputStream outputStream)` Validates all signature states and writes the document content to output stream.

    - ### Methods inherited from interface lv.eparaksts.validation.Validatable

      `validate, validate`

- - ### Method Detail

    - #### addDataObject

          DataObject addDataObject(File file)
                            throws EDoc2Exception

      Adds data object to the document from `File`
      Parameters:
        `file` - data file
      Returns:
        added data object reference
      Throws:
        `EDoc2Exception` - if an error occurs.

    - #### addDataObject

          DataObject addDataObject(InputStream inputStream,
                                   String name,
                                   String mimeType)
                            throws EDoc2Exception

      Adds data object to the document from `InputStream`
      Parameters:
        `inputStream` - Input stream of the data object
        `name` - name of the data object
        `mimeType` - mime type of the data object
      Returns:
        added data object reference
      Throws:
        `EDoc2Exception` - if an error occurs.

    - #### getDataObjectCount

          int getDataObjectCount()

      Returns count of data objects of the document
      Returns:
        count of data objects

    - #### getDataObject

          DataObject getDataObject(int index)

      Returns a data object by index of data object list of the document
      Parameters:
        `index` - index of the data object of the document's data object list
      Returns:
        data object
      Throws:
        `IndexOutOfBoundsException` - if index is out of bounds.

    - #### removeDataObject

          void removeDataObject(int index)
                         throws EDoc2Exception

      Removes a data object from the document by index of the document's data object list
      Parameters:
        `index` - index of the data object of the document's data object list
      Throws:
        `EDoc2Exception` - if an error occurs.

    - #### addSignature

          EDoc2BasicSignature addSignature()
                                    throws EDoc2Exception

      Adds a new signature to the document with default properties
      Returns:
        BASIC profile signature interface
      Throws:
        `EDoc2Exception` - if an error occurs.
      See Also:
        `SignatureProfile`

    - #### addSignature

          EDoc2BasicSignature addSignature(Map<String,String> properties)
                                    throws EDoc2Exception

      Adds a new signature to the document with specified properties. Properties can be used to override the default configuration of the new signature.
      Parameters:
        `properties` -
      Returns:
        BASIC signature profile interface
      Throws:
        `EDoc2Exception` - if an error occurs.
      See Also:
        `SignatureProfile`, `EDoc2Signature.KEY_SIGNATURE_METHOD_URI`

    - #### getSignatureCount

          int getSignatureCount()

      Returns count of signatures of the document
      Returns:
        count of signatures

    - #### getSignature

          EDoc2Signature getSignature(int index)

      Returns signature by index from the signature list of the document
      Parameters:
        `index` - index from signature list of the document
      Returns:
        `null` if index is out of bounds

    - #### getSignature

          EDoc2Signature getSignature(String signatureId)

      Returns signature by id from the signature list of the document
      Parameters:
        `signatureId` - id from signature list of the document
      Returns:
        `null` if id is unknown

    - #### removeSignature

          void removeSignature(int index)
                        throws EDoc2Exception

      Removes signature from the document by index of the signature list
      Parameters:
        `index` - index from signature list of the document
      Throws:
        `EDoc2Exception` - if could not remove the signature.

    - #### removeSignature

          void removeSignature(String signatureId)
                        throws EDoc2Exception

      Removes signature from the document by id of the signature list
      Parameters:
        `signatureId` - id from signature list of the document
      Throws:
        `EDoc2Exception` - if could not remove the signature.

    - #### getVersion

          String getVersion()

      Returns the document format version number
      Returns:
        document format version number

    - #### writeTo

          void writeTo(File file)
                throws EDoc2Exception

      Validates all signature states and writes the document content to file.
      Parameters:
        `file` - output file.
      Throws:
        `EDoc2Exception` - if any of signature is not completed.

    - #### writeTo

          void writeTo(OutputStream outputStream)
                throws EDoc2Exception

      Validates all signature states and writes the document content to output stream.
      Parameters:
        `outputStream` - write destination.
      Throws:
        `EDoc2Exception` - if any of signature is not completed.
      See Also:
        `EDoc2Signature.complete()`

    - #### close

          void close()
              throws EDoc2Exception

      Cleans all temporary files and frees resources
      Throws:
        `EDoc2Exception` - if an error occurs.

Copyright VAS Latvijas Valsts radio un televizijas centrs / Developed by SIA EUSO