java.lang.Object
org.tquadrat.foundation.xml.builder.internal.Text
- All Implemented Interfaces:
Element
@ClassVersion(sourceVersion="$Id: Text.java 1071 2023-09-30 01:49:32Z tquadrat $")
@API(status=INTERNAL,
since="0.0.5")
public class Text
extends Object
implements Element
This class defines the plain text that is the content of an SGML element as
such an element.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: Text.java 1071 2023-09-30 01:49:32Z tquadrat $
- Since:
- 0.0.5
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.xml.builder.internal.Text"
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Function<? super CharSequence, String> The escape function.private final booleanThe flag that indicates if this text element is to be treated as a block element.private ElementThe parent element for this comment.private final CharSequenceThe text. -
Constructor Summary
ConstructorsConstructorDescriptionText(CharSequence text, Function<? super CharSequence, String> escapeFunction) Creates a newTextobject.Text(CharSequence text, Function<? super CharSequence, String> escapeFunction, boolean isBlock) Creates a newTextobject. -
Method Summary
Modifier and TypeMethodDescriptionfinal StringReturns the name of the element.Returns the parent of this element.final booleanisBlock()Returns the block flag.
This flag is used in the conversion of the element into a String; it indicates whether the element is 'inline' (like an HTML <span>) or 'block' (as an HTML <div>).final <E extends Element>
voidsetParent(E parent) Sets the parent for this element.final StringtoString()final StringtoString(int indentationLevel, boolean prettyPrint) Returns a String representation for this element instance.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.tquadrat.foundation.xml.builder.spi.Element
getAttribute, getAttributes, getChildren, getNamespaces, hasChildren
-
Field Details
-
m_EscapeFunction
The escape function. -
m_IsBlock
The flag that indicates if this text element is to be treated as a block element. This is usuallyfalse, but for predefined markup, it can betrue.- See Also:
-
m_Parent
The parent element for this comment. -
m_Text
The text.
-
-
Constructor Details
-
Text
public Text(CharSequence text, Function<? super CharSequence, String> escapeFunction, boolean isBlock) Creates a newTextobject.- Parameters:
text- The text.escapeFunction- The function that is used to escape special characters in the given text according to the target format.isBlock- The flag that indicates if this text element is to be treated as a block element. This is usuallyfalse, but for predefined markup, it can betrue.- See Also:
-
Text
Creates a newTextobject.- Parameters:
text- The text.escapeFunction- The function that is used to escape special characters in the given text according to the target format.
-
-
Method Details
-
getElementName
Returns the name of the element.- Specified by:
getElementNamein interfaceElement- Returns:
- The name of the element.
-
getParent
Returns the parent of this element. -
isBlock
Returns the block flag.
This flag is used in the conversion of the element into a String; it indicates whether the element is 'inline' (like an HTML <span>) or 'block' (as an HTML <div>). This is important only for elements where whitespace is relevant, like for HTML elements, as pretty printing will add additional whitespace around inline elements that can become visible on parsing (for HTML: on the rendered page).
XML elements for example will be always block as there whitespace is not that important.
Obviously,trueindicates a block element, whilefalsestands for an inline element.
The default istrue. -
setParent
Sets the parent for this element. -
toString
Returns a String representation for this element instance. -
toString
-
