public abstract class ContainerBuilder extends Object
Here's an example of creating a new container:
Container
container = ContainerBuilder
.
aContainer("BDOC")
.
withConfiguration(configuration)
. // Configuration settings
withDataFile("testFiles/legal_contract_1.txt", "text/plain")
. // Adding a document from a hard drive
withDataFile(inputStream, "legal_contract_2.txt", "text/plain")
. // Adding a document from a stream
withTimeStampToken(DigestAlgorithm digestAlgorithm)
. // (DEPRECATED) Adding timestamp token in case of ASICS
build()
;
Use ContainerBuilder.aContainer()
to create a new container builder, populate the builder with data and
finally call build()
to create the container with the populated data.
Use fromExistingFile(String)
or fromStream(InputStream)
to open an existing container.
Modifier and Type | Class and Description |
---|---|
static class |
ContainerBuilder.ContainerDataFile |
Constructor and Description |
---|
ContainerBuilder() |
Modifier and Type | Method and Description |
---|---|
static ContainerBuilder |
aContainer()
Create a new ASICE container builder.
|
static ContainerBuilder |
aContainer(Container.DocumentType type)
Create a new container builder based on a container type.
|
static ContainerBuilder |
aContainer(String type)
Create a new container builder based on a container type.
|
Container |
build()
Builds a new container or opens existing container from the parameters given to the builder.
|
ContainerBuilder |
fromExistingFile(String filePath)
Open container from an existing file.
|
ContainerBuilder |
fromStream(InputStream containerInputStream)
Open container from a stream.
|
static void |
removeCustomContainerImplementations()
Clear the list of custom container implementations and types
and continue using the default container types and implementations.
|
static <T extends Container> |
setContainerImplementation(String containerType,
Class<T> containerClass)
Set a custom container implementation class to be used for the container type.
|
abstract ContainerBuilder |
usingTempDirectory(String temporaryDirectoryPath) |
ContainerBuilder |
withConfiguration(Configuration configuration)
Specify configuration for the container.
|
ContainerBuilder |
withDataFile(DataFile dataFile)
Add a data file to the container.
|
ContainerBuilder |
withDataFile(File file,
String mimeType)
Add a data file to the container.
|
ContainerBuilder |
withDataFile(InputStream inputStream,
String fileName,
String mimeType)
Add a data file from a stream to the container.
|
ContainerBuilder |
withDataFile(String filePath,
String mimeType)
Add a data file to the container.
|
ContainerBuilder |
withTimeStampToken(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm)
Deprecated.
Deprecated for removal
|
public static ContainerBuilder aContainer()
public static ContainerBuilder aContainer(String type)
type
- a type of container to be created, e.g. "BDOC(ASICE)", "ASICS" or "DDOC".public static ContainerBuilder aContainer(Container.DocumentType type)
type
- a type of container to be created, e.g. "BDOC(ASICE)", "ASICS" or "DDOC".public Container build()
public ContainerBuilder withConfiguration(Configuration configuration)
configuration
- configuration to use for creating the container.public ContainerBuilder withDataFile(String filePath, String mimeType) throws InvalidDataFileException
filePath
- data file location on the disk.mimeType
- MIME type of the data file, for example 'text/plain' or 'application/msword'InvalidDataFileException
public ContainerBuilder withDataFile(InputStream inputStream, String fileName, String mimeType) throws InvalidDataFileException
inputStream
- stream of a data file to be added to the container.fileName
- name of the data file to be added.mimeType
- MIME type of the data file, for example 'text/plain' or 'application/msword'InvalidDataFileException
public ContainerBuilder withDataFile(File file, String mimeType) throws InvalidDataFileException
file
- data file to be added to the container.mimeType
- MIME type of the data file, for example 'text/plain' or 'application/msword'InvalidDataFileException
public ContainerBuilder withDataFile(DataFile dataFile)
dataFile
- data file to be added to the container.@Deprecated public ContainerBuilder withTimeStampToken(eu.europa.esig.dss.enumerations.DigestAlgorithm digestAlgorithm)
digestAlgorithm
- public ContainerBuilder fromExistingFile(String filePath)
filePath
- absolute path to the container file.public ContainerBuilder fromStream(InputStream containerInputStream)
containerInputStream
- stream of the container file to be opened.public static <T extends Container> void setContainerImplementation(String containerType, Class<T> containerClass)
T
- container class extending the Container interface.containerType
- container type name used when handling such containers.containerClass
- container implementation for handling such container types.Container
public static void removeCustomContainerImplementations()
public abstract ContainerBuilder usingTempDirectory(String temporaryDirectoryPath)
Copyright © 2023. All rights reserved.