Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For these JSONTable steps, use the Jackson API which is dependency managed by Maven. 1 Serialize all types using corresponding JSON equivalents or analogs. 2

For these JSONTable steps, use the Jackson API which is dependency managed by Maven.
1 Serialize all types using corresponding JSON equivalents or analogs.
2 Deserialize all types with minimal custom parsing.
3 Use JSON objects and arrays efficiently and conventionally.
B The following private fields:
1 A static constant path for the base directories, which are db sub tables relative to the project directory.
2 A path for the file, which is the table file structure in JSON format.
3 A reference for the tree, which is the root object node representing the contents of the file.
4 A static constant reference for the mapper, which is a new reusable JSON mapper instance with static factory methods.
5 No fields for the degree, size, fingerprint, or any other fields (unlike in previous modules).
C A 2-ary constructor which takes a name parameter (string) and a columns parameter (list of strings).
1 Create the base directories, if needed.
2 Initialize the path field by resolving the given name plus the .json extension relative to the base directories.
3 If the file doesnt exist at the path field, create it.
4 Use the mapper to create a new object node, and initialize the tree field to it.
5 Put a new object node at the metadata property of the tree.
6 Put a new object node at the data property of the tree.
7 Put the given columns as suitable at the columns property under the metadata node.
8 Call the flush method to update the file.
D A 1-ary constructor which takes a name parameter (string) only.
1 Initialize the path field by resolving the given name plus the .json extension relative to the base directories.
2 If the file doesnt exist at the path field, throw an illegal argument exception.
3 Use the mapper to read the root object node from the file, and initialize the tree field to it.
4 When catching a parse exception for an invalid JSON file, throw an illegal state exception.
E A public clear method.
1 Remove all properties under the data node.
2 Call the flush method to update the file.
F A public flush method.
1 Use the mapper to write the tree to the file.
2 Configure the file output to be pretty-printed.
G Public methods for the following statistics and predicates:
1 The name method which returns the name of the file, excluding the base directories and the .json extension.
2 The columns method which returns appropriately from the columns property under the metadata node.
3 The degree method which returns the size of the list of columns which is returned by the columns method.
4 The size method which returns the size of the data node.
5 The hashCode method which returns the sum of the hash codes from the rows for each property under the data node.
6 The equals method which returns true if the parameter is any table with the same fingerprint (as in previous modules).
7 Dont implement capacity or loadFactor, because this is a FileTable, not a DataTable.
H A public iterator method which returns an iterator of rows.
1 Create an empty list of rows.
2 For each property under the data node, create a new row from that property, and add it to the list.
3 Call iterator on that list and return the corresponding iterator.
4 Dont implement a new iterator using an anonymous class (unlike in previous modules).
I A public toString method.
1 Return an unsorted view of the table by calling toTabularView.
page 2/3
2ND QUARTER: JSON PUT, GET, REMOVE
J For these JSONTable steps, use the Jackson API which is dependency managed by Maven (as in step A).
K A public put method which takes a key parameter (string), then a list of fields parameter (list of objects).
1 If the degree of the given row doesnt match the result of calling the degree method, throw an illegal argument exception.
2 Check if the given key is a property under the data node to determine a hit or a miss.
3 On a hit, remove the old row at the key under the data node, put the new row at the key under the data node, call flush,
and return the old list of fields.
4 On a miss, put the new row at the key under the data node, call flush, and return null.
L A public get method which takes a key parameter.
1 Check if the given key is a property under the data node to determine a hit or a miss.
2 On a hit, return the old list of fields at the key under the data node.
3 On a miss, return null.
M A public remove method which takes a key parameter.
1 Check if the given key is a property under the data node to determine a hit or a miss.
2 On a hit, remove the old row at the key under the data node, call flush, and return the old list of fields.
3 On a miss, return null.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

=+ Is the information source respected?

Answered: 1 week ago

Question

=+ Is the source or sponsor of the information indicated?

Answered: 1 week ago