Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1.2
    • Fix Version/s: 1.3
    • Component/s: Core
    • Labels:
      None
    • Number of attachments :
      3

      Description

      In some cases components have to write to different parts of a page. With the current implementation you can only keep appending the page.
      I've attached a new class, with which it should be possible to add subsinks to which you can write at any time.

      Code might look like this

      baseSink.text("Hello World");
      Sink top = baseSink.addSink();
      baseSink.horizontalRule();
      Sink content = baseSink.addSink();
      baseSink.text("So long, farewell");
      

      After flushing the basesink, subsinks will flush to the basesink.
      Closing the basesink will close al subsinks as well.

      1. DOXIA-387.patch
        24 kB
        Robert Scholte
      2. DOXIA-387.patch
        19 kB
        Robert Scholte
      3. randomaccesssink.patch
        15 kB
        Robert Scholte

        Activity

        Hide
        Robert Scholte added a comment -

        Hmm, tried to write some tests, where I'd like to use the SinkAdapter. But that class seems to be part of the doxia-core, so that would result in a circular dependency. The RandomAccessSink itself only uses Sink and SinkFactory, no specific implementation so the Sink API looked like a valid location. Should I move this patch or just use an anonymous implementation classes for the tests?

        Show
        Robert Scholte added a comment - Hmm, tried to write some tests, where I'd like to use the SinkAdapter. But that class seems to be part of the doxia-core, so that would result in a circular dependency. The RandomAccessSink itself only uses Sink and SinkFactory, no specific implementation so the Sink API looked like a valid location. Should I move this patch or just use an anonymous implementation classes for the tests?
        Hide
        Lukas Theussl added a comment -

        Your sink is itself an implementation so it should go into core. A test case will help as I don't quite understand the use case (yet).

        Show
        Lukas Theussl added a comment - Your sink is itself an implementation so it should go into core. A test case will help as I don't quite understand the use case (yet).
        Hide
        Robert Scholte added a comment -

        I have to dive a bit more into this. It seems like a lot of files have been moved.
        First let me explain it with a concrete example. Although I need this for the dashboard-m-p, for the explanation the surefire-report-m-p will work as well.
        A surefire is divided into 3 sections: Summary, Package List and Test Cases. Every next section contains more detail than it's previous.
        Since you can only build the page from start to end, you have to iterate over all entries once per section.
        With the RandomAccessSink you only have to iterate once over these entries and directly write to it's specific sectionsink. Code would look like this:

        //prepare RandomAccessSink structure
        RandomAccessSink baseSink = new RandomAccessSink(); //some arguments required here, at least a SinkFactory
        Sink summarySink = baseSink.addSink();
        baseSink.horizontalRule(); // some divider-stuff
        Sink packageListSink= baseSink.addSink();
        baseSink.horizontalRule(); // some divider-stuff
        Sink testCasesSink = baseSink.addSink();
        
        //get packageList Iterator
        while ( packageListIter.hasNext() )
        {
          writePackageList(packageListSink, packageListIter.next()  )
          
          //get testCases Iterator
          while ( testCasesIter.hasNext() )
          {
            writeTestCases(testCasesSink , testCasesIter.next()  )
          }  
        }
        
        Show
        Robert Scholte added a comment - I have to dive a bit more into this. It seems like a lot of files have been moved. First let me explain it with a concrete example. Although I need this for the dashboard-m-p, for the explanation the surefire-report-m-p will work as well. A surefire is divided into 3 sections: Summary, Package List and Test Cases. Every next section contains more detail than it's previous. Since you can only build the page from start to end, you have to iterate over all entries once per section. With the RandomAccessSink you only have to iterate once over these entries and directly write to it's specific sectionsink. Code would look like this: //prepare RandomAccessSink structure RandomAccessSink baseSink = new RandomAccessSink(); //some arguments required here, at least a SinkFactory Sink summarySink = baseSink.addSink(); baseSink.horizontalRule(); // some divider-stuff Sink packageListSink= baseSink.addSink(); baseSink.horizontalRule(); // some divider-stuff Sink testCasesSink = baseSink.addSink(); //get packageList Iterator while ( packageListIter.hasNext() ) { writePackageList(packageListSink, packageListIter.next() ) //get testCases Iterator while ( testCasesIter.hasNext() ) { writeTestCases(testCasesSink , testCasesIter.next() ) } }
        Hide
        Robert Scholte added a comment -

        Moved RandomAccessSink to doxia-core and added two tests. If you want to use this with the AbstractMavenReport, it could to nice to be able to get a reference to the SinkFactory next to the getSink()

        Show
        Robert Scholte added a comment - Moved RandomAccessSink to doxia-core and added two tests. If you want to use this with the AbstractMavenReport, it could to nice to be able to get a reference to the SinkFactory next to the getSink()
        Hide
        Lukas Theussl added a comment -

        As a new feature, schedule for a minor release. A minor note: please add license header and javadocs to any future patches, see http://maven.apache.org/developers/conventions/code.html.

        Show
        Lukas Theussl added a comment - As a new feature, schedule for a minor release. A minor note: please add license header and javadocs to any future patches, see http://maven.apache.org/developers/conventions/code.html .
        Hide
        Robert Scholte added a comment -

        You're absolutely right. It's just not in my system yet, but it's getting better day by day . Here's a new patch.

        Show
        Robert Scholte added a comment - You're absolutely right. It's just not in my system yet, but it's getting better day by day . Here's a new patch.
        Hide
        Robert Scholte added a comment -

        Fixed in rev. 1228615

        Show
        Robert Scholte added a comment - Fixed in rev. 1228615

          People

          • Assignee:
            Robert Scholte
            Reporter:
            Robert Scholte
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: