1 package rydeen;
2
3 import java.io.IOException;
4 import java.util.ArrayList;
5 import java.util.List;
6
7 import rydeen.io.DestinationBuilder;
8 import rydeen.io.GlueDestination;
9 import rydeen.io.TargetSourceBuilder;
10
11
12
13
14
15
16
17 public class Rydeen{
18 private Context context;
19
20
21
22
23 public Rydeen(Context context){
24 this.context = context;
25 }
26
27
28
29
30 public void execute() throws ProcessorException{
31 try{
32 Processor[] processors = context.getProcessors();
33
34 TargetSource source = new TargetSourceBuilder().build(context.getTargets());
35 List<Summary> summaries = new ArrayList<Summary>();
36 for(int i = 0; i < processors.length; i++){
37 Destination dest;
38 if(i == (processors.length - 1)){
39 dest = new DestinationBuilder().build(context.getDestination());
40 }
41 else{
42 dest = new GlueDestination();
43 }
44 processors[i].init();
45 processors[i].execute(source, dest);
46 processors[i].finish();
47 summaries.add(processors[i].getSummary());
48 if(dest instanceof GlueDestination){
49 source = ((GlueDestination)dest).getTargetSource();
50 }
51 dest.close();
52 }
53
54 } catch(IOException e){
55 throw new ProcessorException(e);
56 }
57 }
58 }