= ZipWriter
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Zip utility for generating compressed output.

Typical use:

----

val zipWriter = ZipWriter.newInstance();

for (Map.Entry entry : schemaMap.entrySet()) {
     val namespaceUri = entry.getKey();
     val schemaText = entry.getValue();
     zipWriter.nextEntry(zipEntryNameFor(namespaceUri), writer->{
    	    writer.write(schemaText);
     });
}

return BlobClobFactory.blobZip(fileName, zipWriter.toBytes());
----

== API

[source,java]
.ZipWriter.java
----
class ZipWriter {
  ZipWriter newInstance()
  ZipWriter ofFailureMessage(String failureMessage)
  void nextEntry(String zipEntryName, OnZipEntry onZipEntry)     // <.>
  byte[] toBytes()     // <.>
}
----

<.> xref:#nextEntry_String_OnZipEntry[nextEntry(String, OnZipEntry)]
+
--
Adds a new zipEntry with given _zipEntryName_ , and provides the _OutputStreamWriter_ via _OnZipEntry_ for the consumer to write the actual (uncompressed) zip-entry content.
--
<.> xref:#toBytes_[toBytes()]
+
--
Terminal operation, closes the writer. Calling this operation multiple times, will return the same array instance object.
--

== Members

[#nextEntry_String_OnZipEntry]
=== nextEntry(String, OnZipEntry)

Adds a new zipEntry with given _zipEntryName_ , and provides the _OutputStreamWriter_ via _OnZipEntry_ for the consumer to write the actual (uncompressed) zip-entry content.

[#toBytes_]
=== toBytes()

Terminal operation, closes the writer. Calling this operation multiple times, will return the same array instance object.
