コード例 #1
0
ファイル: Main.java プロジェクト: ManuelaLjubicic/UE01
  public static void pushPipelineB() {
    PushPipe<CharTransfer> pipe1 = new PushPipe<>();
    CharacterSource filter1 = new CharacterSource(pipe1);

    PushPipe<WordTransfer> pipe2 = new PushPipe<>();
    CharToWordFilter filter2 = new CharToWordFilter(pipe2);

    PushPipe<LineWithLineNumber> pipe3 = new PushPipe<>();
    WordToLineFilter filter3 = new WordToLineFilter(pipe3, len, align);

    PushPipe<LinkedList<String>> pipe4 = new PushPipe<>();
    LineToListFilter filter4 = new LineToListFilter(pipe4);

    PrintSink filter5 = new PrintSink(outputPath);

    pipe1.setSuccessorFilter(filter2);
    pipe2.setSuccessorFilter(filter3);
    pipe3.setSuccessorFilter(filter4);
    pipe4.setSuccessorFilter(filter5);

    try {
      filter1.write(new File("").getAbsolutePath() + inputPath);
    } catch (StreamCorruptedException e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
ファイル: Main.java プロジェクト: ManuelaLjubicic/UE01
  public static void pushPipelineAandB() {
    PushPipe<CharTransfer> pipe1 = new PushPipe<>();
    CharacterSource filter1 = new CharacterSource(pipe1);

    PushPipe<WordTransfer> pipe2 = new PushPipe<>();
    CharToWordFilter filter2 = new CharToWordFilter(pipe2);

    PushPipe<LineWithLineNumber> pipe3 = new PushPipe<>();
    // Allignment wird hier nicht durchgeführt, da der LineToWordFilter alle Leerzeichen wieder
    // entfernt
    WordToLineFilter filter3 = new WordToLineFilter(pipe3, len, align);

    PushPipe<WordArray> pipe4 = new PushPipe<>();
    LineToWordFilter filter4 = new LineToWordFilter(pipe4);

    PushPipe<LinkedList<LineWithLineNumber>> pipe5 = new PushPipe<>();
    ShiftFilter filter5 = new ShiftFilter(pipe5);

    PushPipe<LinkedList<String>> pipe6 = new PushPipe<>();
    CreateIndexFilter filter6 = new CreateIndexFilter(pipe6);

    PrintSink filter7 = new PrintSink(outputPath);

    pipe1.setSuccessorFilter(filter2);
    pipe2.setSuccessorFilter(filter3);
    pipe3.setSuccessorFilter(filter4);
    pipe4.setSuccessorFilter(filter5);
    pipe5.setSuccessorFilter(filter6);
    pipe6.setSuccessorFilter(filter7);

    try {
      filter1.write(new File("").getAbsolutePath() + inputPath);
    } catch (StreamCorruptedException e) {
      e.printStackTrace();
    }
  }