Answered step by step
Verified Expert Solution
Link Copied!

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).
1 If the given object is a null reference, return a string containing the literal word null.
2 If it is a string, return it between literal quotation marks ("), thus 2 characters longer.
3 If it is a boolean, integer, or floating point number (double), return it converted to a string.
4 Otherwise, throw an illegal argument exception and pass it the message that the given object is unsupported.
5 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.
1 If the given field is the literal word null or any case variant, return a null reference.
2 If it starts and ends with literal quotation marks ("), return the substring between the marks, thus 2 characters shorter.
3 If it is the literal word true or false or any case variant, return the corresponding boolean true or false.
4 If it can be parsed as an integer, return the corresponding integer.
5 If it can be parsed as a floating point number (double), return the corresponding number.
6 Otherwise, throw an illegal argument exception and pass it the message that the given field is unrecognized.
7 This step I is the functional inverse of step H above.
page 2/3
J A private static encodeRow method which takes a row parameter and encodes it as a record (string).
1 Create a string joiner with a comma (,) as its delimiter.
2 Encode the key of the given row as a field using encodeField, and add it to the string joiner.
3 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.
4 Return the string joiner converted to a string.
5 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.
1 Split the record on commas (,) into a sequence of fields.
2 Strip the first field of whitespace and decode it as a key using decodeField.
3 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.
4 Return a new row composed of the key and list of fields.
5 This step K is the functional inverse of step J above.
L Public methods for the following properties:
1 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

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

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions