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

« back to all changes in this revision

Viewing changes to doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/parser/LinkBlock.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:
21
21
 
22
22
import org.apache.maven.doxia.sink.Sink;
23
23
 
24
 
 
25
24
/**
26
25
 * Block that represents a link.
27
26
 *
28
27
 * @author Juan F. Codagnone
29
 
 * @since Nov 4, 2005
 
28
 * @version $Id: LinkBlock.java 705065 2008-10-15 21:46:08Z vsiveton $
30
29
 */
31
 
public class LinkBlock implements Block
 
30
class LinkBlock
 
31
    implements Block
32
32
{
33
33
    /**
34
34
     * link reference
35
35
     */
36
36
    private final String reference;
 
37
 
37
38
    /**
38
39
     * link text
39
40
     */
40
 
    private final String text;
41
 
 
42
 
    /**
43
 
     * Creates the LinkBlock.
44
 
     *
45
 
     * @param reference reference anchor
46
 
     * @param text      text to show
 
41
    private final Block content;
 
42
 
 
43
    /**
 
44
     * Creates the LinkBlock.
 
45
     *
 
46
     * @param reference reference anchor
 
47
     * @param text text to display
 
48
     * @deprecated
 
49
     */
 
50
    LinkBlock( final String reference, final String text )
 
51
    {
 
52
        this( reference, new TextBlock( text ) );
 
53
    }
 
54
 
 
55
    /**
 
56
     * Creates the LinkBlock.
 
57
     *
 
58
     * @param reference reference anchor
 
59
     * @param content block with the displayed content
47
60
     * @throws IllegalArgumentException if any argument is <code>null</code>
48
61
     */
49
 
    public LinkBlock( final String reference, final String text )
 
62
    LinkBlock( final String reference, final Block content )
50
63
        throws IllegalArgumentException
51
64
    {
52
 
        if ( reference == null || text == null )
 
65
        if ( reference == null || content == null )
53
66
        {
54
67
            throw new IllegalArgumentException( "arguments can't be null" );
55
68
        }
56
69
        this.reference = reference;
57
 
        this.text = text;
 
70
        this.content = content;
58
71
    }
59
72
 
60
 
    /**
61
 
     * @see Block#traverse(org.apache.maven.doxia.sink.Sink)
62
 
     */
 
73
    /** {@inheritDoc} */
63
74
    public final void traverse( final Sink sink )
64
75
    {
65
76
        sink.link( reference );
66
 
        sink.text( text );
 
77
        content.traverse( sink );
67
78
        sink.link_();
68
79
 
69
80
    }
70
81
 
71
 
    /**
72
 
     * @see Object#equals(Object)
73
 
     */
74
 
    
 
82
    /** {@inheritDoc} */
75
83
    public final boolean equals( final Object obj )
76
84
    {
77
85
        boolean ret = false;
83
91
        else if ( obj instanceof LinkBlock )
84
92
        {
85
93
            final LinkBlock l = (LinkBlock) obj;
86
 
            ret = reference.equals( l.reference )
87
 
                && text.equals( l.text );
 
94
            ret = reference.equals( l.reference ) && content.equals( l.content );
88
95
        }
89
96
 
90
97
        return ret;
91
98
    }
92
99
 
93
 
    /**
94
 
     * @see Object#hashCode()
95
 
     */
96
 
    
 
100
    /** {@inheritDoc} */
97
101
    public final int hashCode()
98
102
    {
99
103
        final int magic1 = 17;
100
104
        final int magic2 = 37;
101
105
 
102
 
        return magic1 + magic2 * reference.hashCode()
103
 
            + magic2 * text.hashCode();
 
106
        return magic1 + magic2 * reference.hashCode() + magic2 * content.hashCode();
104
107
    }
105
 
 
106
108
}