All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.schlichtherle.truezip.fs.archive.zip.ZipDriverEntry Maven / Gradle / Ivy

Go to download

The file system driver family for ZIP and related archive file types. Add the JAR artifact of this module to the run time class path to make its file system drivers available for service location in the client API modules.

There is a newer version: 7.7.10
Show newest version
/*
 * Copyright (C) 2005-2013 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package de.schlichtherle.truezip.fs.archive.zip;

import static de.schlichtherle.truezip.entry.Entry.Access.WRITE;
import static de.schlichtherle.truezip.entry.Entry.Size.DATA;
import static de.schlichtherle.truezip.entry.Entry.Type.DIRECTORY;
import static de.schlichtherle.truezip.entry.Entry.Type.FILE;
import de.schlichtherle.truezip.fs.FsArchiveEntries;
import de.schlichtherle.truezip.fs.FsArchiveEntry;
import de.schlichtherle.truezip.zip.DateTimeConverter;
import de.schlichtherle.truezip.zip.ZipEntry;

/**
 * ZIP archive entries apply the date/time conversion rules as defined by
 * {@link DateTimeConverter#ZIP}.
 *
 * @see    #getDateTimeConverter()
 * @see    ZipDriver
 * @author Christian Schlichtherle
 */
public class ZipDriverEntry extends ZipEntry implements FsArchiveEntry {

    public ZipDriverEntry(String name) {
        super(name);
    }

    protected ZipDriverEntry(String name, ZipEntry template) {
        super(name, template);
    }

    @Override
    public Type getType() {
        return isDirectory() ? DIRECTORY : FILE;
    }

    /**
     * Returns a {@link DateTimeConverter} for the conversion of Java time
     * to DOS date/time fields and vice versa.
     * 

* The implementation in the class {@link ZipDriverEntry} returns * {@link DateTimeConverter#ZIP}. * * @return {@link DateTimeConverter#ZIP} */ @Override protected DateTimeConverter getDateTimeConverter() { return DateTimeConverter.ZIP; } @Override public long getSize(final Size type) { switch (type) { case DATA: return getSize(); case STORAGE: return getCompressedSize(); default: return FsArchiveEntry.UNKNOWN; } } @Override public boolean setSize(final Size type, final long size) { if (DATA != type) return false; setSize(size); return true; } @Override public long getTime(Access type) { if (WRITE != type) return FsArchiveEntry.UNKNOWN; long time = getTime(); return 0 <= time ? time : FsArchiveEntry.UNKNOWN; } @Override public boolean setTime(Access type, long time) { if (WRITE != type) return false; setTime(time); return true; } /** * Returns a string representation of this object for debugging and logging * purposes. */ @Override public String toString() { return FsArchiveEntries.toString(this); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy