org.apache.hadoop.fs
Class FileStatus

java.lang.Object
  extended by org.apache.hadoop.fs.FileStatus
All Implemented Interfaces:
Comparable, Writable
Direct Known Subclasses:
LocatedFileStatus

@InterfaceAudience.Public
@InterfaceStability.Stable
public class FileStatus
extends Object
implements Writable, Comparable

Interface that represents the client side information for a file.


Constructor Summary
FileStatus()
           
FileStatus(FileStatus other)
          Copy constructor.
FileStatus(long length, boolean isdir, int block_replication, long blocksize, long modification_time, long access_time, FsPermission permission, String owner, String group, Path path)
          Constructor for file systems on which symbolic links are not supported
FileStatus(long length, boolean isdir, int block_replication, long blocksize, long modification_time, long access_time, FsPermission permission, String owner, String group, Path symlink, Path path)
           
FileStatus(long length, boolean isdir, int block_replication, long blocksize, long modification_time, Path path)
           
 
Method Summary
 int compareTo(Object o)
          Compare this object to another object
 boolean equals(Object o)
          Compare if this object is equal to another object
 long getAccessTime()
          Get the access time of the file.
 long getBlockSize()
          Get the block size of the file.
 String getGroup()
          Get the group associated with the file.
 long getLen()
          Get the length of this file, in bytes.
 long getModificationTime()
          Get the modification time of the file.
 String getOwner()
          Get the owner of the file.
 Path getPath()
           
 FsPermission getPermission()
          Get FsPermission associated with the file.
 short getReplication()
          Get the replication factor of a file.
 Path getSymlink()
           
 int hashCode()
          Returns a hash code value for the object, which is defined as the hash code of the path name.
 boolean isDir()
          Deprecated. Use isFile(), isDirectory(), and isSymlink() instead.
 boolean isDirectory()
          Is this a directory?
 boolean isFile()
          Is this a file?
 boolean isSymlink()
          Is this a symbolic link?
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
protected  void setGroup(String group)
          Sets group.
protected  void setOwner(String owner)
          Sets owner.
 void setPath(Path p)
           
protected  void setPermission(FsPermission permission)
          Sets permission.
 void setSymlink(Path p)
           
 String toString()
           
 void write(DataOutput out)
          Serialize the fields of this object to out.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileStatus

public FileStatus()

FileStatus

public FileStatus(long length,
                  boolean isdir,
                  int block_replication,
                  long blocksize,
                  long modification_time,
                  Path path)

FileStatus

public FileStatus(long length,
                  boolean isdir,
                  int block_replication,
                  long blocksize,
                  long modification_time,
                  long access_time,
                  FsPermission permission,
                  String owner,
                  String group,
                  Path path)
Constructor for file systems on which symbolic links are not supported


FileStatus

public FileStatus(long length,
                  boolean isdir,
                  int block_replication,
                  long blocksize,
                  long modification_time,
                  long access_time,
                  FsPermission permission,
                  String owner,
                  String group,
                  Path symlink,
                  Path path)

FileStatus

public FileStatus(FileStatus other)
           throws IOException
Copy constructor.

Parameters:
other - FileStatus to copy
Throws:
IOException
Method Detail

getLen

public long getLen()
Get the length of this file, in bytes.

Returns:
the length of this file, in bytes.

isFile

public boolean isFile()
Is this a file?

Returns:
true if this is a file

isDirectory

public boolean isDirectory()
Is this a directory?

Returns:
true if this is a directory

isDir

@Deprecated
public boolean isDir()
Deprecated. Use isFile(), isDirectory(), and isSymlink() instead.

Old interface, instead use the explicit isFile(), isDirectory(), and isSymlink()

Returns:
true if this is a directory.

isSymlink

public boolean isSymlink()
Is this a symbolic link?

Returns:
true if this is a symbolic link

getBlockSize

public long getBlockSize()
Get the block size of the file.

Returns:
the number of bytes

getReplication

public short getReplication()
Get the replication factor of a file.

Returns:
the replication factor of a file.

getModificationTime

public long getModificationTime()
Get the modification time of the file.

Returns:
the modification time of file in milliseconds since January 1, 1970 UTC.

getAccessTime

public long getAccessTime()
Get the access time of the file.

Returns:
the access time of file in milliseconds since January 1, 1970 UTC.

getPermission

public FsPermission getPermission()
Get FsPermission associated with the file.

Returns:
permssion. If a filesystem does not have a notion of permissions or if permissions could not be determined, then default permissions equivalent of "rwxrwxrwx" is returned.

getOwner

public String getOwner()
Get the owner of the file.

Returns:
owner of the file. The string could be empty if there is no notion of owner of a file in a filesystem or if it could not be determined (rare).

getGroup

public String getGroup()
Get the group associated with the file.

Returns:
group for the file. The string could be empty if there is no notion of group of a file in a filesystem or if it could not be determined (rare).

getPath

public Path getPath()

setPath

public void setPath(Path p)

setPermission

protected void setPermission(FsPermission permission)
Sets permission.

Parameters:
permission - if permission is null, default value is set

setOwner

protected void setOwner(String owner)
Sets owner.

Parameters:
owner - if it is null, default value is set

setGroup

protected void setGroup(String group)
Sets group.

Parameters:
group - if it is null, default value is set

getSymlink

public Path getSymlink()
                throws IOException
Returns:
The contents of the symbolic link.
Throws:
IOException

setSymlink

public void setSymlink(Path p)

write

public void write(DataOutput out)
           throws IOException
Description copied from interface: Writable
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Description copied from interface: Writable
Deserialize the fields of this object from in.

For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Parameters:
in - DataInput to deseriablize this object from.
Throws:
IOException

compareTo

public int compareTo(Object o)
Compare this object to another object

Specified by:
compareTo in interface Comparable
Parameters:
o - the object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the specified object's is not of type FileStatus

equals

public boolean equals(Object o)
Compare if this object is equal to another object

Overrides:
equals in class Object
Parameters:
o - the object to be compared.
Returns:
true if two file status has the same path name; false if not.

hashCode

public int hashCode()
Returns a hash code value for the object, which is defined as the hash code of the path name.

Overrides:
hashCode in class Object
Returns:
a hash code value for the path name.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014 Apache Software Foundation. All Rights Reserved.