Class FileAttributes
- java.lang.Object
-
- org.codehaus.plexus.components.io.attributes.FileAttributes
-
- All Implemented Interfaces:
PlexusIoResourceAttributes
- Direct Known Subclasses:
UserGroupModeFileAttributes
public class FileAttributes extends java.lang.Object implements PlexusIoResourceAttributes
-
-
Field Summary
Fields Modifier and Type Field Description private booleandirectorystatic java.nio.file.LinkOption[]FOLLOW_LINK_OPTIONSprivate static java.util.Map<java.nio.file.FileSystem,java.util.Map<java.lang.Integer,java.lang.String>>GIDS_CACHEprivate java.lang.IntegergroupIdprivate java.lang.StringgroupNameprivate java.nio.file.attribute.FileTimelastModifiedTimestatic java.nio.file.LinkOption[]NOFOLLOW_LINK_OPTIONSprivate intoctalModeprivate booleanotherprivate java.util.Set<java.nio.file.attribute.PosixFilePermission>permissionsprivate booleanregularFileprivate longsizeprivate booleansymbolicLinkprivate static java.util.Map<java.nio.file.FileSystem,java.util.Map<java.lang.Integer,java.lang.String>>UIDS_CACHEprivate java.lang.IntegeruserIdprivate java.lang.StringuserName-
Fields inherited from interface org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes
UNKNOWN_OCTAL_MODE
-
-
Constructor Summary
Constructors Constructor Description FileAttributes(java.io.File file)FileAttributes(java.io.File file, boolean followLinks)FileAttributes(java.io.File file, java.util.Map<java.lang.Integer,java.lang.String> userCache, java.util.Map<java.lang.Integer,java.lang.String> groupCache)Deprecated.useFileAttributes(File)and remove the unused userCache and groupCache parametersFileAttributes(java.lang.Integer userId, java.lang.String userName, java.lang.Integer groupId, java.lang.String groupName, int octalMode, boolean symbolicLink, boolean regularFile, boolean directory, boolean other, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, long size, java.nio.file.attribute.FileTime lastModifiedTime)FileAttributes(java.nio.file.Path path, boolean followLinks)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcalculatePosixOctalMode()private booleancontainsPermission(java.nio.file.attribute.PosixFilePermission groupExecute)private static java.util.Map<java.lang.Integer,java.lang.String>getGroupCache(java.nio.file.FileSystem fs)java.lang.IntegergetGroupId()Gets the unix group id.java.lang.StringgetGroupName()The group name.java.nio.file.attribute.FileTimegetLastModifiedTime()intgetOctalMode()Octal mode attributes.java.lang.StringgetOctalModeString()protected java.util.Set<java.nio.file.attribute.PosixFilePermission>getPermissions()private static java.lang.StringgetPrincipalName(java.nio.file.Path path, java.lang.String attribute)longgetSize()private static java.util.Map<java.lang.Integer,java.lang.String>getUserCache(java.nio.file.FileSystem fs)java.lang.IntegergetUserId()Gets the unix user id.java.lang.StringgetUserName()Returns the user name of the user owning the file.booleanhasGroupId()booleanhasUserId()booleanisDirectory()booleanisGroupExecutable()booleanisGroupReadable()booleanisGroupWritable()booleanisOther()booleanisOwnerExecutable()booleanisOwnerReadable()booleanisOwnerWritable()booleanisRegularFile()booleanisSymbolicLink()Indicates if this is a symbolic link element.booleanisWorldExecutable()booleanisWorldReadable()booleanisWorldWritable()java.lang.StringtoString()static PlexusIoResourceAttributesuncached(java.io.File file)
-
-
-
Field Detail
-
FOLLOW_LINK_OPTIONS
public static final java.nio.file.LinkOption[] FOLLOW_LINK_OPTIONS
-
NOFOLLOW_LINK_OPTIONS
public static final java.nio.file.LinkOption[] NOFOLLOW_LINK_OPTIONS
-
groupId
@Nullable private final java.lang.Integer groupId
-
groupName
@Nullable private final java.lang.String groupName
-
userId
@Nullable private final java.lang.Integer userId
-
userName
private final java.lang.String userName
-
symbolicLink
private final boolean symbolicLink
-
regularFile
private final boolean regularFile
-
directory
private final boolean directory
-
other
private final boolean other
-
octalMode
private final int octalMode
-
permissions
private final java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions
-
size
private final long size
-
lastModifiedTime
private final java.nio.file.attribute.FileTime lastModifiedTime
-
UIDS_CACHE
private static final java.util.Map<java.nio.file.FileSystem,java.util.Map<java.lang.Integer,java.lang.String>> UIDS_CACHE
-
GIDS_CACHE
private static final java.util.Map<java.nio.file.FileSystem,java.util.Map<java.lang.Integer,java.lang.String>> GIDS_CACHE
-
-
Constructor Detail
-
FileAttributes
@Deprecated public FileAttributes(@Nonnull java.io.File file, @Nonnull java.util.Map<java.lang.Integer,java.lang.String> userCache, @Nonnull java.util.Map<java.lang.Integer,java.lang.String> groupCache) throws java.io.IOExceptionDeprecated.useFileAttributes(File)and remove the unused userCache and groupCache parameters- Throws:
java.io.IOException
-
FileAttributes
public FileAttributes(@Nonnull java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
FileAttributes
public FileAttributes(@Nonnull java.io.File file, boolean followLinks) throws java.io.IOException- Throws:
java.io.IOException
-
FileAttributes
public FileAttributes(@Nonnull java.nio.file.Path path, boolean followLinks) throws java.io.IOException- Throws:
java.io.IOException
-
FileAttributes
public FileAttributes(@Nullable java.lang.Integer userId, java.lang.String userName, @Nullable java.lang.Integer groupId, @Nullable java.lang.String groupName, int octalMode, boolean symbolicLink, boolean regularFile, boolean directory, boolean other, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, long size, java.nio.file.attribute.FileTime lastModifiedTime)
-
-
Method Detail
-
getUserCache
private static java.util.Map<java.lang.Integer,java.lang.String> getUserCache(java.nio.file.FileSystem fs)
-
getGroupCache
private static java.util.Map<java.lang.Integer,java.lang.String> getGroupCache(java.nio.file.FileSystem fs)
-
getPrincipalName
@Nullable private static java.lang.String getPrincipalName(java.nio.file.Path path, java.lang.String attribute)
-
uncached
@Nonnull public static PlexusIoResourceAttributes uncached(@Nonnull java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
getGroupId
@Nullable public java.lang.Integer getGroupId()
Description copied from interface:PlexusIoResourceAttributesGets the unix group id.- Specified by:
getGroupIdin interfacePlexusIoResourceAttributes- Returns:
- The unix group id, may be null ("not set"), even on unix
-
hasGroupId
public boolean hasGroupId()
-
hasUserId
public boolean hasUserId()
-
getGroupName
@Nullable public java.lang.String getGroupName()
Description copied from interface:PlexusIoResourceAttributesThe group name. May be null if groups are unsupported- Specified by:
getGroupNamein interfacePlexusIoResourceAttributes- Returns:
- the group names
-
getUserId
public java.lang.Integer getUserId()
Description copied from interface:PlexusIoResourceAttributesGets the unix user id.- Specified by:
getUserIdin interfacePlexusIoResourceAttributes- Returns:
- The unix user id, may be null ("not set"), even on unix
-
getUserName
public java.lang.String getUserName()
Description copied from interface:PlexusIoResourceAttributesReturns the user name of the user owning the file. Probably not null :)- Specified by:
getUserNamein interfacePlexusIoResourceAttributes- Returns:
- The user name
-
isGroupExecutable
public boolean isGroupExecutable()
- Specified by:
isGroupExecutablein interfacePlexusIoResourceAttributes
-
containsPermission
private boolean containsPermission(java.nio.file.attribute.PosixFilePermission groupExecute)
-
isGroupReadable
public boolean isGroupReadable()
- Specified by:
isGroupReadablein interfacePlexusIoResourceAttributes
-
isGroupWritable
public boolean isGroupWritable()
- Specified by:
isGroupWritablein interfacePlexusIoResourceAttributes
-
isOwnerExecutable
public boolean isOwnerExecutable()
- Specified by:
isOwnerExecutablein interfacePlexusIoResourceAttributes
-
isOwnerReadable
public boolean isOwnerReadable()
- Specified by:
isOwnerReadablein interfacePlexusIoResourceAttributes
-
isOwnerWritable
public boolean isOwnerWritable()
- Specified by:
isOwnerWritablein interfacePlexusIoResourceAttributes
-
isWorldExecutable
public boolean isWorldExecutable()
- Specified by:
isWorldExecutablein interfacePlexusIoResourceAttributes
-
isWorldReadable
public boolean isWorldReadable()
- Specified by:
isWorldReadablein interfacePlexusIoResourceAttributes
-
isWorldWritable
public boolean isWorldWritable()
- Specified by:
isWorldWritablein interfacePlexusIoResourceAttributes
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getOctalMode
public int getOctalMode()
Description copied from interface:PlexusIoResourceAttributesOctal mode attributes.PlexusIoResourceAttributes.UNKNOWN_OCTAL_MODEif unsupported on current file/file system- Specified by:
getOctalModein interfacePlexusIoResourceAttributes
-
calculatePosixOctalMode
public int calculatePosixOctalMode()
-
getOctalModeString
public java.lang.String getOctalModeString()
-
isSymbolicLink
public boolean isSymbolicLink()
Description copied from interface:PlexusIoResourceAttributesIndicates if this is a symbolic link element. For file-based resource attributes this value may be always "false" for versions prior to java7.- Specified by:
isSymbolicLinkin interfacePlexusIoResourceAttributes- Returns:
- True if the file is a symlink or false if not.
-
isRegularFile
public boolean isRegularFile()
-
isDirectory
public boolean isDirectory()
-
isOther
public boolean isOther()
-
getSize
public long getSize()
-
getLastModifiedTime
public java.nio.file.attribute.FileTime getLastModifiedTime()
-
getPermissions
protected java.util.Set<java.nio.file.attribute.PosixFilePermission> getPermissions()
-
-