Class FileAttributes
- java.lang.Object
-
- ghidra.formats.gfilesystem.fileinfo.FileAttributes
-
public class FileAttributes extends java.lang.Object
A collection ofFileAttribute
values that describe a file.
-
-
Field Summary
Fields Modifier and Type Field Description static FileAttributes
EMPTY
Read-only empty instance.
-
Constructor Summary
Constructors Constructor Description FileAttributes()
Creates a new / emptyFileAttributes
instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(FileAttributeType attributeType, java.lang.Object attributeValue)
Adds a typed file attribute value.void
add(FileAttributeType attributeType, java.lang.String displayName, java.lang.Object attributeValue)
Adds a typed file attribute value.void
add(java.lang.String name, java.lang.Object attributeValue)
Adds a custom named file attribute.FileAttributes
clone()
boolean
contains(FileAttributeType attributeType)
Returns true if the specified attribute is present.<T> T
get(FileAttributeType attributeType, java.lang.Class<T> valueClass, T defaultValue)
Gets the value of the specified attribute.java.util.List<FileAttribute<?>>
getAttributes()
Return a list of all the attributes added to this instance.static FileAttributes
of(FileAttribute<?>... attribs)
Creates aFileAttributes
instance containing the specified attribute values.
-
-
-
Field Detail
-
EMPTY
public static FileAttributes EMPTY
Read-only empty instance.
-
-
Constructor Detail
-
FileAttributes
public FileAttributes()
Creates a new / emptyFileAttributes
instance.
-
-
Method Detail
-
of
public static FileAttributes of(FileAttribute<?>... attribs)
Creates aFileAttributes
instance containing the specified attribute values.- Parameters:
attribs
- var-arg list ofFileAttribute
values, null values are ignored and skipped- Returns:
- a new
FileAttributes
instance
-
clone
public FileAttributes clone()
- Overrides:
clone
in classjava.lang.Object
-
add
public void add(java.lang.String name, java.lang.Object attributeValue)
Adds a custom named file attribute.The value class should have a reasonable toString() that converts the value to something that is presentable to the user.
- Parameters:
name
- name of the attributeattributeValue
- value of the attribute
-
add
public void add(FileAttributeType attributeType, java.lang.Object attributeValue)
Adds a typed file attribute value.The value class needs to match
FileAttributeType.getValueType()
.- Parameters:
attributeType
-FileAttributeType
type of this valueattributeValue
- value of attribute
-
add
public void add(FileAttributeType attributeType, java.lang.String displayName, java.lang.Object attributeValue)
Adds a typed file attribute value.The value class needs to match
FileAttributeType.getValueType()
.- Parameters:
attributeType
-FileAttributeType
type of this valuedisplayName
- string used to label the value when displayed to the userattributeValue
- value of attribute- Throws:
java.lang.IllegalArgumentException
- if attributeValue does not match attributeType'sFileAttributeType.getValueType()
.
-
get
public <T> T get(FileAttributeType attributeType, java.lang.Class<T> valueClass, T defaultValue)
Gets the value of the specified attribute.- Type Parameters:
T
- expected class of the attribute value- Parameters:
attributeType
-FileAttributeType
enum type of attribute to search forvalueClass
- java class of the valuedefaultValue
- value to return if attribute is not present- Returns:
- value of requested attribute, or defaultValue if not present
-
getAttributes
public java.util.List<FileAttribute<?>> getAttributes()
Return a list of all the attributes added to this instance.- Returns:
- list of
FileAttribute
-
contains
public boolean contains(FileAttributeType attributeType)
Returns true if the specified attribute is present.- Parameters:
attributeType
- attribute to query- Returns:
- boolean true if present
-
-