Tabnine Logo
ExtraFields
Code IndexAdd Tabnine to your IDE (free)

How to use
ExtraFields
in
de.schlichtherle.truezip.zip

Best Java code snippets using de.schlichtherle.truezip.zip.ExtraFields (Showing top 15 results out of 315)

origin: de.schlichtherle.truezip/truezip-driver-zip

private byte[] getExtraFields(final boolean zip64) {
  ExtraFields fields = this.fields;
  if (zip64) {
    final ExtraField field = composeZip64ExtraField();
    if (null != field) {
      fields = null != fields ? fields.clone() : new ExtraFields();
      fields.add(field);
    }
  } else {
    assert null == fields || null == fields.get(ZIP64_HEADER_ID);
  }
  return null == fields ? EMPTY : fields.getExtra();
}
origin: de.schlichtherle.truezip/truezip-driver-zip

/**
 * Returns a protective copy of the Extra Fields.
 * {@code null} is never returned.
 *
 * @see #getExtraLength
 */
byte[] getExtra() {
  final int size = getExtraLength();
  assert UShort.check(size);
  if (0 == size)
    return EMPTY;
  final byte[] data = new byte[size];
  writeTo(data, 0);
  return data;
}
origin: de.schlichtherle.truezip/truezip-driver-zip

final @Nullable ExtraField removeExtraField(final int headerId) {
  final ExtraFields fields = this.fields;
  return null != fields ? fields.remove(headerId) : null;
}
origin: stackoverflow.com

 public class Subclass1 extends Superclass1
{
  private ExtraFields extraFields;

  public MySubclass()
  {
    super();
    extraFields = new ExtraFields();
  }

  public void doSomethingWithExtraFields()
  {
    extraFields.doSomethingWithExtraFields();
  }
}
origin: de.schlichtherle.truezip/truezip-driver-zip

final @Nullable ExtraField addExtraField(final ExtraField field) {
  assert null != field;
  ExtraFields fields = this.fields;
  if (null == fields)
    this.fields = fields = new ExtraFields();
  return fields.add(field);
}
origin: de.schlichtherle.truezip/truezip-driver-zip

@Test
public void testCollection0() {
  fields.readFrom(serialized, 0, serialized.length);
  final ExtraField ef = fields.get(ExtraField.ZIP64_HEADER_ID);
  assertNotNull(ef);
  assertSame(ef, fields.remove(ExtraField.ZIP64_HEADER_ID));
  assertNull(fields.get(ExtraField.ZIP64_HEADER_ID));
  assertNull(fields.add(ef));
  final byte[] got = fields.getExtra();
  assertNotSame(serialized, got);
  assertTrue(Arrays.equals(serialized, got));
}
origin: de.schlichtherle.truezip/truezip-driver-zip

/**
 * @throws IllegalArgumentException if the serialized extra fields do not
 *         conform to the ZIP File Format Specification.
 */
private void setExtraFields(final byte[] buf, final boolean zip64)
throws IllegalArgumentException {
  assert UShort.check(buf.length);
  if (0 < buf.length) {
    final ExtraFields fields = new ExtraFields();
    try {
      fields.readFrom(buf, 0, buf.length);
      if (zip64) parseZip64ExtraField(fields);
    } catch (final IndexOutOfBoundsException ex) {
      throw new IllegalArgumentException(ex);
    }
    fields.remove(ZIP64_HEADER_ID);
    this.fields = 0 < fields.size() ? fields : null;
  } else {
    this.fields = null;
  }
}
origin: de.schlichtherle.truezip/truezip-driver-zip

@Test
public void testGetSet() {
  assertEquals(0, fields.getExtra().length);
  fields.readFrom(serialized, 0, serialized.length);
  assertEquals(serialized.length, fields.getExtraLength());
  serialized[0] = (byte) 0xff;
  byte[] got1 = fields.getExtra();
  assertNotNull(got1);
  assertNotSame(serialized, got1);
  final byte[] got2 = fields.getExtra();
  assertNotNull(got2);
  assertNotSame(serialized, got2);
  assertNotSame(got1, got2);
  serialized[0] = (byte) 0x00;
  assertTrue(Arrays.equals(serialized, got1));
  assertTrue(Arrays.equals(serialized, got2));
}
origin: stackoverflow.com

 public class Wrapper<T>  // Don't use this name either...
{
  private ExtraFields extraFields;
  private T myClass;

