Package org.digidoc4j
Class CompositeContainerBuilder
java.lang.Object
org.digidoc4j.CompositeContainerBuilder
A builder for creating
CompositeContainer
s by nesting an existing container into another container.
A nested inner container becomes a data file for the nesting outer container.
The builder can be created from either:
- an existing
Container
object viafromContainer(Container, String)
- a path to an existing container file via
fromContainerFile(String)
- an input stream of an existing container via
fromContainerStream(InputStream, String)
The builder currently supports creating:
- a timestamped ASiC-S container via
buildTimestamped(Consumer)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuildTimestamped
(Consumer<TimestampBuilder> timestampBuilderConfigurator) Builds a timestamped composite container.static CompositeContainerBuilder
fromContainer
(Container container, String containerFileName) Creates an instance of a composite container builder from an existingContainer
object.static CompositeContainerBuilder
fromContainerFile
(String containerFilePath) Creates an instance of a composite container builder from an existing container file.static CompositeContainerBuilder
fromContainerStream
(InputStream containerInputStream, String containerFileName) Creates an instance of a composite container builder from the input stream of an existing container.withConfiguration
(Configuration configuration) Specifies the configuration to be used by the container being built.
-
Method Details
-
fromContainer
public static CompositeContainerBuilder fromContainer(Container container, String containerFileName) Creates an instance of a composite container builder from an existingContainer
object. The specified container will be nested as a data file into a nesting composite container. The name of the data file will be specified bycontainerFileName
parameter.NB:
- The specified nested container must support serialization via
Container.saveAsStream()
! - In case the to-be-nested container has already been serialized and it does not need any further modifications,
it is recommended to use
fromContainerFile(String)
orfromContainerStream(InputStream, String)
instead.Container.saveAsStream()
may produce a binary representation that is not identical to the original serialized form of the container! - The composite container this builder will create, will use the same configuration as the specified
to-be-nested container uses, unless overridden via
withConfiguration(Configuration)
.
- Parameters:
container
- an existing container object to be nestedcontainerFileName
- file name of the to-be-nested container- Returns:
- builder for creating a composite container
- The specified nested container must support serialization via
-
fromContainerFile
Creates an instance of a composite container builder from an existing container file. The specified container will be nested as a data file into a nesting composite container. The name of the data file will be determined from the specified file path.- Parameters:
containerFilePath
- path to an existing container file to be nested- Returns:
- builder for creating a composite container
-
fromContainerStream
public static CompositeContainerBuilder fromContainerStream(InputStream containerInputStream, String containerFileName) Creates an instance of a composite container builder from the input stream of an existing container. The specified container will be nested as a data file into a nesting composite container. The name of the data file will be specified bycontainerFileName
parameter.- Parameters:
containerInputStream
- input stream of an existing container to be nestedcontainerFileName
- file name of the to-be-nested container- Returns:
- builder for creating a composite container
-
buildTimestamped
Builds a timestamped composite container. The resulting composite container will contain the initially specified container as its data file, which will be covered by a freshly taken timestamp token. The type of the resulting container will be ASiC-S.NB: The specified timestamp builder configurator should not call
TimestampBuilder.invokeTimestamping()
directly!- Parameters:
timestampBuilderConfigurator
- callback for configuring the timestamp builder used for creating a timestamp- Returns:
- timestamped composite container
- See Also:
-
withConfiguration
Specifies the configuration to be used by the container being built.- Parameters:
configuration
- configuration to use for building the container- Returns:
- this builder
-