Package com.atlassian.adf.model.node
Class Paragraph
- java.lang.Object
-
- com.atlassian.adf.model.node.AbstractNode<C>
-
- com.atlassian.adf.model.node.AbstractContentNode<C,N>
-
- com.atlassian.adf.model.node.AbstractMarkedContentNode<Paragraph,InlineContent,ParagraphMark>
-
- com.atlassian.adf.model.node.Paragraph
-
- All Implemented Interfaces:
Element,Node,ContentNode<Paragraph,InlineContent>,DocContent,LayoutColumnContent,ListItemContent,Marked<Paragraph,ParagraphMark>,NestedExpandContent,NonNestableBlockContent,PanelContent,TableCellContent
public class Paragraph extends AbstractMarkedContentNode<Paragraph,InlineContent,ParagraphMark> implements DocContent, LayoutColumnContent, ListItemContent, NestedExpandContent, NonNestableBlockContent, PanelContent, TableCellContent
A container for a block of formatted text delineated by a carriage return. It is equivalent to an HTML<p>tag.Example
Java
p("Hello world");ADF
{ "type": "paragraph", "content": [ { "type": "text", "text": "Hello world" } ] }Result
Hello world
- See Also:
- Node - paragraph
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.atlassian.adf.model.node.AbstractNode
AbstractNode.ToStringHelper
-
-
Field Summary
-
Fields inherited from class com.atlassian.adf.model.node.AbstractMarkedContentNode
marks
-
Fields inherited from class com.atlassian.adf.model.node.AbstractContentNode
content
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Paragraphalignment(Alignment alignment)voidappendPlainText(StringBuilder sb)Renders this node as plain-text suitable for viewing by end users.Paragraphcenter()Class<InlineContent>contentClass()ReturnsClass<N>, the class representing the type of items held by this node.Paragraphcopy()Returns a deep copy of this element, including copies of any nodes or marks that it contains.StringelementType()Thetypevalue that identifies this element, such as"paragraph"or"strong".Paragraphend()Paragraphindentation(int level)Paragraphindentation(Indentation indentation)Paragraphmark(ParagraphMark mark)Adds the given mark to this marked node.Class<ParagraphMark>markClass()Returns the type of marks that may be applied to this node.static Paragraphp()static Paragraphp(InlineContent content)static Paragraphp(InlineContent... content)static Paragraphp(Iterable<? extends InlineContent> content)static Paragraphp(String content)static Paragraphp(String... content)Creates a new paragraph with the given content, all within that single paragraph.static Paragraphp(Stream<? extends InlineContent> content)static Paragraphparagraph()static Paragraphparagraph(InlineContent content)static Paragraphparagraph(InlineContent... content)static Paragraphparagraph(Iterable<? extends InlineContent> content)static Paragraphparagraph(String content)static Paragraphparagraph(String... content)static Paragraphparagraph(Stream<? extends InlineContent> content)Paragraphtext(String content)Convenience method for appending an ordinary text node to this paragraph.Paragraphtext(String... content)Convenience method for appending multiple ordinary text nodes to this paragraph.Paragraphtext(String content, TextMark mark)Convenience method for appending an text node with a single mark to this paragraph.Paragraphtext(String content, TextMark... marks)Convenience method for appending an text node with multiple marks to this paragraph.Map<String,?>toMap()Transforms this element to a map ofStringvalues to various basic object types suitable for direct rendering as JSON content.-
Methods inherited from class com.atlassian.adf.model.node.AbstractMarkedContentNode
appendContentNodeFields, appendMarkedContentNodeFields, contentNodeEquals, contentNodeHashCode, contentNodeValidate, createMarkHolder, mark, markedContentNodeEquals, markedContentNodeHashCode, markedContentNodeValidate, marks, marks, markTypes, parseMarks, unsupportedMarkFactory
-
Methods inherited from class com.atlassian.adf.model.node.AbstractContentNode
addContent, addContentIfPresent, allNodes, appendNodeFields, appendPlainTextContentJoinedWith, appendPlainTextInlineContent, clear, content, content, content, content, content, contentFieldMaps, isEmpty, nodeEquals, nodeHashCode, parseContentItem, parseContentItems, parseOptionalContent, parseRequiredContent, parseRequiredContentAllowEmpty, removeIf, replaceContent, requireNotEmpty, transformContent, transformDescendants, trim, validate, validateContentItems, validateContentNodeForAppend
-
Methods inherited from class com.atlassian.adf.model.node.AbstractNode
doubleEq, doubleHash, equals, hashCode, isSupported, mapWithType, numberEq, numberHash, self, toPlainText, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.atlassian.adf.model.node.type.ContentNode
allNodes, allNodesOfType, allNodesOfTypeAsList, clear, content, content, content, content, content, isEmpty, removeIf, replaceContent, transformContent, transformDescendants
-
Methods inherited from interface com.atlassian.adf.model.Element
isSupported, validate
-
Methods inherited from interface com.atlassian.adf.model.node.Node
toPlainText
-
-
-
-
Method Detail
-
p
public static Paragraph p()
- Returns:
- a new, empty paragraph
-
p
public static Paragraph p(String... content)
Creates a new paragraph with the given content, all within that single paragraph. This is so that a long paragraph can be nicely split over multiple lines without having to concatenate them manually. Each is assigned its ownTextnode, but they are all assigned as content within the same containing paragraph.- Returns:
- a new paragraph with the given content
-
p
public static Paragraph p(InlineContent content)
- Returns:
- a new paragraph with the given content
-
p
public static Paragraph p(InlineContent... content)
- Returns:
- a new paragraph with the given content
-
p
public static Paragraph p(Iterable<? extends InlineContent> content)
- Returns:
- a new paragraph with the given content
-
p
public static Paragraph p(Stream<? extends InlineContent> content)
- Returns:
- a new paragraph with the given content
-
paragraph
public static Paragraph paragraph(String... content)
- See Also:
p(String[])
-
paragraph
public static Paragraph paragraph(InlineContent content)
- See Also:
p(InlineContent)
-
paragraph
public static Paragraph paragraph(InlineContent... content)
- See Also:
p(InlineContent[])
-
paragraph
public static Paragraph paragraph(Iterable<? extends InlineContent> content)
- See Also:
p(Iterable)
-
paragraph
public static Paragraph paragraph(Stream<? extends InlineContent> content)
- See Also:
p(Stream)
-
text
public Paragraph text(String content)
Convenience method for appending an ordinary text node to this paragraph.This is equivalent to:
content(text(content))- Parameters:
content- the text to add as an ordinary text node- Returns:
this
-
text
public Paragraph text(String content, TextMark mark)
Convenience method for appending an text node with a single mark to this paragraph.This is equivalent to:
content(text(content) .mark(mark) );- Parameters:
content- the text to add as an ordinary text node- Returns:
this
-
text
public Paragraph text(String content, TextMark... marks)
Convenience method for appending an text node with multiple marks to this paragraph.This is equivalent to:
content(text(content, marks));- Parameters:
content- the text to add as an ordinary text node- Returns:
this
-
text
public Paragraph text(String... content)
Convenience method for appending multiple ordinary text nodes to this paragraph.This is equivalent to:
content(text(content))- Parameters:
content- the text to add as an ordinary text node- Returns:
this
-
center
public Paragraph center()
-
end
public Paragraph end()
-
indentation
public Paragraph indentation(Indentation indentation)
-
indentation
public Paragraph indentation(int level)
-
mark
public Paragraph mark(ParagraphMark mark)
Description copied from interface:MarkedAdds the given mark to this marked node.- Specified by:
markin interfaceMarked<Paragraph,ParagraphMark>- Overrides:
markin classAbstractMarkedContentNode<Paragraph,InlineContent,ParagraphMark>- Parameters:
mark- the mark to be added- Returns:
this
-
markClass
public Class<ParagraphMark> markClass()
Description copied from interface:MarkedReturns the type of marks that may be applied to this node.- Specified by:
markClassin interfaceMarked<Paragraph,ParagraphMark>- Specified by:
markClassin classAbstractMarkedContentNode<Paragraph,InlineContent,ParagraphMark>- Returns:
- the type of marks that may be applied to this node, which is the concrete type for the generic
type
<M>on this interface.
-
contentClass
public Class<InlineContent> contentClass()
Description copied from interface:ContentNodeReturnsClass<N>, the class representing the type of items held by this node.- Specified by:
contentClassin interfaceContentNode<Paragraph,InlineContent>
-
copy
public Paragraph copy()
Description copied from interface:ElementReturns a deep copy of this element, including copies of any nodes or marks that it contains. The copy will not necessarily be in exactly the same state as the original in some cases. For example, atextnode that is used inside acodeBlockwill have the ability to use marks on it disabled, but a copy made of the text node using this method will not similarly disallow marks unless it is also added to a content node with those same restrictions.Implementations notes:
- Implementations should narrow the return type.
- Implementations should
return thisif the element is immutable. The@Immutableannotation should be used on the class to offer additional confirmation of this intent. - Implementations should
return parse(toMap())if they have state. - While there may be cases where it is worthwhile to do something more efficient than
the conversion to a map and back, this is discouraged because it would add yet another
fragile piece of code that breaks when new data is added to the node. The
parseandtoMapmethods already have to be updated in these circumstances, so it makes sense to take advantage of that.
- Specified by:
copyin interfaceContentNode<Paragraph,InlineContent>- Specified by:
copyin interfaceElement- Specified by:
copyin interfaceMarked<Paragraph,ParagraphMark>- Specified by:
copyin interfaceNode- Returns:
- a copy of this element, or
thisif the element is immutable anyway
-
elementType
public String elementType()
Description copied from interface:ElementThetypevalue that identifies this element, such as"paragraph"or"strong".- Specified by:
elementTypein interfaceElement
-
toMap
public Map<String,?> toMap()
Description copied from interface:ElementTransforms this element to a map ofStringvalues to various basic object types suitable for direct rendering as JSON content.
-
appendPlainText
public void appendPlainText(StringBuilder sb)
Description copied from interface:NodeRenders this node as plain-text suitable for viewing by end users. This is equivalent to callingNode.toPlainText()and appending the result to the given buffer, except that it may be slightly more efficient, since it will write directly to the existing buffer instead of using a temporary buffer and having to make a copy of the result.- Specified by:
appendPlainTextin interfaceNode- Overrides:
appendPlainTextin classAbstractContentNode<Paragraph,InlineContent>- Parameters:
sb- where to write the result
-
-