QuestionQuestion

Description:
In phase 1 you will check files for accessibility and build them into a simple XML file. The xml file will be written out in this phase so it may be checked for correctness. The files that you will pack into the xml file will be text files -- no binary files in this phase.
You will add this later on. In the final project a GUI will be used to set up the files and options for the test project. In this phase, a class will be used to hold the information that the GUI will get and forward it to your phase 1 code.
For each file that needs to be packaged for the remote test system you will need to make sure it exists and that it is accessible. If it exists and is readable it can be copied to the xml file with the correct tags. If it is not, you should generate an appropriate error message and continue processing the remaining files in the list of files.
There will be a number of flags and options available for compilation and linking. These are also available through the class representing the GUI and will be needed to complete the xml file.
The class is “TestProject” and contains the following methods:
int getNumberOfFiles() -- returns the number of files that have been saved in the GUI.
vector<string> getFilenames() -- returns a vector of strings. Each element contains one of the filenames entered into the GUI.
Int getNumberOfLibDirs() -- returns the number of library directories that the user has entered for this project.
vector<string> getLibDirs() -- returns a vector of strings. Each element contains a directory to be searched when looking for libraries.
Int getNumberOfIncludeDirs() - returns the nuymber of include directories that the user has entered for this project.
vector<string> getIncludeDirs() -- returns a vector containing strings representing each of the directories to be searched when using an include preprocessor directive.
string getOptLevel () -- returns a string that represents the optimization level to use in building the project.
string getLanguageVersion() -- returns a string that represents the language version to be used in building the project. These values will depend on the compiler type selected.
string getCompilerType() -- returns the compiler type to use for this project. Current options are limited to C++, C, Java, and FORTRAN.
string getTestSetName() -- the name of the test set to run using the program on the remote system. For example it may be “EECS 4520 Phase 1”. Another might be “EECS 2510 Project 2”.

bool isDebugOn() -- if this returns true the flags to the compiler should include the debugging flag if it exists. If this returns false debugging should be disabled or off.

The XML file format is not completely set at this moment and you should expect updates. The preliminary form is:
<xml>
<filesystem>
<file name=”filename”> Contents of file here
</file>
<file name=”second filename”> Contents of file here
</file>
</filesystem>
<Compilation language=”C++” version=”17” Debug=”yes”>
<LibraryDirectory name=”./lib”>
<LibraryDirectory name=”./GL”>
<LibraryDirectory name=”./special/secret/library”>
<IncludeDirectory name=”./include”>
<IncludeDirectory name=”./include/phigs”>
<Optimization level=”high”>
</Compilation>
<TestSet name=”EECS 4520 Phase 1”>
</TestSet>
</xml>

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.*;
import java.io.*;
import java.util.ArrayList;
import java.util.List;

@XmlRootElement(name = "xml")
public class TestProject {

    private int numberOfFiles;

    @XmlElementWrapper(name = "filesystem")
    @XmlElement(name="file")
    private List<FileInformation> lstFileNames;

    private int numberOfLibDirs;
    private List<String> lstLibDirs;

    @XmlElement(name = "Compilation")
    private Compilation compilation;

    private int numberIncludeDirs;
    private List<String> lstIncludeDirs;

    private String optLevel;

    private String langVersion;

    private String compilerType;

    @XmlElement
    private TestSet testSet;

    private boolean isDebug;

    public TestProject(){

       String FILE_DIR = "files";

       lstFileNames = new ArrayList<>();
       lstLibDirs = new ArrayList<>();
       lstIncludeDirs = new ArrayList<>();

       lstLibDirs.add("./lib");
       lstLibDirs.add("./GL");
       lstLibDirs.add("./special/secret/library");

       lstIncludeDirs.add("./include");
       lstIncludeDirs.add("/include/phigs");

       isDebug = true;
       langVersion = "17";
       compilerType = "C++";

       try {
            File file = new File(FILE_DIR);
            if(file != null && file.isDirectory()){
                File[] files = file.listFiles();
                for (File f: files) {

                   if(f != null && f.isFile() && f.getName().endsWith(".txt")) {
                        BufferedReader bufferedInputStream = new BufferedReader(new FileReader(f));

                        String content = "";
                        String line = "";

                        while ((line = bufferedInputStream.readLine()) != null) {
                            line = line.replaceAll("&", "&");
                            line = line.replaceAll("<", "<");
                            line = line.replaceAll(">", ">");
                            content += line + "\n";
                        }
                        lstFileNames.add(new FileInformation(f.getName(), content));
                        bufferedInputStream.close();
                   }
                }
            }
       }catch (Exception ex){
            System.err.println(ex.getMessage());
       }...

By purchasing this solution you'll be able to access the following files:
Solution.xml and Solution.java.

$45.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats