Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA For these JSONTable steps, use the Jackson API which is dependency managed by Maven. 1 Serialize all types using corresponding JSON equivalents or analogs.
JAVA For these JSONTable steps, use the Jackson API which is dependency managed by Maven.
Serialize all types using corresponding JSON equivalents or analogs.
Deserialize all types with minimal custom parsing.
Use JSON objects and arrays efficiently and conventionally.
B The following private fields:
A static constant path for the base directories, which are db sub tables relative to the project directory.
A path for the file, which is the table file structure in JSON format.
A reference for the tree, which is the root object node representing the contents of the file.
A static constant reference for the mapper, which is a new reusable JSON mapper instance with static factory methods.
No fields for the degree, size, fingerprint, or any other fields unlike in previous modules
C A ary constructor which takes a name parameter string and a columns parameter list of strings
Create the base directories, if needed.
Initialize the path field by resolving the given name plus the json extension relative to the base directories.
If the file doesnt exist at the path field, create it
Use the mapper to create a new object node, and initialize the tree field to it
Put a new object node at the metadata property of the tree.
Put a new object node at the data property of the tree.
Put the given columns as suitable at the columns property under the metadata node.
Call the flush method to update the file.
D A ary constructor which takes a name parameter string only.
Initialize the path field by resolving the given name plus the json extension relative to the base directories.
If the file doesnt exist at the path field, throw an illegal argument exception.
Use the mapper to read the root object node from the file, and initialize the tree field to it
When catching a parse exception for an invalid JSON file, throw an illegal state exception.
E A public clear method.
Remove all properties under the data node.
Call the flush method to update the file.
F A public flush method.
Use the mapper to write the tree to the file.
Configure the file output to be prettyprinted.
G Public methods for the following statistics and predicates:
The name method which returns the name of the file, excluding the base directories and the json extension.
The columns method which returns appropriately from the columns property under the metadata node.
The degree method which returns the size of the list of columns which is returned by the columns method.
The size method which returns the size of the data node.
The hashCode method which returns the sum of the hash codes from the rows for each property under the data node.
The equals method which returns true if the parameter is any table with the same fingerprint as in previous modules
Dont implement capacity or loadFactor, because this is a FileTable, not a DataTable.
H A public iterator method which returns an iterator of rows.
Create an empty list of rows.
For each property under the data node, create a new row from that property, and add it to the list.
Call iterator on that list and return the corresponding iterator.
Dont implement a new iterator using an anonymous class unlike in previous modules
I A public toString method.
Return an unsorted view of the table by calling toTabularView.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started