UnicodeCommentExtraField.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one
  3.  * or more contributor license agreements.  See the NOTICE file
  4.  * distributed with this work for additional information
  5.  * regarding copyright ownership.  The ASF licenses this file
  6.  * to you under the Apache License, Version 2.0 (the
  7.  * "License"); you may not use this file except in compliance
  8.  * with the License.  You may obtain a copy of the License at
  9.  *
  10.  *   https://www.apache.org/licenses/LICENSE-2.0
  11.  *
  12.  * Unless required by applicable law or agreed to in writing,
  13.  * software distributed under the License is distributed on an
  14.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15.  * KIND, either express or implied.  See the License for the
  16.  * specific language governing permissions and limitations
  17.  * under the License.
  18.  */

  19. package org.apache.commons.compress.archivers.zip;

  20. /**
  21.  * Info-ZIP Unicode Comment Extra Field (0x6375):
  22.  *
  23.  * <p>
  24.  * Stores the UTF-8 version of the file comment as stored in the central directory header.
  25.  * </p>
  26.  *
  27.  * @see <a href="https://www.pkware.com/documents/casestudies/APPNOTE.TXT">PKWARE APPNOTE.TXT, section 4.6.8</a>
  28.  * @NotThreadSafe super-class is not thread-safe
  29.  */
  30. public class UnicodeCommentExtraField extends AbstractUnicodeExtraField {

  31.     /**
  32.      * Field ID.
  33.      */
  34.     public static final ZipShort UCOM_ID = new ZipShort(0x6375);

  35.     /**
  36.      * Constructs a new instance.
  37.      */
  38.     public UnicodeCommentExtraField() {
  39.     }

  40.     /**
  41.      * Constructs a new instance as Unicode comment extension from the comment given as text as well as the bytes actually written to the archive.
  42.      *
  43.      * @param comment The file comment
  44.      * @param bytes   the bytes actually written to the archive
  45.      */
  46.     public UnicodeCommentExtraField(final String comment, final byte[] bytes) {
  47.         super(comment, bytes);
  48.     }

  49.     /**
  50.      * Assemble as Unicode comment extension from the name given as text as well as the encoded bytes actually written to the archive.
  51.      *
  52.      * @param text  The file name
  53.      * @param bytes the bytes actually written to the archive
  54.      * @param off   The offset of the encoded comment in {@code bytes}.
  55.      * @param len   The length of the encoded comment or comment in {@code bytes}.
  56.      */
  57.     public UnicodeCommentExtraField(final String text, final byte[] bytes, final int off, final int len) {
  58.         super(text, bytes, off, len);
  59.     }

  60.     @Override
  61.     public ZipShort getHeaderId() {
  62.         return UCOM_ID;
  63.     }

  64. }