Class Directory

java.lang.Object
it.unimi.di.prog2.temisvolti.filesystem.Entry
it.unimi.di.prog2.temisvolti.filesystem.Directory
All Implemented Interfaces:
Iterable<Entry>

public class Directory extends Entry implements Iterable<Entry>
Classe mutabile che rappresenta una directory.
  • Field Details

    • entries

      private final List<Entry> entries
      Il contenuto della directory.
  • Constructor Details

    • Directory

      public Directory(String name)
      Costruisce una directory vuota dato il suo nome
      Parameters:
      name - il nome.
      Throws:
      IllegalArgumentException - se il nome è null o vuoto.
  • Method Details

    • find

      public Entry find(String name)
      Restituisce l'entry dato il suo nome se presente (altrimenti restituisce null).
      Parameters:
      name - il nome dell'entry.
      Returns:
      l'entry di dato nome (o null se nessuna entry ha il nome dato).
      Throws:
      NullPointerException - se il name è null.
    • add

      void add(Entry entry) throws FileAlreadyExistsException
      Aggiunge una entry.
      Parameters:
      entry - l'entry da aggiungere.
      Throws:
      NullPointerException - se l'entry è null
      FileAlreadyExistsException
    • isDir

      public boolean isDir()
      Description copied from class: Entry
      Consente di sapere se una entry è una directory.
      Specified by:
      isDir in class Entry
      Returns:
      true sse l'entry è una directory.
    • size

      public int size()
      Description copied from class: Entry
      Restituisce la dimensione dell'entry.
      Specified by:
      size in class Entry
      Returns:
      la dimensione.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • iterator

      public Iterator<Entry> iterator()
      Specified by:
      iterator in interface Iterable<Entry>