  public Wrapper(T myClass) {
    this.myClass = myClass;
    this.extraFields = new ExtraFields();
  }
}
origin: de.schlichtherle.truezip/truezip-driver-zip

final @Nullable ExtraField getExtraField(int headerId) {
  final ExtraFields fields = this.fields;
  return fields == null ? null : fields.get(headerId);
}
origin: de.schlichtherle.truezip/truezip-driver-zip

@Override
@SuppressWarnings("AccessingNonPublicFieldOfAnotherObject")
public ZipEntry clone() {
  final ZipEntry entry;
  try {
    entry = (ZipEntry) super.clone();
  } catch (CloneNotSupportedException ex) {
    throw new AssertionError(ex);
  }
  final ExtraFields fields = this.fields;
  entry.fields = fields == null ? null : fields.clone();
  return entry;
}
origin: de.schlichtherle.truezip/truezip-driver-zip

  @Test
  public void testCollection1() {
    assertEquals(0, fields.getExtra().length);
    final ExtraField ef = new DefaultExtraField(ExtraField.ZIP64_HEADER_ID);
    assertNull(fields.get(ExtraField.ZIP64_HEADER_ID));
    assertNull(fields.add(ef));
    byte[] got = fields.getExtra();
    assertEquals(4 + ef.getDataSize(), got.length);
    assertSame(ef, fields.remove(ExtraField.ZIP64_HEADER_ID));
    assertEquals(0, fields.getExtra().length);
  }
}
origin: de.schlichtherle.truezip/truezip-driver-zip

@Before
public void setUp() {
  fields = new ExtraFields();
  serialized = SERIALIZED.clone();
}
origin: de.schlichtherle.truezip/truezip-driver-zip

final ExtraField ef = fields.get(ZIP64_HEADER_ID);
if (null == ef) return;
final byte[] data = ef.getDataBlock();
origin: de.schlichtherle.truezip/truezip-driver-zip

/**
 * Constructs a new ZIP entry with the given name and all other properties
 * copied from the given template.
 */
@SuppressWarnings("AccessingNonPublicFieldOfAnotherObject")
protected ZipEntry(final String name, final ZipEntry template) {
  UShort.check(name.length());
  this.init = template.init;
  this.name = name;
  this.platform = template.platform;
  this.general = template.general;
  this.method = template.method;
  this.dtime = template.dtime;
  this.crc = template.crc;
  this.csize = template.csize;
  this.size = template.size;
  this.eattr = template.eattr;
  this.offset = template.offset;
  final ExtraFields templateFields = template.fields;
  this.fields = templateFields == null ? null : templateFields.clone();
  this.comment = template.comment;
}
de.schlichtherle.truezip.zipExtraFields

Javadoc

Represents a collection of ExtraField as they may be present at several locations in ZIP files.

Most used methods

  • <init>
  • add
    Stores the given Extra Field in this collection.
  • get
    Returns the Extra Field with the given Header ID or nullif no such Extra Field exists.
  • getExtra
    Returns a protective copy of the Extra Fields. null is never returned.
  • getExtraLength
    Returns the number of bytes required to hold the Extra Fields.
  • readFrom
    Deserializes this collection of extra fields from the data block starting at the zero based offset o
  • remove
    Removes the Extra Field with the given Header ID.
  • clone
    Returns a shallow clone of this collection.
  • doSomethingWithExtraFields
  • size
    Returns the number of Extra Fields in this collection.
  • writeTo
    Serializes a list of Extra Fields of #getExtraLength bytes to the byte array data at the zero based
  • writeTo

Popular in Java

  • Creating JSON documents from java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSupportFragmentManager (FragmentActivity)
  • getContentResolver (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • JCheckBox (javax.swing)
  • JComboBox (javax.swing)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now