~ubuntu-branches/ubuntu/vivid/doxia/vivid-proposed

« back to all changes in this revision

Viewing changes to doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/parser/list/TreeListBuilder.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-10-08 14:20:22 UTC
  • mfrom: (2.3.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091008142022-f6ccxganfr2tbaig
Tags: 1.1-3build1
Upload to karmic, avoiding new version from unstable. LP: #443292.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 * under the License.
20
20
 */
21
21
 
22
 
import org.apache.maven.doxia.module.confluence.parser.TextBlock;
23
 
 
24
22
import java.util.ArrayList;
 
23
import java.util.Iterator;
25
24
import java.util.List;
26
 
import java.util.Iterator;
27
 
 
 
25
 
 
26
import org.apache.maven.doxia.module.confluence.parser.ChildBlocksBuilder;
 
27
 
 
28
/**
 
29
 * <p>TreeListBuilder class.</p>
 
30
 *
 
31
 * @version $Id: TreeListBuilder.java 746983 2009-02-23 12:28:41Z vsiveton $
 
32
 */
28
33
public class TreeListBuilder
29
34
{
30
35
    private  TreeComponent root;
31
36
 
32
37
    private TreeComponent current;
33
38
 
34
 
    public TreeListBuilder()
 
39
    TreeListBuilder()
35
40
        throws IllegalArgumentException
36
41
    {
37
42
        root = new TreeComponent( null, "root", 0 );
39
44
        current = root;
40
45
    }
41
46
 
42
 
    public void feedEntry( int type, int level, String text )
 
47
    void feedEntry( int type, int level, String text )
43
48
    {
44
49
        int currentDepth = current.getDepth();
45
50
 
82
87
                }
83
88
            }
84
89
        }
85
 
        current.addChildren( text, type );
 
90
        current.addChildren( text.trim(), type );
86
91
    }
87
92
 
88
 
    public ListBlock getBlock()
 
93
    ListBlock getBlock()
89
94
    {
90
95
        return getList( root );
91
96
    }
94
99
    {
95
100
        List list = getListItems( treeComponent );
96
101
 
97
 
        int type = ((TreeComponent)treeComponent.getChildren().get(0)).getType();
 
102
        int type = ( (TreeComponent) treeComponent.getChildren().get( 0 ) ).getType();
98
103
 
99
104
        if ( type == ListBlockParser.BULLETED_LIST )
100
105
        {
101
106
            return new BulletedListBlock( list );
102
107
        }
103
 
        else
104
 
        {
105
 
            return new NumberedListBlock( list );
106
 
        }
 
108
 
 
109
        return new NumberedListBlock( list );
107
110
    }
108
111
 
109
112
    private List getListItems( TreeComponent tc )
114
117
        {
115
118
            TreeComponent child = (TreeComponent) i.next();
116
119
 
117
 
            List text = new ArrayList();
 
120
            List childBlocks = new ArrayList();
118
121
 
119
122
            if ( child.getFather() != null )
120
123
            {
121
 
                text.add( new TextBlock( child.getText() ) );
 
124
                childBlocks.addAll( new ChildBlocksBuilder( child.getText() ).getBlocks() );
122
125
            }
123
126
 
124
127
            if ( child.getChildren().size() != 0 )
125
128
            {
126
 
                blocks.add( new ListItemBlock( text, getList( child ) ) );
 
129
                blocks.add( new ListItemBlock( childBlocks, getList( child ) ) );
127
130
            }
128
131
            else
129
132
            {
130
 
                blocks.add( new ListItemBlock( text ) );
 
133
                blocks.add( new ListItemBlock( childBlocks ) );
131
134
            }
132
135
        }
133
136