Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA A private static encodeField method which takes an object parameter and encodes it as a field ( string ) . 1 If the given
JAVA A private static encodeField method which takes an object parameter and encodes it as a field string
If the given object is a null reference, return a string containing the literal word null.
If it is a string, return it between literal quotation marks thus characters longer.
If it is a boolean, integer, or floating point number double return it converted to a string.
Otherwise, throw an illegal argument exception and pass it the message that the given object is unsupported.
This step H is the functional inverse of step I below.
I A private static decodeField method which takes a field parameter string and decodes it as an object.
If the given field is the literal word null or any case variant, return a null reference.
If it starts and ends with literal quotation marks return the substring between the marks, thus characters shorter.
If it is the literal word true or false or any case variant, return the corresponding boolean true or false.
If it can be parsed as an integer, return the corresponding integer.
If it can be parsed as a floating point number double return the corresponding number.
Otherwise, throw an illegal argument exception and pass it the message that the given field is unrecognized.
This step I is the functional inverse of step H above.
page
J A private static encodeRow method which takes a row parameter and encodes it as a record string
Create a string joiner with a comma as its delimiter.
Encode the key of the given row as a field using encodeField, and add it to the string joiner.
For each field in the list of fields of the given row in order, encode it using encodeField, and add it to the string joiner.
Return the string joiner converted to a string.
This step J is the functional inverse of step K below.
K A private static decodeRow method which takes a record parameter string and decodes it as a row.
Split the record on commas into a sequence of fields.
Strip the first field of whitespace and decode it as a key using decodeField.
Create a new list of fields. For each remaining field in the sequence, strip it decode it using decodeField, and add it to
the list of fields.
Return a new row composed of the key and list of fields.
This step K is the functional inverse of step J above.
L Public methods for the following properties:
The hashCode method fingerprint which returns the sum of the hash codes of the rows decoded from the records in
the flat file, excluding the header.
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