On 2010-07-22, Torsten Curdt wrote:

>> Between 1.0 and 1.1 I pushed getLastModifiedDate into ArchiveEntry to
>> simplify a very common case.

> Maybe we should add some more there.

>>> If a particular ArchiveEntry doesn't support e.g. getGroup() it would
>>> just return null ...but I am a little back and forth on this. Mostly
>>> because of methods returning primitives

>> I solved this by returning Interger.MIN_VALUE - the group id should
>> never be < 0 anyway.

> True. But this doesn't necessarily work for all primitives. I guess we
> could return Objects.

Just tossing out ideas

class OwnerInformation {
    int getUserId();
    int getGroupId();
    String getUserName();
    String getGroupName();
}

class ArchiveEntry {
    OwnerInformation getOwner();
}

ZIP would return null on getOwner, AR and CPIO return null in the *Name
methods.

>>> ...and the bloat of the interface.

>> That's been my main concern as well and that's why I stopped with the
>> last modified date.

> Right. What we could think of is to delegate the metadata by type.

>   entry.getUnixMetadata()

POSIX rather than Unix.

I had a look at
http://download.java.net/jdk7/docs/api/java/nio/file/attribute/PosixFileAttributes.html
and somewhat like the approach of having a Set of permissions rather
than a multitude of canOwnerRead() type of methods - even if we can't
use generics or enums.

class PosixAttributes {
    /* nine constants */
    static final int OWNER_CAN_READ = ...

    /* set of the constants that apply */
    Set getPermissions();

    /* could be mixed with permissions if we wanted to */
    Boolean isSetUserId();
    Boolean isSetGroupId();
    Boolean hasStickyBit();

    /* TAR, AR and CPIO know these as well */
    Boolean isSymbolicLink();
    Boolean isRegularFile();

    // redundant
    boolean isDirectory();

    // unlikely to appear in a real archive but TAR and CPIO support devices
    Boolean isSocket();
    Boolean isBlockDevice();
    Boolean isCharacterDevice();
    Boolean isFifo();

    /* convenience method that re-creates the numeric mode field from
       permissions, file flags and bits */
    int asMode();

    /* TAR and CPIO know these as well */
    Integer getDeviceMajorNumber();
    Integer getDeviceMinorNumber();
}

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to