Class TxtTreeSerializer

java.lang.Object
introspector.model.traverse.TxtTreeSerializer
All Implemented Interfaces:
TreeSerializer
Direct Known Subclasses:
ConsoleTreeSerializer

public class TxtTreeSerializer extends Object implements TreeSerializer
Stores a tree as a txt file
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final boolean
    Indicates if all the info in the nodes must be displayed (i.e., toString() method of objects wrapped by nodes)
    private final Set<Node>
    Used when two trees have been compared.
    private final Writer
    The text stream where the information is to be written
  • Constructor Summary

    Constructors
    Constructor
    Description
    This constructor creates an object to write the tree in a file with all the information in the nodes
    TxtTreeSerializer(Writer writer, boolean allInfo)
    This constructor creates an object to write the tree in a file with all the information in the nodes
    This constructor creates an object to write the tree in a file with all the information in the nodes
    TxtTreeSerializer(String fileName, boolean allInfo)
    This constructor creates an object to write the tree in a file
    TxtTreeSerializer(String fileName, boolean allInfo, Set<Node> modifiedNodes)
    This constructor creates an object to write the tree in a file
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterTraversing(Node node, int depth, boolean hasBeenVisited)
    This method is called after one node is traversed
    void
    beforeTraversing(Node node, int depth, boolean hasBeenVisited)
    This method is called after the whole tree has been traversed
    void
    This method is called at the beginning of the tree traversal
    void
    This method is called after the whole tree has been traversed
    private String
    prefix(int depth)
    Writes the prefix of every node
    void
    traversing(Node node, int depth, boolean hasBeenVisited)
    This method is called when a node is being traversed
    protected void
    Writes one string in the output file and flushes it

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • outputTxtFile

      private final Writer outputTxtFile
      The text stream where the information is to be written
    • allInfo

      private final boolean allInfo
      Indicates if all the info in the nodes must be displayed (i.e., toString() method of objects wrapped by nodes)
    • modifiedNodes

      private final Set<Node> modifiedNodes
      Used when two trees have been compared. The nodes in this set indicates that nodes that have been modified. These nodes must be written between ** and ** to indicate that they have are different from the other tree.
  • Constructor Details

    • TxtTreeSerializer

      public TxtTreeSerializer(String fileName, boolean allInfo) throws IOException
      This constructor creates an object to write the tree in a file
      Parameters:
      fileName - the name of the output txt file
      allInfo - if all the info in the nodes must be displayed (i.e., toString() method of objects wrapped by nodes)
      Throws:
      IOException - a textual file is opened
    • TxtTreeSerializer

      public TxtTreeSerializer(String fileName, boolean allInfo, Set<Node> modifiedNodes) throws IOException
      This constructor creates an object to write the tree in a file
      Parameters:
      fileName - the name of the output txt file
      allInfo - if all the info in the nodes must be displayed (i.e., toString() method of objects wrapped by nodes)
      modifiedNodes - the nodes that have been modified in the comparison of two trees
      Throws:
      IOException - a textual file is opened
    • TxtTreeSerializer

      TxtTreeSerializer(String fileName) throws IOException
      This constructor creates an object to write the tree in a file with all the information in the nodes
      Parameters:
      fileName - the name of the file
      Throws:
      IOException - textual file is opened
    • TxtTreeSerializer

      TxtTreeSerializer(Writer writer, boolean allInfo)
      This constructor creates an object to write the tree in a file with all the information in the nodes
      Parameters:
      writer - the textual output stream
      allInfo - if all the info in the nodes must be displayed (i.e., toString() method of objects wrapped by nodes)
    • TxtTreeSerializer

      TxtTreeSerializer(Writer writer)
      This constructor creates an object to write the tree in a file with all the information in the nodes
      Parameters:
      writer - the textual output stream
  • Method Details