軟體體系結構第二次作業
- Requirements of the project:
Run the program PipeFilterTestGui before you actually do any coding. Afteryou run the program, a graphical user interface will appear as below.
As you can see from the above graphical userinterface, there are two options, one is the legacy files to be processed, andthe other is the pipeline used for processing the files.
The file name such as “Sale1.txt” is the name ofthe actual old .txt file to be processed. You can also put other files into thedirectory “LegacyFiles” for processing.
If you choose a file name from the Files combox,and then choose one pipeline pipeline1, then the program will start inputtinglines from Sale1.txt and then invoke AssemblyOfPipeLines, which will in turnrun the pipeline 1 as the following
InputFilterèY2kFixFilterèAnnotFilterèOutputFilter
to fix Y2Kproblem, add annotations to each line, and finally output the processedcontents to a file Updated.txt and at the sametime to display the contents to the screen. See the pipeline bellow.
Fig 1. The pipeline 1 of the filters
Specifically speaking,the program will run in the following manner.
1) InputFilter reads the file tobe processed in character stream format and parses the file. The parsed data iswritten to the output pipe as char stream.
2) Y2kFixFilter reads characterstream from its source pipe, fix Y2k problem, e.g, change 96-12-09 into1996-12-09, and then write processed contents as character stream into its sinkpipe
3) AnnotFilter read characterstream from the source stream (through source pipe), and add some annotationsto each line, and then write the resultant data into sink pipe as characterstream
4) OutputFilterreads character stream from the source stream (through source pipe), andthen write the resultant data into a file named Updated.txt in directory “NewFiles” and onto the righttextArea on the GUI (the original file content will be shown on the left textArea)
Now,all the files
l PipeFilterTestGui.java,
l AssemblyOfPipeLines.java,
l InputFilter.java,
l Y2kFixFilter.java,
l AnnotFilter.java, and
l OutputFilter.java
have all been implemented.
What you should do. You are required to (需要你完成的部分)
a) Write a Java classcalled PoliticalFilter.java to find every phrase “Republic of China” in thefile and change it into “Taiwan”.
b) then inside class AssemblyOfPipeLines.java,you need to insert the objects of PoliticalFilter.java into the pipeline toform a new PIPELINE2 as below.
Fig 2. The pipeline 2 of the filters
c) The new pipeline 2 should be assembled in file AssemblyOfPipeLines.javaas option2. Therefore, in order to runthe pipeline2, you only need to choose pipeline 2 on the graphical userinterface
ReportPart
1. Drawthe new pipeline, namely pipeline 2, of your new design here
2. About the designclass diagram
a) Draw the originalclass diagram of the program
b) What class hasbeen added to the class diagram
c) Draw your newclass diagram with the added class
3. Answer questions
a) What makes the data flow through the pipeline?
b) Why all the filters can work simultaneously?
4. Typical input and outputfrom running your program