Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA For these XMLTable steps, use the dom 4 j API which is dependency managed by Maven. 1 Serialize all types using corresponding XML equivalents
JAVA For these XMLTable steps, use the domj API which is dependency managed by Maven.
Serialize all types using corresponding XML equivalents or analogs.
Deserialize all types with minimal custom parsing.
Use XML elements, attributes, and text content 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 XML format.
A reference for the document, which is the document model representing the contents of the file.
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 xml extension relative to the base directories.
If the file doesnt exist at the path field, create it
Use the document helper to create a new document, then set the document field to the result.
Add a new table element under the document as the root element.
Add a new columns element under the table element. Add the given columns as suitable column elements under it
Add a new rows element under the table element.
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 xml extension relative to the base directories.
If the file doesnt exist at the path field, throw an illegal argument exception.
Use a reader to read the document from the file, and initialize the document field to it
When catching a document exception for an invalid XML file, throw an illegal state exception.
E A public clear method.
Clear all row elements under the rows element.
Call the flush method to update the file.
F A private flush method.
Use a writer to write the document 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 xml extension.
The columns method which returns appropriately from the column elements under the columns element.
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 number of row elements under the rows element.
The hashCode method which returns the sum of the hash codes from the row elements under the rows element.
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
page
H A public iterator method which returns an iterator of rows.
Create an empty list of rows.
For each row element under the rows element, create a new row from that element, 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.
TH QUARTER: XML PUT, GET, REMOVE
J For these XMLTable steps, use the domj 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
If the degree of the given row doesnt match the result of calling the degree method, throw an illegal argument exception.
Linear search the row elements under the rows element to find a row with the given key.
On a hit, remove the old row element at the key under the rows element, put the new row element as suitable at the key
under the rows element, call flush, and return the old list of fields.
On a miss, put the new row element at the key under the rows element, call flush, and return null.
L A public get method which takes a key parameter.
Linear search the row elements under the rows element to find a row with the given key.
On a hit, return the old list of fields of the row element at the key under the rows element.
On a miss, return null.
M A public remove method which takes a key parameter.
Linear search the row elements under the rows element to find a row with the given key.
On a hit, remove the old row element at the key under the rows element, call flush, and return the old list of fields.
On a miss, return null. Attach console screenshots for tabular views of two or more nontrivial tables, displayed using your Sandbox class.
At least one new table must be created in JSON format using the ary constructor.
At least one existing table must be created in JSON format using the ary constructor.
At least one new table must be created in XML format using the ary
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