Index: src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java =================================================================== --- src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java (revision 1148778) +++ src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveEntry.java (working copy) @@ -20,6 +20,7 @@ import java.util.Date; import org.apache.commons.compress.archivers.ArchiveEntry; +import org.apache.commons.compress.archivers.OwnerInformation; public final class MemoryArchiveEntry implements ArchiveEntry { @@ -47,4 +48,9 @@ public Date getLastModifiedDate() { return new Date(); } + + /** {@inheritDoc} */ + public OwnerInformation getOwner() { + return null; + } } Index: src/main/java/org/apache/commons/compress/archivers/OwnerInformation.java =================================================================== --- src/main/java/org/apache/commons/compress/archivers/OwnerInformation.java (revision 0) +++ src/main/java/org/apache/commons/compress/archivers/OwnerInformation.java (revision 0) @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.commons.compress.archivers; + +/** + * Provides owner (user and group) information about an archive entry. + * + *
Some archive formats may not be able to store the information + * and will return null for the missing pieces.
+ * + * @since Apache Commons Compress 1.2 + * + * @Immutable + */ +public class OwnerInformation { + private final Integer userId, groupId; + private final String userName, groupName; + + /** + * Creates an instance with known numeric ids but unknown names. + */ + public OwnerInformation(int userId, int groupId) { + this(userId, null, groupId, null); + } + + /** + * Creates an instance with known numeric ids and potentially + * unknown names. + */ + public OwnerInformation(int userId, String userName, + int groupId, String groupName) { + this(Integer.valueOf(userId), userName, + Integer.valueOf(groupId), groupName); + } + + /** + * Creates an instance with potentially unknown numeric ids and + * names. + */ + public OwnerInformation(Integer userId, String userName, + Integer groupId, String groupName) { + this.userId = userId; + this.userName = userName; + this.groupId = groupId; + this.groupName = groupName; + } + + /** + * The numeric id of the user. + */ + public Integer getUserId() { + return userId; + } + + /** + * The name id of the user. + */ + public String getUserName() { + return userName; + } + + /** + * The numeric id of the group. + */ + public Integer getGroupId() { + return groupId; + } + + /** + * The name id of the group. + */ + public String getGroupName() { + return groupName; + } +} \ No newline at end of file Property changes on: src\main\java\org\apache\commons\compress\archivers\OwnerInformation.java ___________________________________________________________________ Added: svn:eol-style + native Index: src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java =================================================================== --- src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java (revision 1148784) +++ src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveEntry.java (working copy) @@ -22,6 +22,7 @@ import java.util.Date; import org.apache.commons.compress.archivers.ArchiveEntry; +import org.apache.commons.compress.archivers.OwnerInformation; /** * Represents an archive entry in the "ar" format. @@ -144,6 +145,17 @@ return lastModified; } + /** + * The owner of the entry. + * + *This implementation will only return numeric ids.
+ * + * @since Apache Commons Compress 1.2 + */ + public OwnerInformation getOwner() { + return new OwnerInformation(getUserId(), getGroupId()); + } + /** {@inheritDoc} */ public Date getLastModifiedDate() { return new Date(1000 * getLastModified()); Index: src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java =================================================================== --- src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java (revision 1148778) +++ src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveEntry.java (working copy) @@ -25,6 +25,7 @@ import java.util.List; import java.util.zip.ZipException; import org.apache.commons.compress.archivers.ArchiveEntry; +import org.apache.commons.compress.archivers.OwnerInformation; /** * Extension that adds better handling of extra fields and provides @@ -565,6 +566,17 @@ return new Date(getTime()); } + /** + * The owner of the entry. + * + *This implementation always returns null.
+ * + * @since Apache Commons Compress 1.2 + */ + public OwnerInformation getOwner() { + return null; + } + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ Index: src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java =================================================================== --- src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java (revision 1148778) +++ src/main/java/org/apache/commons/compress/archivers/ArchiveEntry.java (working copy) @@ -43,4 +43,14 @@ * @since Apache Commons Compress 1.1 */ public Date getLastModifiedDate(); + + /** + * The owner of the entry. + * + *Depending on the archive type this information may not be + * available at all, in which case the method returns null.
+ * + * @since Apache Commons Compress 1.2 + */ + public OwnerInformation getOwner(); } Index: src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java =================================================================== --- src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (revision 1148778) +++ src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (working copy) @@ -23,6 +23,7 @@ import java.util.Locale; import org.apache.commons.compress.archivers.ArchiveEntry; +import org.apache.commons.compress.archivers.OwnerInformation; /** * This class represents an entry in a Tar archive. It consists @@ -498,6 +499,19 @@ } /** + * The owner of the entry. + * + *This implementation should return complete information + * including numeric ids and names.
+ * + * @since Apache Commons Compress 1.2 + */ + public OwnerInformation getOwner() { + return new OwnerInformation(getUserId(), getUserName(), getGroupId(), + getGroupName()); + } + + /** * Get this entry's file. * * @return This entry's file. Index: src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java =================================================================== --- src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java (revision 1148778) +++ src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java (working copy) @@ -22,6 +22,7 @@ import java.util.Date; import org.apache.commons.compress.archivers.ArchiveEntry; +import org.apache.commons.compress.archivers.OwnerInformation; /** * A cpio archive consists of a sequence of files. There are several types of @@ -583,6 +584,17 @@ } /** + * The owner of the entry. + * + *This implementation will only return numeric ids.
+ * + * @since Apache Commons Compress 1.2 + */ + public OwnerInformation getOwner() { + return new OwnerInformation((int) getUID(), (int) getGID()); + } + + /** * Get the user id. * * @return Returns the user id.