Class ObjDumper

java.lang.Object
io.permazen.core.util.ObjDumper

public final class ObjDumper extends Object
Utility classes for printing database objects and fields in a human-readable format.

To use this class for implementing Object.toString(), add a method like this to your Java model classes:

  @Override
  public String toString() {
      return ObjDumper.toString(this.getTransaction().getTransaction(), this.getObjId(), 16);
  }
 
  • Method Details

    • toString

      public static String toString(Transaction tx, ObjId id, int maxCollectionEntries)
      Helper for Java model object Object.toString() methods that wish to display all fields in the object.
      Parameters:
      tx - transaction containing the object
      id - the ID of the object
      maxCollectionEntries - maximum number of elements to display in any collection field or -1 to not display any fields
      Returns:
      contents of the specified object, or just object type and ID if tx is no longer valid
      Throws:
      IllegalArgumentException - if tx or id is null
    • print

      public static void print(PrintWriter writer, Transaction tx, ObjId id, int maxCollectionEntries)
      Print the content of the given object's fields in a human readable format.

      The given transaction must still be open and the specified object must exist therein.

      Parameters:
      writer - output destination
      tx - transaction containing the object
      id - the ID of the object
      maxCollectionEntries - maximum number of elements to display in any collection field or -1 to not display any fields
      Throws:
      DeletedObjectException - if the object does not exist in tx
      StaleTransactionException - if tx is no longer usable
      UnknownTypeException - if id specifies an unknown object type
      IllegalArgumentException - if any parameter is null