// -*- Java -*-
/*
* <copyright>
*
* Copyright (c) 2002
* Institute for Information Processing and Computer Supported New Media (IICM),
* Graz University of Technology, Austria.
*
* </copyright>
*
* <file>
*
* Name: KWIC.java
*
* Purpose: The Master Control class
*
* Created: 20 Sep 2002
*
* $Id$
*
* Description:
* The Master Control class
* </file>
*/
package kwic.pf;
/*
* $Log$
*/
import java.io.FileInputStream;
import java.io.IOException;
/**
* An object of the KWIC class creates the linear sequence (pipeline) of filters
* connected with pipes. To achieve the desired functionality of the KWIC index system
* the following pipeline is created:
* <ul>
* <li>The first filter is the Input filter. It reads the data from the file, parses it
* and outputs it to the in_cs pipe.
* <li>The in_cs pipe is the input pipe for the next filter in the pipeline: CircularShifter
* filter. CircularShifter reads the data from the in_cs pipe, process it by making circular shifts
* of lines in that pipe. The output is written to the cs_al pipe.
* <li>The cs_al pipe is the input pipe for the next filter in the pipeline: Alphabetizer
* filter. Alphabetizer reads the data from the cs_al pipe, process it by sorting circular shifts
* from that pipe. The output is written to the al_ou pipe.
* <li>The al_ou pipe is the input pipe for the next filter in the pipeline: Output
* filter. Output reads the data from the al_ou pipe and writes it to the standard output.
* </ul>
* Thus, the KWIC object manages the following pipe mechanism:
* <p>
* input file > Input > CircularShifter > Alphabetizer > Output > standard output
* @author dhelic
* @version $Id$
*/
public class KWIC {
//----------------------------------------------------------------------
/**
* Fields
*
*/
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/**
* Constructors
*
*/
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/**
* Methods
*
*/
//----------------------------------------------------------------------
//----------------------------------------------------------------------
/**
* Parses the data, makes shifts and sorts them. At the end prints the
* sorted shifts.
* @param file name of the input file
*/
public void execute(String file) {
try {
Pipe in_up1 = new Pipe();
Pipe up1_cs = new Pipe();
Pipe cs_up2 = new Pipe();
Pipe up2_al = new Pipe();
Pipe al_ou = new Pipe();
FileInputStream in = new FileInputStream(file);
Input input = new Input(in, in_up1);
LineTransformer trans1 = new LineTransformer(in_up1, up1_cs);
CircularShifter shifter = new CircularShifter(up1_cs, cs_up2);
LineTransformer trans2 = new LineTransformer(cs_up2, up2_al);
Alphabetizer alpha = new Alphabetizer(up2_al, al_ou);
Output output = new Output(al_ou);
input.start(); // run it !
trans1.start();
shifter.start();
trans2.start();
alpha.start();
output.start();
} catch (IOException exc) {
exc.printStackTrace();
}
}
public void execute(String file1, String file2) {
try {
Pipe in_cs = new Pipe();
Pipe cs_sf = new Pipe();
Pipe sf_al = new Pipe();
Pipe al_ou = new Pipe();
FileInputStream in = new FileInputStream(file1);
FileInputStream noise = new FileInputStream(file2);
Input input = new Input(in, in_cs);
CircularShifter shifter = new CircularShifter(in_cs, cs_sf);
ShiftFilter shiftFilter = new ShiftFilter(cs_sf, sf_al, noise);
Alphabetizer alpha = new Alphabetizer(sf_al, al_ou);
Output output = new Output(al_ou);
input.start(); // run it !
shifter.start();
shiftFilter.start();
alpha.start();
output.start();
} catch (IOException exc) {
exc.printStackTrace();
}
}
//----------------------------------------------------------------------
/**
* Main function checks the command line arguments. The program expects
* exactly one command line argument specifying the name of the file
* that contains the data. If the program has not been started with
* proper command line arguments, main function exits
* with an error message. Otherwise, a KWIC instance is created and program
* control is passed to it.
* @param args command line arguments
*/
public static void main(String[] args) {
if (args.length != 1 && args.length != 2) {
System.err.println("KWIC Usage: java kwic.ms.KWIC file_name");
System.err.println("or");
System.err.println("KWIC Usage: java kwic.ms.KWIC file_name noise_file_name");
System.exit(1);
}
if (args.length == 1) {
KWIC kwic = new KWIC();
kwic.execute(args[0]);
} else if (args.length == 2) {
KWIC kwic = new KWIC();
kwic.execute(args[0], args[1]);
}
}
//----------------------------------------------------------------------
/**
* Inner classes
*
*/
//----------------------------------------------------------------------
}
没有合适的资源?快使用搜索试试~ 我知道了~
软件体系结构的管道问题
共9个文件
java:9个
需积分: 10 15 下载量 83 浏览量
2008-12-13
17:51:32
上传
评论 1
收藏 10KB RAR 举报
温馨提示
这个是一个关于软件体系结构的课程的作业,是关于管道的问题的.....
资源推荐
资源详情
资源评论
收起资源包目录
.rar (9个子文件)
kwic
pf
Pipe.java 3KB
CircularShifter.java 3KB
ShiftFilter.java 3KB
KWIC.java 6KB
Alphabetizer.java 4KB
Input.java 4KB
Filter.java 3KB
LineTransformer.java 1KB
Output.java 2KB
共 9 条
- 1
资源评论
caty1987220
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功