Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
XHTMLBlock |
|
| 2.5;2,5 |
1 | package org.apache.maven.doxia.module.twiki.parser; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import org.apache.maven.doxia.sink.Sink; | |
23 | ||
24 | /** | |
25 | * An XHTML Block | |
26 | * | |
27 | * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> | |
28 | * @version $Id: XHTMLBlock.java 763762 2009-04-09 18:19:56Z ltheussl $ | |
29 | */ | |
30 | class XHTMLBlock | |
31 | implements Block | |
32 | { | |
33 | private final String tag; | |
34 | ||
35 | /** | |
36 | * Creates the XHTMLBlock. | |
37 | * | |
38 | * @param tag the tag, eg: <pre> | |
39 | * @throws IllegalArgumentException if the arguments are <code>null</code> | |
40 | */ | |
41 | XHTMLBlock( final String tag ) | |
42 | 0 | { |
43 | 0 | if ( tag == null ) |
44 | { | |
45 | 0 | throw new IllegalArgumentException( "argument can't be null" ); |
46 | } | |
47 | 0 | this.tag = tag; |
48 | 0 | } |
49 | ||
50 | /** {@inheritDoc}*/ | |
51 | public final void traverse( final Sink sink ) | |
52 | { | |
53 | 0 | if ( tag.trim().length() == 0 ) |
54 | { | |
55 | 0 | return; |
56 | } | |
57 | ||
58 | 0 | sink.rawText( tag ); |
59 | 0 | } |
60 | ||
61 | /** {@inheritDoc}*/ | |
62 | public final boolean equals( final Object obj ) | |
63 | { | |
64 | 0 | boolean ret = false; |
65 | ||
66 | 0 | if ( obj == this ) |
67 | { | |
68 | 0 | ret = true; |
69 | } | |
70 | 0 | else if ( obj instanceof XHTMLBlock ) |
71 | { | |
72 | 0 | final XHTMLBlock a = (XHTMLBlock) obj; |
73 | ||
74 | 0 | ret = tag.equals( a.tag ); |
75 | } | |
76 | ||
77 | 0 | return ret; |
78 | } | |
79 | ||
80 | /** {@inheritDoc}*/ | |
81 | public final int hashCode() | |
82 | { | |
83 | 0 | return tag.hashCode(); |
84 | } | |
85 | } |