Class FileAttributes
- java.lang.Object
-
- ghidra.formats.gfilesystem.fileinfo.FileAttributes
-
public class FileAttributes extends java.lang.ObjectA collection ofFileAttributevalues that describe a file.
-
-
Field Summary
Fields Modifier and Type Field Description static FileAttributesEMPTYRead-only empty instance.
-
Constructor Summary
Constructors Constructor Description FileAttributes()Creates a new / emptyFileAttributesinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(FileAttributeType attributeType, java.lang.Object attributeValue)Adds a typed file attribute value.voidadd(FileAttributeType attributeType, java.lang.String displayName, java.lang.Object attributeValue)Adds a typed file attribute value.voidadd(java.lang.String name, java.lang.Object attributeValue)Adds a custom named file attribute.FileAttributesclone()booleancontains(FileAttributeType attributeType)Returns true if the specified attribute is present.<T> Tget(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 FileAttributesof(FileAttribute<?>... attribs)Creates aFileAttributesinstance containing the specified attribute values.
-
-
-
Field Detail
-
EMPTY
public static FileAttributes EMPTY
Read-only empty instance.
-
-
Constructor Detail
-
FileAttributes
public FileAttributes()
Creates a new / emptyFileAttributesinstance.
-
-
Method Detail
-
of
public static FileAttributes of(FileAttribute<?>... attribs)
Creates aFileAttributesinstance containing the specified attribute values.- Parameters:
attribs- var-arg list ofFileAttributevalues, null values are ignored and skipped- Returns:
- a new
FileAttributesinstance
-
clone
public FileAttributes clone()
- Overrides:
clonein 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-FileAttributeTypetype 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-FileAttributeTypetype 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-FileAttributeTypeenum 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
-
-