Class NotebookReader

java.lang.Object
io.deephaven.enterprise.dnd.notebook.NotebookReader

@InternalUseOnly @NotThreadSafe public final class NotebookReader extends Object
Tools for getting Files and Folders out of the Web IDE notebooks that are stored in DbInternal.WorkspaceData.

This is exposed from the deephaven_enterprise.notebook Python module.

  • Method Details

    • create

      public static NotebookReader create(@NotNull @NotNull Database database)
      Creates a notebook reader that takes a static snapshot of notebook state as the basis for its operations.
      Parameters:
      database - the database object to retrieve tables and the user context from (must be a DatabaseInternal)
      Returns:
      a new notebook reader
    • create

      public static NotebookReader create(@NotNull @NotNull Database database, @NotNull @NotNull Runnable callback)
      Functions like create(Database), except notebook state is live and a callback is executed when notebooks are added or removed.
      Parameters:
      database - the database object to retrieve tables and the user context from (must be a DatabaseInternal)
      callback - logic to execute upon notebook addition or removal
      Returns:
      a new notebook reader
    • getNotebookPaths

      @NotNull public @NotNull Set<String> getNotebookPaths()
      Get the available notebook path names.
      Returns:
      the available notebook path names, or an empty set if none are available
    • getNotebookPaths

      @NotNull public @NotNull Set<String> getNotebookPaths(@NotNull @NotNull String suffix)
      Functions like getNotebookPaths(), except notebooks will be filtered by the supplied suffix.
      Parameters:
      suffix - optional suffix to filter notebook names
      Returns:
      the available notebook path names, or an empty set if none are available
    • getNotebookText

      public String getNotebookText(@NotNull @NotNull String notebookName)
      Get the text of a notebook at the given path.
      Parameters:
      notebookName - the name of the notebook, starting with "/"
      Returns:
      the text of the notebook, if not found an Exception is thrown
    • getNotebookText

      @NotNull public static @NotNull String getNotebookText(@NotNull @NotNull Database database, @NotNull @NotNull String notebookName, @Nullable @Nullable Table workspaceData)
      Get the text of a notebook at the given path.
      Parameters:
      database - the database object to retrieve tables and the user context from (must be a DatabaseInternal)
      notebookName - the name of the notebook, starting with "/"
      workspaceData - optional source of workspace data to base processing on
      Returns:
      the text of the notebook, if not found an Exception is thrown
    • getNotebookText

      @NotNull public static @NotNull String getNotebookText(@NotNull @NotNull Database database, @NotNull @NotNull String notebookName)
      Functions as getNotebookText(Database, String, Table), except without providing workspace data.
      Parameters:
      database - the database object to retrieve tables and the user context from (must be a DatabaseInternal)
      notebookName - the name of the notebook, starting with "/"
      Returns:
      the text of the notebook, if not found an Exception is thrown
    • getFileOrFolder

      @NotNull public static @NotNull NotebookReader.FileOrFolder getFileOrFolder(@NotNull @NotNull Database database, @NotNull @NotNull String path, boolean usesSlash, @NotNull @NotNull String suffix, @Nullable @Nullable Table workspaceData)
      Gets a FileOrFolder pointed to by path.

      This is used by the getNotebookText(java.lang.String) and Python import machinery. In each case you must begin your path with a separator (e.g. "/bill.py" or ".bill"). The optional suffix is used for the imports to search for folders followed by files along the imported path.

      Parameters:
      database - the database object to retrieve tables and the user context from (must be a DatabaseInternal)
      path - the path to retrieve
      usesSlash - use "/+" for the path separator, otherwises uses "\." for Python imports
      suffix - the optional suffix to append to the last component (e.g., ".py" for an import); or empty if no suffix searching should be performed
      workspaceData - optional source of workspace data to base processing on
      Returns:
      the FileOrFolder that was found at the given path, or an exception is thrown
    • getFileOrFolder

      @NotNull public static @NotNull NotebookReader.FileOrFolder getFileOrFolder(@NotNull @NotNull Database database, @NotNull @NotNull String path, boolean usesSlash, @NotNull @NotNull String suffix)
      Functions as getFileOrFolder(Database, String, boolean, String, Table), except without providing workspace data.
      Parameters:
      database - the database object to retrieve tables and the user context from (must be a DatabaseInternal)
      path - the path to retrieve
      usesSlash - use "/+" for the path separator, otherwises uses "\." for Python imports
      suffix - the optional suffix to append to the last component (e.g., ".py" for an import); or empty if no suffix searching should be performed
      Returns:
      the FileOrFolder that was found at the given path, or an exception is thrown