[ 
http://jira.codehaus.org/browse/DOXIA-387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=219098#action_219098
 ] 

Robert Scholte commented on DOXIA-387:
--------------------------------------

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:
{code}
//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()  )
  }  
}
{code}


> Add RandomAccessSink
> --------------------
>
>                 Key: DOXIA-387
>                 URL: http://jira.codehaus.org/browse/DOXIA-387
>             Project: Maven Doxia
>          Issue Type: New Feature
>          Components: Sink API
>    Affects Versions: 1.1.2
>            Reporter: Robert Scholte
>            Priority: Minor
>         Attachments: randomaccesssink.patch
>
>
> 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
> {code}
> baseSink.text("Hello World");
> Sink top = baseSink.addSink();
> baseSink.horizontalRule();
> Sink content = baseSink.addSink();
> baseSink.text("So long, farewell");
> {code}
> After flushing the basesink, subsinks will flush to the basesink.
> Closing the basesink will close al subsinks as well.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to