001/* 002 Licensed to the Apache Software Foundation (ASF) under one 003 or more contributor license agreements. See the NOTICE file 004 distributed with this work for additional information 005 regarding copyright ownership. The ASF licenses this file 006 to you under the Apache License, Version 2.0 (the 007 "License"); you may not use this file except in compliance 008 with the License. You may obtain a copy of the License at 009 010 http://www.apache.org/licenses/LICENSE-2.0 011 012 Unless required by applicable law or agreed to in writing, 013 software distributed under the License is distributed on an 014 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 KIND, either express or implied. See the License for the 016 specific language governing permissions and limitations 017 under the License. 018*/ 019package org.apache.wiki.htmltowiki.syntax; 020 021import org.apache.wiki.htmltowiki.SyntaxDecorator; 022import org.apache.wiki.htmltowiki.WhitespaceTrimWriter; 023import org.apache.wiki.htmltowiki.XHtmlElementToWikiTranslator; 024import org.apache.wiki.htmltowiki.XHtmlToWikiConfig; 025import org.jdom2.Element; 026import org.jdom2.JDOMException; 027import org.jdom2.Text; 028 029import java.io.PrintWriter; 030import java.util.Deque; 031import java.util.Map; 032 033 034/** 035 * <p>Base Syntax decorator which translates to JSPWiki syntax. Delegates each kind of XHTML element to its specific 036 * decorator.</p> 037 * <p>This class is useful when developing a new wiki syntax decorator - just extend from it and provide the implementations of all 038 * the needed Decorators on the {@link SyntaxDecorator#init(PrintWriter, Deque, Deque, WhitespaceTrimWriter, XHtmlToWikiConfig, XHtmlElementToWikiTranslator)} method</p> 039 */ 040public abstract class WikiSyntaxDecorator implements SyntaxDecorator { 041 042 protected ADecorator a; 043 protected BrDecorator br; 044 protected CodeDecorator code; 045 protected DdDecorator dd; 046 protected DlDecorator dl; 047 protected DtDecorator dt; 048 protected FormDecorator form; 049 protected HrDecorator hr; 050 protected H1Decorator h1; 051 protected H2Decorator h2; 052 protected H3Decorator h3; 053 protected H4Decorator h4; 054 protected ImageDecorator img; 055 protected InputDecorator input; 056 protected LiDecorator li; 057 protected OlDecorator ol; 058 protected OptionDecorator option; 059 protected PDecorator p; 060 protected PlainTextDecorator plainText; 061 protected PlainTextBoldDecorator strong; 062 protected PlainTextCssDecorator css; 063 protected PlainTextCssSpecialDecorator cssStyle; 064 protected PlainTextItalicDecorator em; 065 protected PlainTextMonospaceDecorator pre; 066 protected SelectDecorator select; 067 protected StrikeDecorator strike; 068 protected SubDecorator sub; 069 protected SupDecorator sup; 070 protected TableDecorator table; 071 protected TbodyDecorator tbody; 072 protected TdDecorator td; 073 protected TextAreaDecorator textarea; 074 protected TextElementDecorator textElement; 075 protected ThDecorator th; 076 protected TheadDecorator thead; 077 protected TrDecorator tr; 078 protected UlDecorator ul; 079 protected UnderlineDecorator underline; 080 protected WhitespaceTrimWriter outTrimmer; 081 protected XHtmlElementToWikiTranslator chain; 082 protected XHtmlToWikiConfig config; 083 084 /** {@inheritDoc} */ 085 @Override 086 public void a( final Element e, final String ref ) throws JDOMException { 087 a.decorate( e, ref ); 088 } 089 090 /** {@inheritDoc} */ 091 @Override 092 public void aFootnote( final String text, final String ref ) { 093 a.decorateFootnote( text, ref ); 094 } 095 096 /** {@inheritDoc} */ 097 @Override 098 public void aUndefined( final Element e ) throws JDOMException { 099 a.decorateUndefinedLink( e ); 100 } 101 102 /** {@inheritDoc} */ 103 @Override 104 public void br( final Element base, final Element e ) throws JDOMException { 105 br.decorate( base, e ); 106 } 107 108 /** {@inheritDoc} */ 109 @Override 110 public void code( final Element e ) throws JDOMException { 111 code.decorate( e ); 112 } 113 114 /** {@inheritDoc} */ 115 @Override 116 public void dd( final Element e ) throws JDOMException { 117 dd.decorate( e ); 118 } 119 120 /** {@inheritDoc} */ 121 @Override 122 public void dl( final Element e ) throws JDOMException { 123 dl.decorate( e ); 124 } 125 126 /** {@inheritDoc} */ 127 @Override 128 public void dt( final Element e ) throws JDOMException { 129 dt.decorate( e ); 130 } 131 132 /** {@inheritDoc} */ 133 @Override 134 public void em( final Element e ) throws JDOMException { 135 em.decorate( e ); 136 } 137 138 /** {@inheritDoc} */ 139 @Override 140 public void form( final Element e ) throws JDOMException { 141 form.decorate( e ); 142 } 143 144 /** {@inheritDoc} */ 145 @Override 146 public void hr( final Element e ) throws JDOMException { 147 hr.decorate( e ); 148 } 149 150 /** {@inheritDoc} */ 151 @Override 152 public void h1( final Element e ) throws JDOMException { 153 h1.decorate( e ); 154 } 155 156 /** {@inheritDoc} */ 157 @Override 158 public void h2( final Element e ) throws JDOMException { 159 h2.decorate( e ); 160 } 161 162 /** {@inheritDoc} */ 163 @Override 164 public void h3( final Element e ) throws JDOMException { 165 h3.decorate( e ); 166 } 167 168 /** {@inheritDoc} */ 169 @Override 170 public void h4( final Element e ) throws JDOMException { 171 h4.decorate( e ); 172 } 173 174 /** {@inheritDoc} */ 175 @Override 176 public void image( final String src, final Map< String, Object > imageAttrs ) { 177 img.decorate( src, imageAttrs ); 178 } 179 180 /** {@inheritDoc} */ 181 @Override 182 public void img( final Element e ) { 183 img.decorate( e ); 184 } 185 186 /** {@inheritDoc} */ 187 @Override 188 public void input( final Element e ) throws JDOMException { 189 input.decorate( e ); 190 } 191 192 /** {@inheritDoc} */ 193 @Override 194 public void li( final Element base, final Element e ) throws JDOMException { 195 li.decorate( base, e ); 196 } 197 198 /** {@inheritDoc} */ 199 @Override 200 public void ol( final Element e ) throws JDOMException { 201 ol.decorate( e ); 202 } 203 204 /** {@inheritDoc} */ 205 @Override 206 public void option( final Element base, final Element e ) throws JDOMException { 207 option.decorate( base, e ); 208 } 209 210 /** {@inheritDoc} */ 211 @Override 212 public void p( final Element e ) throws JDOMException { 213 p.decorate( e ); 214 } 215 216 /** {@inheritDoc} */ 217 @Override 218 public void paragraph( final XHtmlElementToWikiTranslator.ElementDecoratorData dto ) throws JDOMException { 219 plainText.decorate( dto ); 220 } 221 222 /** {@inheritDoc} */ 223 @Override 224 public void pre( final Element e ) throws JDOMException { 225 pre.decorate( e ); 226 } 227 228 /** {@inheritDoc} */ 229 @Override 230 public void strong( final Element e ) throws JDOMException { 231 strong.decorate( e ); 232 } 233 234 /** {@inheritDoc} */ 235 @Override 236 public void table( final Element e ) throws JDOMException { 237 table.decorate( e ); 238 } 239 240 /** {@inheritDoc} */ 241 @Override 242 public void tbody( final Element e ) throws JDOMException { 243 tbody.decorate( e ); 244 } 245 246 /** {@inheritDoc} */ 247 @Override 248 public void td( final Element e ) throws JDOMException { 249 td.decorate( e ); 250 } 251 252 /** {@inheritDoc} */ 253 @Override 254 public void text( final Text element ) { 255 textElement.decorate( element ); 256 } 257 258 /** {@inheritDoc} */ 259 @Override 260 public void textarea( final Element e ) throws JDOMException { 261 textarea.decorate( e ); 262 } 263 264 /** {@inheritDoc} */ 265 @Override 266 public void th( final Element e ) throws JDOMException { 267 th.decorate( e ); 268 } 269 270 /** {@inheritDoc} */ 271 @Override 272 public void thead( final Element e ) throws JDOMException { 273 thead.decorate( e ); 274 } 275 276 /** {@inheritDoc} */ 277 @Override 278 public void tr( final Element e ) throws JDOMException { 279 tr.decorate( e ); 280 } 281 282 /** {@inheritDoc} */ 283 @Override 284 public void select( final Element e ) throws JDOMException { 285 select.decorate( e ); 286 } 287 288 /** {@inheritDoc} */ 289 @Override 290 public void strike( final Element e ) throws JDOMException { 291 strike.decorate( e ); 292 } 293 294 /** {@inheritDoc} */ 295 @Override 296 public void sub( final Element e ) throws JDOMException { 297 sub.decorate( e ); 298 } 299 300 /** {@inheritDoc} */ 301 @Override 302 public void sup( final Element e ) throws JDOMException { 303 sup.decorate( e ); 304 } 305 306 /** {@inheritDoc} */ 307 @Override 308 public void ul( final Element e ) throws JDOMException { 309 ul.decorate( e ); 310 } 311 312 /** {@inheritDoc} */ 313 @Override 314 public void underline( final Element e ) throws JDOMException { 315 underline.decorate( e ); 316 } 317 318}