~ubuntu-branches/ubuntu/vivid/herold/vivid

« back to all changes in this revision

Viewing changes to java/org/dbdoclet/trafo/tag/html/InlineElement.java

  • Committer: Package Import Robot
  • Author(s): Mathieu Malaterre
  • Date: 2012-09-20 10:00:14 UTC
  • Revision ID: package-import@ubuntu.com-20120920100014-5pcwbw2err6on8yg
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright (C) 2001-2012 Michael Fuchs
 
3
 *
 
4
 * This file is part of herold.
 
5
 * 
 
6
 * herold is free software: you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation, either version 3 of the License, or
 
9
 * (at your option) any later version.
 
10
 * 
 
11
 * herold is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 * 
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with herold.  If not, see <http://www.gnu.org/licenses/>.  
 
18
 */
 
19
package org.dbdoclet.trafo.tag.html;
 
20
 
 
21
import java.util.HashMap;
 
22
 
 
23
import org.dbdoclet.xiphias.dom.TextImpl;
 
24
import org.w3c.dom.Node;
 
25
 
 
26
abstract public class InlineElement extends HtmlElement {
 
27
 
 
28
    @Override
 
29
        protected boolean validate(HashMap<String, HashMap<String, String>> validParentMap) {
 
30
 
 
31
        if (validParentMap == null) {
 
32
 
 
33
            throw new IllegalArgumentException("Parameter validParentMap is null!");
 
34
        }
 
35
 
 
36
        if (getParentNode() == null) {
 
37
 
 
38
            throw new NullPointerException("Variable getParent() is null!");
 
39
        }
 
40
 
 
41
        if (nodeStack == null) {
 
42
 
 
43
            throw new NullPointerException("Variable nodeStack is null!");
 
44
        }
 
45
 
 
46
        nodeStack.removeAllElements();
 
47
        nodeStack.push(this);
 
48
 
 
49
        if (validParentMap.get(getParentNode().getNodeName()) != null) {
 
50
            return true;
 
51
        }
 
52
 
 
53
        if (getParentNode() instanceof Fieldset) {
 
54
 
 
55
            Node child = getParentNode().getFirstChild();
 
56
 
 
57
            if ((child == null) || !(child instanceof Legend)) {
 
58
 
 
59
                Legend legend = new Legend();
 
60
                getParentNode().appendChild(legend);
 
61
 
 
62
                legend.appendChild(new TextImpl("Legend", legend));
 
63
            }
 
64
 
 
65
            return true;
 
66
        }
 
67
 
 
68
        if (getParentNode() instanceof Select) {
 
69
 
 
70
            nodeStack.removeAllElements();
 
71
 
 
72
            Option option = new Option();
 
73
            nodeStack.push(option);
 
74
 
 
75
            return true;
 
76
        }
 
77
 
 
78
        if (getParentNode() instanceof Optgroup) {
 
79
 
 
80
            nodeStack.removeAllElements();
 
81
 
 
82
            Option option = new Option();
 
83
            nodeStack.push(option);
 
84
 
 
85
            return true;
 
86
        }
 
87
 
 
88
        if (getParentNode() instanceof Dl) {
 
89
 
 
90
            Dd dd = new Dd();
 
91
            dd.appendChild(this);
 
92
 
 
93
            nodeStack.push(dd);
 
94
 
 
95
            return true;
 
96
        }
 
97
 
 
98
        if (getParentNode() instanceof Dir || getParentNode() instanceof Menu || getParentNode() instanceof Ol
 
99
            || getParentNode() instanceof Ul) {
 
100
 
 
101
            Li li = new Li();
 
102
            li.appendChild(this);
 
103
 
 
104
            nodeStack.push(li);
 
105
 
 
106
            return true;
 
107
        }
 
108
 
 
109
        if (getParentNode() instanceof Table) {
 
110
 
 
111
            Tr tr = new Tr();
 
112
            Td td = new Td();
 
113
            tr.appendChild(td);
 
114
            td.appendChild(this);
 
115
 
 
116
            nodeStack.push(td);
 
117
            nodeStack.push(tr);
 
118
 
 
119
            return true;
 
120
        }
 
121
 
 
122
        if (getParentNode() instanceof Tbody || getParentNode() instanceof Tfoot
 
123
            || getParentNode() instanceof Thead) {
 
124
 
 
125
            Tr tr = new Tr();
 
126
            Td td = new Td();
 
127
            tr.appendChild(td);
 
128
            td.appendChild(this);
 
129
 
 
130
            nodeStack.push(td);
 
131
            nodeStack.push(tr);
 
132
 
 
133
            return true;
 
134
        }
 
135
 
 
136
        if (getParentNode() instanceof Tr) {
 
137
 
 
138
            Td td = new Td();
 
139
            td.appendChild(this);
 
140
 
 
141
            nodeStack.push(td);
 
142
 
 
143
            return true;
 
144
        }
 
145
 
 
146
        if (getParentNode() instanceof Map) {
 
147
 
 
148
            Div div = new Div();
 
149
            div.appendChild(this);
 
150
 
 
151
            nodeStack.push(div);
 
152
 
 
153
            return true;
 
154
        }
 
155
 
 
156
        return false;
 
157
    }
 
158
}