View Javadoc

1   package rydeen.plugins.nop;
2   
3   import java.io.IOException;
4   import java.io.InputStream;
5   import java.io.OutputStream;
6   
7   import rydeen.AbstractProcessor;
8   import rydeen.Arguments;
9   import rydeen.Destination;
10  import rydeen.ProcessTarget;
11  import rydeen.ProcessorException;
12  import rydeen.TargetSource;
13  
14  /**
15   * 何も処理を行わない処理器.
16   * 
17   * @author Haruaki Tamada
18   */
19  public class NopProcessor extends AbstractProcessor{
20      /**
21       * NopProcessorを作成します.
22       */
23      public NopProcessor(NopProcessorService service){
24          super(service);
25      }
26  
27      /**
28       * 初期設定を行います.
29       */
30      @Override
31      public void prepare(Arguments args){
32          putEntry(args);
33      }
34  
35      /**
36       * 何も処理を行わず,TargetSourceのProcessTargetからデータを読み込み,
37       * そのままDestinationに出力します.
38       */
39      @Override
40      public void perform(TargetSource source, Destination dest) throws ProcessorException{
41          for(ProcessTarget target: source){
42              try{
43                  InputStream in = target.getSource();
44                  OutputStream out = dest.getOutput(target.getName());
45                  putEntry("target", target.getName());
46  
47                  int data;
48                  while((data = in.read()) != -1){
49                      out.write(data);
50                  }
51                  in.close();
52                  out.close();
53              } catch(IOException e){
54                  throw new ProcessorException(e);
55              }
56          }
57      }
58  
59      /**
60       * 終了処理を行います.
61       */
62      @Override
63      public void summarize(){
64          // do nothing....
65      }
66  }