You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

UnicodeCommentExtraField.java 2.7 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. package org.apache.tools.zip;
  19. /**
  20. * Info-ZIP Unicode Comment Extra Field (0x6375):
  21. *
  22. * <p>Stores the UTF-8 version of the file comment as stored in the
  23. * central directory header.</p>
  24. *
  25. * <pre>
  26. * Value Size Description
  27. * ----- ---- -----------
  28. * (UCom) 0x6375 Short tag for this extra block type ("uc")
  29. * TSize Short total data size for this block
  30. * Version 1 byte version of this extra field, currently 1
  31. * ComCRC32 4 bytes Comment Field CRC32 Checksum
  32. * UnicodeCom Variable UTF-8 version of the entry comment
  33. * </pre>
  34. */
  35. public class UnicodeCommentExtraField extends AbstractUnicodeExtraField {
  36. public static final ZipShort UCOM_ID = new ZipShort(0x6375);
  37. public UnicodeCommentExtraField () {
  38. }
  39. /**
  40. * Assemble as unicode comment extension from the name given as
  41. * text as well as the encoded bytes actually written to the archive.
  42. *
  43. * @param name The file name
  44. * @param bytes the bytes actually written to the archive
  45. * @param off The offset of the encoded comment in <code>bytes</code>.
  46. * @param len The length of the encoded comment or comment in
  47. * <code>bytes</code>.
  48. */
  49. public UnicodeCommentExtraField(String text, byte[] bytes, int off,
  50. int len) {
  51. super(text, bytes, off, len);
  52. }
  53. /**
  54. * Assemble as unicode comment extension from the comment given as
  55. * text as well as the bytes actually written to the archive.
  56. *
  57. * @param comment The file comment
  58. * @param bytes the bytes actually written to the archive
  59. */
  60. public UnicodeCommentExtraField(String comment, byte[] bytes) {
  61. super(comment, bytes);
  62. }
  63. public ZipShort getHeaderId() {
  64. return UCOM_ID;
  65. }
  66. }