关键词不能为空

当前您在: 主页 > 英语 >

完成基于管道过滤器风格的KWIC实现

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-11 23:45
tags:

-

2021年2月11日发(作者:龙虾的英文)



实验


2


:软件体系结 构风格实现



一、实验目的



1


)初步了解不同的体系结构风格



2


)掌握不同体系结构风格的实现



二、实验学时




4


学时。



三、实验方法



根据

< br>KWIC


的描述,用所熟悉的语言,完成实验内容。



四、实验环境



Windows7


旗舰版


jdk1.6 Eclipse3.7.0


五、实验内容



2


)完成基于管道过滤器风格的


KWI C


实现



六、实验操作步骤



1.

< p>
KWIC


描述:


KWIC


索引系统接受一些行,每行有若干字,每个字由若干字


符组成;每行都可以循环移位。重 复地把第一个字删除,然后接到行末;


KWIC


把所有行的各种移位情况按照字母表顺序输出。




完成基于管道过滤器风格的


KWIC


实现



Main




package kwic_pipe;



import


import r;



public class Main {


public static void main(String[] args) {


File infile = new File(


File outfile = new File(



Scanner inputfile;


Scanner outputfile;





try{


inputfile = new Scanner(infile);


outputfile = new Scanner(outfile);


//


定义三个管道



Pipe pipe1 = new Pipe();


Pipe pipe2 = new Pipe();


Pipe pipe3 = new Pipe();


//


定义四种过滤器



Input input = new Input(infile, pipe1);


Shift shift = new Shift(pipe1, pipe2);


Output output = new Output(pipe3, outfile);


//


启动四种过滤器的线程



orm()


shift. transform ();


output. transform ();


//


直接输出结果



n(


String str = null;


while (tLine()){


str = ne();


n(str);


}


n(


(3000);


n(


while (tLine()){


n(str);


}


();


();


}


catch (Exception e){


sage();


}


}


}


Filter




package kwic_pipe;



import ption;



public abstract class Filter {


//


定义输入管道



protected Pipe input;




//


定义输出管道



protected Pipe output;



private boolean isStart = false;



Filter(Pipe input, Pipe output){


= input;


= output;


}




//


防止多次调用,调用之后线程开始执行



public void start(){


if(!isStart){


isStart = true;


Thread thread = new Thread();


();


}


}


//


线程的


run


方法



public void run(){


try{


orm();


} catch (IOException e){


sage();


}


}


//


将输入数据转换为所需数据并写入输出管道



//


由子类实现抽象方法



protected abstract void transform()throws IOException;


}


Pipe




package kwic_pipe;



import ption;


import eader;


import riter;


import riter;


import r;



public class Pipe {


//


输入管道



private Scanner pipereader;


//


输出管道





private PrintWriter pipewriter;


public Pipe(){





















}


PipedWriter pw = new PipedWriter();


PipedReader pr = new PipedReader();


try{




}


pipewriter = new PrintWriter(pw);


pipereader = new Scanner(pr);


t(pr);


sage();


} catch (IOException e){


//


读入一行数据到管道



//@return


读入的数据



public String readerLine() throws IOException{


return ne();


}



//


从管道输出一行数据



public void writerLine(String strline) throws IOException{


n(strline);


}


//


将读管道关闭,调用该方法后,不能再从管道中读数据



//


如不能关闭则抛出异



public void closeReader() throws IOException{


();


}



//


先刷新数据,在将写管道关闭,调用该方法后,不能向管道中写数据



//


如不能关闭则抛出异常



public void closeWriter() throws IOException{


();


();


}


}


Alphabetizer




package kwic_pipe;



import ption;


import ist;


import tions;


public class Alphabetizer extends Filter{


private ArrayList al = new ArrayList();



-


-


-


-


-


-


-


-



本文更新与2021-02-11 23:45,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/639819.html

完成基于管道过滤器风格的KWIC实现的相关文章