Answered step by step
Verified Expert Solution
Link Copied!

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.
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.

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

Step: 3

blur-text-image

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 Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

1. What are the pros and cons of diversity for an organisation?

Answered: 1 week ago

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago