Class FileAttributes

java.lang.Object
ghidra.formats.gfilesystem.fileinfo.FileAttributes

public class FileAttributes extends Object
A collection of FileAttribute values that describe a file.
  • Field Details

    • EMPTY

      public static FileAttributes EMPTY
      Read-only empty instance.
  • Constructor Details

    • FileAttributes

      public FileAttributes()
      Creates a new / empty FileAttributes instance.
  • Method Details

    • of

      public static FileAttributes of(FileAttribute<?>... attribs)
      Creates a FileAttributes instance containing the specified attribute values.
      Parameters:
      attribs - var-arg list of FileAttribute values, null values are ignored and skipped
      Returns:
      a new FileAttributes instance
    • clone

      public FileAttributes clone()
      Overrides:
      clone in class Object
    • add

      public void add(String name, 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 attribute
      attributeValue - value of the attribute
    • add

      public void add(FileAttributeType attributeType, Object attributeValue)
      Adds a typed file attribute value.

      The value class needs to match FileAttributeType.getValueType().

      Parameters:
      attributeType - FileAttributeType type of this value
      attributeValue - value of attribute
    • add

      public void add(FileAttributeType attributeType, String displayName, Object attributeValue)
      Adds a typed file attribute value.

      The value class needs to match FileAttributeType.getValueType().

      Parameters:
      attributeType - FileAttributeType type of this value
      displayName - string used to label the value when displayed to the user
      attributeValue - value of attribute
      Throws:
      IllegalArgumentException - if attributeValue does not match attributeType's FileAttributeType.getValueType().
    • get

      public <T> T get(FileAttributeType attributeType, 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 for
      valueClass - java class of the value
      defaultValue - value to return if attribute is not present
      Returns:
      value of requested attribute, or defaultValue if not present
    • getAttributes

      public 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