Package introspector.model.traverse
Class HtmlTreeSerializer
java.lang.Object
introspector.model.traverse.HtmlTreeSerializer
- All Implemented Interfaces:
TreeSerializer
Stores a tree as a html file
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanIndicates if all the info in the nodes must be displayed (i.e., toString() method of objects wrapped by nodes)Used when two trees have been compared.private final WriterThe text stream where the information is to be written -
Constructor Summary
ConstructorsConstructorDescriptionHtmlTreeSerializer(Writer writer) This constructor creates an object to write the tree in a file with all the information in the nodesHtmlTreeSerializer(Writer writer, boolean allInfo) This constructor creates an object to write the tree in a file with all the information in the nodesHtmlTreeSerializer(String fileName) This constructor creates an object to write the tree in a file with all the information in the nodesHtmlTreeSerializer(String fileName, boolean allInfo) This constructor creates an object to write the tree in a fileHtmlTreeSerializer(String fileName, boolean allInfo, Set<Node> modifiedNodes) This constructor creates an object to write the tree in a file -
Method Summary
Modifier and TypeMethodDescriptionvoidafterTraversing(Node node, int depth, boolean hasBeenVisited) This method is called after one node is traversedvoidbeforeTraversing(Node node, int depth, boolean hasBeenVisited) This method is called after the whole tree has been traversedvoidThis method is called at the beginning of the tree traversalvoidThis method is called after the whole tree has been traversedprivate StringnodeDescription(Node node, boolean cycle) Returns the textual representation of a node, considering the allInfo fieldprivate Stringprefix(int depth) Writes the prefix of every nodeprivate StringreadResourceFile(String resourceName) Reads the contents of a file in a resource foldervoidtraversing(Node node, int depth, boolean hasBeenVisited) This method is called when a node is being traversedprotected voidWrites one string in the output file and flushes it
-
Field Details
-
outputTxtFile
The text stream where the information is to be written -
allInfo
private final boolean allInfoIndicates if all the info in the nodes must be displayed (i.e., toString() method of objects wrapped by nodes) -
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 in red to indicate that they have are different from the other tree.
-
-
Constructor Details
-
HtmlTreeSerializer
This constructor creates an object to write the tree in a file- Parameters:
fileName- the name of the output txt fileallInfo- 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
-
HtmlTreeSerializer
public HtmlTreeSerializer(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 fileallInfo- 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
-
HtmlTreeSerializer
HtmlTreeSerializer(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
-
HtmlTreeSerializer
HtmlTreeSerializer(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 streamallInfo- if all the info in the nodes must be displayed (i.e., toString() method of objects wrapped by nodes)
-
HtmlTreeSerializer
HtmlTreeSerializer(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
-
prefix
Writes the prefix of every node- Parameters:
depth- the depth of the node- Returns:
- its textual representation
-
write
Writes one string in the output file and flushes it- Parameters:
str- the string to be written- Throws:
IOException- a textual file is written
-
readResourceFile
Reads the contents of a file in a resource folder- Parameters:
resourceName- the name of the resource- Returns:
- the contents of the file
-
beginTraverse
Description copied from interface:TreeSerializerThis method is called at the beginning of the tree traversal- Specified by:
beginTraversein interfaceTreeSerializer- Throws:
IOException- if there is an error writing the tree- See Also:
-
endTraverse
Description copied from interface:TreeSerializerThis method is called after the whole tree has been traversed- Specified by:
endTraversein interfaceTreeSerializer- Throws:
IOException- if there is an error writing the tree- See Also:
-
beforeTraversing
Description copied from interface:TreeSerializerThis method is called after the whole tree has been traversed- Specified by:
beforeTraversingin interfaceTreeSerializer- Parameters:
node- the node that is up to be traverseddepth- the depth of the nodehasBeenVisited- if the node has already been visited in the current traversal (to detect cycles)- See Also:
-
traversing
Description copied from interface:TreeSerializerThis method is called when a node is being traversed- Specified by:
traversingin interfaceTreeSerializer- Parameters:
node- the node that is up being traverseddepth- the depth of the nodehasBeenVisited- if the node has already been visited in the current traversal (to detect cycles)- Throws:
IOException- if there is an error writing the tree- See Also:
-
afterTraversing
Description copied from interface:TreeSerializerThis method is called after one node is traversed- Specified by:
afterTraversingin interfaceTreeSerializer- Parameters:
node- the node that has just been traverseddepth- the depth of the nodehasBeenVisited- if the node has already been visited in the current traversal (to detect cycles)- Throws:
IOException- if there is an error writing the tree- See Also:
-
nodeDescription
Returns the textual representation of a node, considering the allInfo field- Parameters:
node- the node to be converted into stringcycle- if this node is a cycle (has already been visited)- Returns:
- the textual representation of a node
-