Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Requirements: In this assignment, you will be designing and implementing an alternative software tool (to the existing ones), called BibCreator. The main task of this

Requirements: In this assignment, you will be designing and implementing an alternative software tool (to the existing ones), called BibCreator. The main task of this tool is read and process a given .bib file (which has one or more articles) and create 3 different files with the correct reference formats for IEEE, ACM and NJ. To distinguish your application from other existing similar software, you will call these files IEEEi.json; ACMi.json; and NJi.json (although in fact, the created files contain the references to the articles, and not json records!), where i is the Latex file #. For instance, Latex3.bib will result in the creation of 3 files called: IEEE3.json; ACM3.json; and NJ3.json. If a file is invalid, then none of the 3 output reference files (for this invalid file) is created. For validation purpose you are given 10 files, called Latex1.bib to Latex10.bib. You BibCreator application will need to read all 10 input files (in one program execution), determine whether each of these files is valid or not (details given below). If a file is valid, then BibCreator will create 3 different files based on the articles in this file, one for IEEE format, one for ACM format and the other one for NJ format. So, in best case, BibCreator execution will result in the creation of 30 output files if all given 10 Latex files are valid, and in worst case it will create 0 files (when all 10 input Latex files are invalid). The details of what you need to do and how your BibCreator should work are given below. 1. For the purpose of this assignment, and to provide some simplifications, the following should be assumed in relation to the input files and the articles (records) in each input file: 2. Each file may have one or more articles; the number is unknown before processing, and your code must assume that. 3.An article starts with @ARTICLE followed by the body of the article (between { and }). It is assumed that all articles have enclosing bodies. 4. Inside each of these articles, there exist few fields; i.e. author, volume, year, etc. These fields are assumed to always start with the field name, followed by an = sign and a { character. For instance: pages={ , month={, etc. 5. It also assumed that each of the bodies of these fields have a closing character for its body. In specific, it is assumed that each of these fields end with }. 6. For simplicity, it is assumed that there is a doi field, which maps always to https://doi.org/ (i.e. any of the doi field in any file will be assigned: https://doi.org/ automatiqualy instead of it real value) 7. The order within the article is NOT important (i.e., it is fine to have the fields in any order, e.g. the pages could be on the top of author) 8. It is also assumed that empty lines can be there within the body of the articles, as well as between different articles; 9. HOWEVER (read carefully), any of the input files may have some of these fields as empty; i.e. number={}, title={}, etc. This is what we classify as an Invalid File. i.e., for a file to be valid, the file cannot have any empty field at any of its articles. Figure 1, below is an image of an invalid file.

Task1: Write an exception class called FileInvalidException with the required constructors to: 1. handle all the different errors for an invalid file and generates error message(s) (e.g. Error: Input file cannot be parsed due to missing information) 2. handle all possible general file errors with different error messages (e.g. file format not accepted, file access rights, etc.) Task2: Write the main() method of the BibCreator class, where it attempts to open all 10 input files (Latex1.bib to Latex10.bib) for reading. You need to use the proper reading class for that in order to read these files(justify the choice of the reading class). If any of these files does not exist, the program must display an error message indicating: Could not open input file xxxxx for reading. Please check if file exists! Program will terminate after closing any opened files. and then exits. You MUST however, close all opened files before exiting the program.

Task3: If all 10 input files can successfully be opened, the program will attempt to open/create all 30 output files (IEEE1.json to IEEE10.json; ACM1.json to ACM10.json; and NJ1.json to NJ10.json). You need to use PrintWriter class to open these output files. If any of these output files cannot be created, then you must:

1. Display a message to the user indicating which file could not be opened/created. 2. Delete all other created output files (if any). That is, if you cannot create all of these output files, then you must clean the directory by deleting all other created files. 3. Close all opened input files; then exist the program.

If you reach this step, then all 10 input files have been opened and all 30 output files have also been created (however, they are surely empty). Task4: Write a method called processFilesForValidation(). This method will process the input files and create the output ones. You can pass any needed parameters to this method, and the method may return any needed information. This method however must NOT declare any exceptions. In other words, the handling of any exceptions that may occur must be handled outside the method, that is: 1. The method should work on the already opened files. 2. The method must process each of these files to find out whether it is valid or not. 3. If a file is valid, then the method must create the proper records for each of the 3 formats (IEEE, ACM and NJ) and store them in these files. 4. If a file is invalid, then the method must stop the processing of this file only, throws FileInvalidException to display the exception error message, then display a message indicating which file was detected as invalid, and where the first problem in that file was detected (See Figure 3). The corresponding output file MUST then be deleted. 5. The method will then continue with the processing of the following file. Task5: Finally, at this point, the program needs to ask the user to enter the name of one of the created output files to display. If the entered file is valid, then your program must open this file for reading you must use the approriate reading class (justify your choice).

If the user enters an invalid name, a FileNotFoundException should be thrown; however, the user is allowed a second and final attempt to enter another name. If this second attempt also fails, then the program exists. Figure 5 and Figure 6 below show the behavior of this program.

General Guideline information: 1. It may assist you greatly if you take advantage of static variables and static attributes throughout the assignment; it is not necessary to utilize other aspects such as Inheritance, Polymorphism, etc.

2.You must exactly match the format and the look of the expected output files. For instance, use & or et al. for the authors as expected, follow the exact order/format of the contents, use vol. instead of volume. In other words, a small difference in the expected output will surely result in mark deduction. 3. For the processing of the authors, you may want to use Java StringTokenizer class. 4. You should minimize opening and closing the files as much as possible. 5. Do not use any external libraries/ADT or existing software to produce what is needed; that will directly result in a 0 mark! 6. Again, your program must work for any input files. The files provided with this assignment are only one possible validation, and must not be considered as the general case when writing your code.

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

More Books

Students also viewed these Databases questions