static List < List < Segment > > readSegmentLinesBeforeRendering ( AbstractContainerSegment container ) { List < List < Segment >> lines = new ArrayList <> ( ) ; List < Segment > currentLine = new ArrayList <> ( ) ; for ( Segment segment : container ) { if ( ! SegmentType . LINE_SEPARATOR . equals ( segment . getType ( ) ) ) { currentLine . add ( segment ) ; } else { // New line separator - flush the line currentLine . add ( segment ) ; lines . add ( currentLine ) ; currentLine = new ArrayList <> ( ) ; } } // Add the last line manually - there is no line separator to trigger // flush if ( ! currentLine . isEmpty ( ) ) { lines . add ( currentLine ) ; } return lines ; }
Read segment lines before rendering .