Record Class SaveOutputs

java.lang.Object
java.lang.Record
vaadinx.SaveOutputs
Record Components:
files - the app's output files, in display order.
truncated - whether MAX_VISITED_ENTRIES stopped the walk — the dialog says so rather than silently showing a short list.

public record SaveOutputs(List<File> files, boolean truncated) extends Record
INTERNAL — do not use. Not part of the emulated Swing/AWT API surface and has no stability guarantee.

What a SAVE produced: the files an emulated Swing app wrote into the temp directory it was handed, in the order the download dialog lists them ([D_save_binds_download]). Pure — no Vaadin, no session, no I/O beyond the walk — so the question "which files does this save offer, and which one goes on top" is decided and tested on its own, apart from BrowserFileTransfer's dialog and transfer mechanics.

The invariant everything here rests on: SessionTempFiles.newTransferDir() hands out a fresh, empty directory per show, so every file found is the app's output by construction — no heuristics, nothing to disambiguate, and no way for one user's save to see another's.

  • Field Details

    • MAX_VISITED_ENTRIES

      public static final int MAX_VISITED_ENTRIES
      Cap on directory entries one walk visits. Counts every entry touched, directories included — a tree of empty directories holds no files and would never trip a file-based cap, yet would be re-walked every 500 ms by the download watcher. Counting visits also makes a depth cap redundant: the walk cannot descend past what this budget allows.
      See Also:
  • Constructor Details

    • SaveOutputs

      public SaveOutputs(List<File> files, boolean truncated)
      Creates an instance of a SaveOutputs record class.
      Parameters:
      files - the value for the files record component
      truncated - the value for the truncated record component
  • Method Details

    • discover

      public static SaveOutputs discover(File dir, String promptedName)
      Walks dir under the default MAX_VISITED_ENTRIES budget.
    • discover

      public static SaveOutputs discover(File dir, String promptedName, int visitCap)
      Breadth-first walk of a SAVE transfer directory.

      Breadth-first is what makes visitCap meaningful: you get the shallowest entries, which are the likely outputs, where a depth-first walk could spend the whole budget inside the first subdirectory. The shape that motivates it: an app that builds a large tree and then zips it writes the one file that matters at the root.

      Ordering is deterministic and stable under a growing file, because the download dialog reconciles rows rather than rebuilding them and a shifting order would move rows under the user's cursor — which is why modification time and size are not sort keys. Files come out ordered by depth (root before nested), then by parent directory, then within a directory by inFolderOrder(String).

      Symbolic links are neither followed nor offered: a link loop would spin the walk, and there is no case where following one is what the migrated app meant. Directories are traversal only — they never become download rows.

      Parameters:
      dir - the transfer directory; null or unreadable yields an empty result rather than an error.
      promptedName - the name typed at the save prompt, used only for the match-first ordering rank; blank means "no signal".
      visitCap - maximum directory entries to visit, counting directories.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • files

      public List<File> files()
      Returns the value of the files record component.
      Returns:
      the value of the files record component
    • truncated

      public boolean truncated()
      Returns the value of the truncated record component.
      Returns:
      the value of the truncated record component