001package com.hfg.html; 002 003import com.hfg.html.attribute.Align; 004import com.hfg.css.CssUtil; 005import com.hfg.xml.XMLNode; 006 007//------------------------------------------------------------------------------ 008/** 009 * Represents a heading (<h2>) tag. 010 * 011 * @author J. Alex Taylor, hairyfatguy.com 012 */ 013//------------------------------------------------------------------------------ 014// com.hfg XML/HTML Coding Library 015// 016// This library is free software; you can redistribute it and/or 017// modify it under the terms of the GNU Lesser General Public 018// License as published by the Free Software Foundation; either 019// version 2.1 of the License, or (at your option) any later version. 020// 021// This library is distributed in the hope that it will be useful, 022// but WITHOUT ANY WARRANTY; without even the implied warranty of 023// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 024// Lesser General Public License for more details. 025// 026// You should have received a copy of the GNU Lesser General Public 027// License along with this library; if not, write to the Free Software 028// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 029// 030// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 031// jataylor@hairyfatguy.com 032//------------------------------------------------------------------------------ 033 034public class H2 extends HTMLTag 035{ 036 037 //########################################################################## 038 // CONSTRUCTORS 039 //########################################################################## 040 041 //-------------------------------------------------------------------------- 042 public H2() 043 { 044 super(HTML.H2); 045 } 046 047 //-------------------------------------------------------------------------- 048 public H2(String inContent) 049 { 050 this(); 051 addContent(inContent); 052 } 053 054 //-------------------------------------------------------------------------- 055 public H2(HTMLTag inContent) 056 { 057 this(); 058 addSubtag(inContent); 059 } 060 061 //-------------------------------------------------------------------------- 062 public H2(XMLNode inXMLNode) 063 { 064 this(); 065 initFromXMLNode(inXMLNode); 066 } 067 068 //########################################################################## 069 // PUBLIC METHODS 070 //########################################################################## 071 072 073 //-------------------------------------------------------------------------- 074 public Center addCenter() 075 { 076 Center center = new Center(); 077 addSubtag(center); 078 079 return center; 080 } 081 082 //-------------------------------------------------------------------------- 083 public Center addCenter(String inContent) 084 { 085 Center center = new Center(inContent); 086 addSubtag(center); 087 088 return center; 089 } 090 091 //-------------------------------------------------------------------------- 092 public Center addCenter(HTMLTag inContent) 093 { 094 Center center = new Center(inContent); 095 addSubtag(center); 096 097 return center; 098 } 099 100 //-------------------------------------------------------------------------- 101 public Div addDiv() 102 { 103 Div div = new Div(); 104 addSubtag(div); 105 106 return div; 107 } 108 109 //-------------------------------------------------------------------------- 110 public Div addDiv(HTMLTag inContent) 111 { 112 Div div = new Div(inContent); 113 addSubtag(div); 114 115 return div; 116 } 117 118 119 //-------------------------------------------------------------------------- 120 public Img addImage(String inSrc) 121 { 122 Img image = new Img(inSrc); 123 addSubtag(image); 124 125 return image; 126 } 127 128 //-------------------------------------------------------------------------- 129 public Link addLink() 130 { 131 Link link = new Link(); 132 addSubtag(link); 133 134 return link; 135 } 136 137 //-------------------------------------------------------------------------- 138 public Link addLink(CharSequence inURL) 139 { 140 Link link = new Link(inURL); 141 addSubtag(link); 142 143 return link; 144 } 145 146 //-------------------------------------------------------------------------- 147 public Link addLink(CharSequence inURL, String inContent) 148 { 149 Link link = new Link(inURL, inContent); 150 addSubtag(link); 151 152 return link; 153 } 154 155 //-------------------------------------------------------------------------- 156 public Link addLink(CharSequence inURL, HTMLTag inContent) 157 { 158 Link link = new Link(inURL, inContent); 159 addSubtag(link); 160 161 return link; 162 } 163 164 //-------------------------------------------------------------------------- 165 public Nobr addNobr() 166 { 167 Nobr nobr = new Nobr(); 168 addSubtag(nobr); 169 170 return nobr; 171 } 172 173 //-------------------------------------------------------------------------- 174 public Nobr addNobr(String inContent) 175 { 176 Nobr nobr = new Nobr(inContent); 177 addSubtag(nobr); 178 179 return nobr; 180 } 181 182 //-------------------------------------------------------------------------- 183 public Nobr addNobr(HTMLTag inContent) 184 { 185 Nobr nobr = new Nobr(inContent); 186 addSubtag(nobr); 187 188 return nobr; 189 } 190 191 192 //-------------------------------------------------------------------------- 193 public Pre addPre() 194 { 195 Pre pre = new Pre(); 196 addSubtag(pre); 197 198 return pre; 199 } 200 201 //-------------------------------------------------------------------------- 202 public Pre addPre(String inContent) 203 { 204 Pre pre = new Pre(inContent); 205 addSubtag(pre); 206 207 return pre; 208 } 209 210 //-------------------------------------------------------------------------- 211 public Pre addPre(HTMLTag inContent) 212 { 213 Pre pre = new Pre(inContent); 214 addSubtag(pre); 215 216 return pre; 217 } 218 219 //-------------------------------------------------------------------------- 220 public Span addSpan() 221 { 222 Span span = new Span(); 223 addSubtag(span); 224 225 return span; 226 } 227 228 //-------------------------------------------------------------------------- 229 public Span addSpan(String inContent) 230 { 231 Span span = new Span(inContent); 232 addSubtag(span); 233 234 return span; 235 } 236 237 //-------------------------------------------------------------------------- 238 public Span addSpan(HTMLTag inContent) 239 { 240 Span span = new Span(inContent); 241 addSubtag(span); 242 243 return span; 244 } 245 246 247 //-------------------------------------------------------------------------- 248 public Table addTable() 249 { 250 Table table = new Table(); 251 addSubtag(table); 252 253 return table; 254 } 255 256 //-------------------------------------------------------------------------- 257 public Ul addUnorderedList() 258 { 259 Ul ul = new Ul(); 260 addSubtag(ul); 261 262 return ul; 263 } 264 265 266 267 268 269 //-------------------------------------------------------------------------- 270 public H2 setAlign(Align inValue) 271 { 272 setAttribute(inValue.getHTMLAttributeName(), inValue.toString()); 273 return this; 274 } 275 276 //-------------------------------------------------------------------------- 277 public H2 setId(String inValue) 278 { 279 setAttribute(HTML.ID, inValue); 280 return this; 281 } 282 283 //-------------------------------------------------------------------------- 284 @Override 285 public H2 setClass(String inValue) 286 { 287 setAttribute(HTML.CLASS, inValue); 288 return this; 289 } 290 291 //--------------------------------------------------------------------------- 292 public H2 setOnClick(String inValue) 293 { 294 setAttribute(HTML.ONCLICK, inValue); 295 296 return this; 297 } 298 299 //-------------------------------------------------------------------------- 300 public H2 setStyle(String inValue) 301 { 302 setAttribute(HTML.STYLE, inValue); 303 304 return this; 305 } 306 307 //-------------------------------------------------------------------------- 308 @Override 309 public H2 addStyle(String inValue) 310 { 311 CssUtil.addStyle(this, inValue); 312 return this; 313 } 314 315 316 //-------------------------------------------------------------------------- 317 public void br() 318 { 319 HTMLUtil.br(this); 320 } 321 322 //-------------------------------------------------------------------------- 323 public void br(int inNumber) 324 { 325 HTMLUtil.br(this, inNumber); 326 } 327 328 //-------------------------------------------------------------------------- 329 public void nbsp(int inNumber) 330 { 331 HTMLUtil.nbsp(this, inNumber); 332 } 333 334 //-------------------------------------------------------------------------- 335 public void hr() 336 { 337 HTMLUtil.hr(this); 338 } 339 340 //-------------------------------------------------------------------------- 341 public void hr(String inWidth) 342 { 343 HTMLUtil.hr(this, inWidth); 344 } 345 346}