2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
*
|
2007-02-12 01:59:05 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2003-09-14 16:46:38 +02:00
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2004-11-03 00:37:00 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2003-09-14 16:46:38 +02:00
|
|
|
*
|
2004-11-03 00:37:00 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2003-09-14 16:46:38 +02:00
|
|
|
*
|
2004-11-03 00:37:00 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
|
|
|
|
2014-02-15 11:35:08 +01:00
|
|
|
package org.jivesoftware.smackx.xhtmlim;
|
2003-09-14 16:46:38 +02:00
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
import org.jivesoftware.smack.packet.Message;
|
|
|
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
2003-09-28 05:13:45 +02:00
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
2018-05-09 23:06:12 +02:00
|
|
|
* An XHTMLText represents formatted text. This class also helps to build valid
|
2003-09-14 16:46:38 +02:00
|
|
|
* XHTML tags.
|
|
|
|
*
|
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
|
|
|
public class XHTMLText {
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String NAMESPACE = "http://www.w3.org/1999/xhtml";
|
2014-02-10 13:51:12 +01:00
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
private final XmlStringBuilder text = new XmlStringBuilder();
|
2003-09-14 16:46:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new XHTMLText with body tag params.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param style the XHTML style of the body
|
|
|
|
* @param lang the language of the body
|
|
|
|
*/
|
|
|
|
public XHTMLText(String style, String lang) {
|
2003-09-28 05:13:45 +02:00
|
|
|
appendOpenBodyTag(style, lang);
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
2003-09-28 05:13:45 +02:00
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String A = "a";
|
|
|
|
public static final String HREF = "href";
|
|
|
|
public static final String STYLE = "style";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that an anchor section begins.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param href indicates the URL being linked to
|
|
|
|
* @param style the XHTML style of the anchor
|
2017-12-23 20:21:19 +01:00
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenAnchorTag(String href, String style) {
|
|
|
|
text.halfOpenElement(A);
|
|
|
|
text.optAttribute(HREF, href);
|
|
|
|
text.optAttribute(STYLE, style);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that an anchor section ends.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseAnchorTag() {
|
|
|
|
text.closeElement(A);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String BLOCKQUOTE = "blockquote";
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that a blockquote section begins.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param style the XHTML style of the blockquote
|
2017-12-23 20:21:19 +01:00
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenBlockQuoteTag(String style) {
|
|
|
|
text.halfOpenElement(BLOCKQUOTE);
|
|
|
|
text.optAttribute(STYLE, style);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that a blockquote section ends.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseBlockQuoteTag() {
|
|
|
|
text.closeElement(BLOCKQUOTE);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that a body section begins.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param style the XHTML style of the body
|
|
|
|
* @param lang the language of the body
|
2017-12-23 20:21:19 +01:00
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
private XHTMLText appendOpenBodyTag(String style, String lang) {
|
|
|
|
text.halfOpenElement(Message.BODY);
|
|
|
|
text.xmlnsAttribute(NAMESPACE);
|
2019-05-06 00:38:22 +02:00
|
|
|
text.optAttribute(STYLE, style);
|
2014-07-05 14:19:31 +02:00
|
|
|
text.xmllangAttribute(lang);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2017-12-23 20:21:19 +01:00
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that the body section ends.
|
|
|
|
*
|
|
|
|
* @return this.
|
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseBodyTag() {
|
|
|
|
text.closeElement(Message.BODY);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String BR = "br";
|
|
|
|
public static final String CITE = "cite";
|
|
|
|
public static final String CODE = "code";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
* Appends a tag that inserts a single carriage return.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendBrTag() {
|
2014-07-15 18:02:52 +02:00
|
|
|
text.emptyElement(BR);
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates a reference to work, such as a book, report or web site.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenCiteTag() {
|
|
|
|
text.openElement(CITE);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates text that is the code for a program.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenCodeTag() {
|
|
|
|
text.openElement(CODE);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates end of text that is the code for a program.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseCodeTag() {
|
|
|
|
text.closeElement(CODE);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String EM = "em";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
* Appends a tag that indicates emphasis.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenEmTag() {
|
|
|
|
text.openElement(EM);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates end of emphasis.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseEmTag() {
|
|
|
|
text.closeElement(EM);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String H = "h";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
* Appends a tag that indicates a header, a title of a section of the message.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-07-05 14:19:31 +02:00
|
|
|
* @param level the level of the Header. It must be a value between 1 and 3
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param style the XHTML style of the blockquote
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenHeaderTag(int level, String style) {
|
2003-09-14 16:46:38 +02:00
|
|
|
if (level > 3 || level < 1) {
|
2014-07-05 14:19:31 +02:00
|
|
|
throw new IllegalArgumentException("Level must be between 1 and 3");
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
2014-07-05 14:19:31 +02:00
|
|
|
text.halfOpenElement(H + Integer.toString(level));
|
|
|
|
text.optAttribute(STYLE, style);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that a header section ends.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-07-05 14:19:31 +02:00
|
|
|
* @param level the level of the Header. It must be a value between 1 and 3
|
2017-12-23 20:21:19 +01:00
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseHeaderTag(int level) {
|
2003-09-14 16:46:38 +02:00
|
|
|
if (level > 3 || level < 1) {
|
2014-07-05 14:19:31 +02:00
|
|
|
throw new IllegalArgumentException("Level must be between 1 and 3");
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
2014-07-05 14:19:31 +02:00
|
|
|
text.closeElement(H + Integer.toBinaryString(level));
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String IMG = "img";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
* Appends a tag that indicates an image.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param align how text should flow around the picture
|
|
|
|
* @param alt the text to show if you don't show the picture
|
|
|
|
* @param height how tall is the picture
|
|
|
|
* @param src where to get the picture
|
|
|
|
* @param width how wide is the picture
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendImageTag(String align, String alt, String height, String src, String width) {
|
|
|
|
text.halfOpenElement(IMG);
|
|
|
|
text.optAttribute("align", align);
|
|
|
|
text.optAttribute("alt", alt);
|
|
|
|
text.optAttribute("height", height);
|
|
|
|
text.optAttribute("src", src);
|
|
|
|
text.optAttribute("width", width);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String LI = "li";
|
|
|
|
public static final String OL = "ol";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
* Appends a tag that indicates the start of a new line item within a list.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param style the style of the line item
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendLineItemTag(String style) {
|
|
|
|
text.halfOpenElement(LI);
|
|
|
|
text.optAttribute(STYLE, style);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2015-01-05 03:27:42 +01:00
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that a line item section ends.
|
|
|
|
*
|
2017-12-23 20:21:19 +01:00
|
|
|
* @return this.
|
2015-01-05 03:27:42 +01:00
|
|
|
*/
|
|
|
|
public XHTMLText appendCloseLineItemTag() {
|
|
|
|
text.closeElement(LI);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
2018-05-09 23:06:12 +02:00
|
|
|
* Appends a tag that creates an ordered list. "Ordered" means that the order of the items
|
|
|
|
* in the list is important. To show this, browsers automatically number the list.
|
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param style the style of the ordered list
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenOrderedListTag(String style) {
|
|
|
|
text.halfOpenElement(OL);
|
|
|
|
text.optAttribute(STYLE, style);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that an ordered list section ends.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseOrderedListTag() {
|
|
|
|
text.closeElement(OL);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String UL = "ul";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
2018-05-09 23:06:12 +02:00
|
|
|
* Appends a tag that creates an unordered list. The unordered part means that the items
|
2003-09-14 16:46:38 +02:00
|
|
|
* in the list are not in any particular order.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param style the style of the unordered list
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenUnorderedListTag(String style) {
|
|
|
|
text.halfOpenElement(UL);
|
|
|
|
text.optAttribute(STYLE, style);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that an unordered list section ends.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseUnorderedListTag() {
|
|
|
|
text.closeElement(UL);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String P = "p";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
2018-05-09 23:06:12 +02:00
|
|
|
* Appends a tag that indicates the start of a new paragraph. This is usually rendered
|
2003-09-14 16:46:38 +02:00
|
|
|
* with two carriage returns, producing a single blank line in between the two paragraphs.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param style the style of the paragraph
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenParagraphTag(String style) {
|
|
|
|
text.halfOpenElement(P);
|
|
|
|
text.optAttribute(STYLE, style);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-09 23:06:12 +02:00
|
|
|
* Appends a tag that indicates the end of a new paragraph. This is usually rendered
|
2003-09-14 16:46:38 +02:00
|
|
|
* with two carriage returns, producing a single blank line in between the two paragraphs.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseParagraphTag() {
|
|
|
|
text.closeElement(P);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String Q = "q";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that an inlined quote section begins.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param style the style of the inlined quote
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenInlinedQuoteTag(String style) {
|
|
|
|
text.halfOpenElement(Q);
|
|
|
|
text.optAttribute(STYLE, style);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that an inlined quote section ends.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseInlinedQuoteTag() {
|
|
|
|
text.closeElement(Q);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String SPAN = "span";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
* Appends a tag that allows to set the fonts for a span of text.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2003-09-14 16:46:38 +02:00
|
|
|
* @param style the style for a span of text
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenSpanTag(String style) {
|
|
|
|
text.halfOpenElement(SPAN);
|
|
|
|
text.optAttribute(STYLE, style);
|
2014-08-20 21:25:14 +02:00
|
|
|
text.rightAngleBracket();
|
2014-07-05 14:19:31 +02:00
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that a span section ends.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseSpanTag() {
|
|
|
|
text.closeElement(SPAN);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public static final String STRONG = "strong";
|
|
|
|
|
2003-09-14 16:46:38 +02:00
|
|
|
/**
|
|
|
|
* Appends a tag that indicates text which should be more forceful than surrounding text.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendOpenStrongTag() {
|
|
|
|
text.openElement(STRONG);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a tag that indicates that a strong section ends.
|
2017-12-23 20:21:19 +01:00
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText appendCloseStrongTag() {
|
|
|
|
text.closeElement(STRONG);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Appends a given text to the XHTMLText.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2017-12-23 20:21:19 +01:00
|
|
|
* @param textToAppend the text to append
|
|
|
|
*
|
|
|
|
* @return this.
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2014-07-05 14:19:31 +02:00
|
|
|
public XHTMLText append(String textToAppend) {
|
|
|
|
text.escape(textToAppend);
|
|
|
|
return this;
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the text of the XHTMLText.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
|
|
|
* @return the text of the XHTMLText
|
2003-09-14 16:46:38 +02:00
|
|
|
*/
|
2017-02-11 16:16:41 +01:00
|
|
|
@Override
|
2003-09-14 16:46:38 +02:00
|
|
|
public String toString() {
|
2014-07-05 14:19:31 +02:00
|
|
|
return text.toString();
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|
|
|
|
|
2014-07-05 14:19:31 +02:00
|
|
|
public XmlStringBuilder toXML() {
|
|
|
|
return text;
|
|
|
|
}
|
2003-09-14 16:46:38 +02:00
|
|
|
}
|