Class FileAttributes
java.lang.Object
ghidra.formats.gfilesystem.fileinfo.FileAttributes
A collection of
FileAttribute
values that describe a file.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(FileAttributeType attributeType, Object attributeValue) Adds a typed file attribute value.void
add
(FileAttributeType attributeType, String displayName, Object attributeValue) Adds a typed file attribute value.void
Adds a custom named file attribute.clone()
boolean
contains
(FileAttributeType attributeType) Returns true if the specified attribute is present.<T> T
get
(FileAttributeType attributeType, Class<T> valueClass, T defaultValue) Gets the value of the specified attribute.List
<FileAttribute<?>> 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 Details
-
EMPTY
Read-only empty instance.
-
-
Constructor Details
-
FileAttributes
public FileAttributes()Creates a new / emptyFileAttributes
instance.
-
-
Method Details
-
of
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
-
add
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
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
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:
IllegalArgumentException
- if attributeValue does not match attributeType'sFileAttributeType.getValueType()
.
-
get
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
Return a list of all the attributes added to this instance.- Returns:
- list of
FileAttribute
-
contains
Returns true if the specified attribute is present.- Parameters:
attributeType
- attribute to query- Returns:
- boolean true if present
-