Package com.atlassian.adf.model.node
Class Table
- java.lang.Object
-
- com.atlassian.adf.model.node.AbstractNode<C>
-
- com.atlassian.adf.model.node.AbstractContentNode<C,N>
-
- com.atlassian.adf.model.node.AbstractMarkedContentNode<Table,TableRow,TableMark>
-
- com.atlassian.adf.model.node.Table
-
- All Implemented Interfaces:
Element,Node,ContentNode<Table,TableRow>,DocContent,LayoutColumnContent,Marked<Table,TableMark>,NonNestableBlockContent
@Documentation(state=REVIEWED, date="2023-07-26") public class Table extends AbstractMarkedContentNode<Table,TableRow,TableMark> implements DocContent, LayoutColumnContent, NonNestableBlockContent
A container for the nodes that define a table.⚠️ WARNING: Tables are documented as supported on web and desktop only. Mobile rendering support for tables may be restricted or entirely unavailable.Note: The settings for numbers columns and the layout do not apply in Jira, where tables are automatically displayed across the full width of the text container.
Example
Java
table(DEFAULT) .withoutNumberColumn() .width(75.0) .localId("table-id") .tr(td(p(" Row one, cell one")),td(p("Row one, cell two")) );ADF
{ "type": "table", "attrs": { "isNumberColumnEnabled": false, "layout": "default", "width": 75.0, "localId": "table-id" }, "content": [ { "type": "tableRow", "content": [ { "type": "tableCell", "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": " Row one, cell one" } ] } ] }, { "type": "tableCell", "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": "Row one, cell two" } ] } ] } ] } ] }Result
Row one, cell one
Row one, cell two
- See Also:
- Node - table
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTable.Layout-
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 protected voidappendMarkedContentNodeFields(AbstractNode.ToStringHelper buf)voidappendPlainText(StringBuilder sb)Renders this node as plain-text suitable for viewing by end users.Class<TableRow>contentClass()ReturnsClass<N>, the class representing the type of items held by this node.Tablecopy()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".booleanisNumberColumnEnabled()TableisNumberColumnEnabled(Boolean isNumberColumnEnabled)Optional<Table.Layout>layout()Tablelayout(Table.Layout layout)Optional<String>localId()TablelocalId(String localId)Class<TableMark>markClass()Returns the type of marks that may be applied to this node.protected booleanmarkedContentNodeEquals(Table other)protected intmarkedContentNodeHashCode()static Tabletable()static Tabletable(Table.Layout layout)static Tabletable(Table.Layout layout, TableRow content)static Tabletable(Table.Layout layout, TableRow... content)static Tabletable(Table.Layout layout, Iterable<? extends TableRow> content)static Tabletable(Table.Layout layout, Stream<? extends TableRow> content)static Tabletable(TableRow content)static Tabletable(TableRow... content)static Tabletable(Iterable<? extends TableRow> content)static Tabletable(Stream<? extends TableRow> content)Map<String,?>toMap()Transforms this element to a map ofStringvalues to various basic object types suitable for direct rendering as JSON content.Tabletr(TableRowContent content)Tabletr(TableRowContent... content)Tabletr(Iterable<? extends TableRowContent> content)Tabletr(Stream<? extends TableRowContent> content)Optional<Number>width()Tablewidth(Number width)TablewithNumberColumn()TablewithoutNumberColumn()-
Methods inherited from class com.atlassian.adf.model.node.AbstractMarkedContentNode
appendContentNodeFields, contentNodeEquals, contentNodeHashCode, contentNodeValidate, createMarkHolder, mark, mark, 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
-
markClass
public Class<TableMark> markClass()
Description copied from interface:MarkedReturns the type of marks that may be applied to this node.
-
table
public static Table table()
- Returns:
- a new, empty table. At least one table row must be added to make it valid.
-
table
public static Table table(Iterable<? extends TableRow> content)
- Returns:
- a new table with the given content
-
table
public static Table table(Stream<? extends TableRow> content)
- Returns:
- a new table with the given content
-
table
public static Table table(Table.Layout layout)
- Returns:
- a new, empty table using the specified layout. At least one table row must be added to make it valid.
-
table
public static Table table(Table.Layout layout, TableRow content)
- Returns:
- a new table with the given layout and content
-
table
public static Table table(Table.Layout layout, TableRow... content)
- Returns:
- a new table with the given layout and content
-
table
public static Table table(Table.Layout layout, Iterable<? extends TableRow> content)
- Returns:
- a new table with the given layout and content
-
table
public static Table table(Table.Layout layout, Stream<? extends TableRow> content)
- Returns:
- a new table with the given layout and content
-
tr
public Table tr(TableRowContent content)
- Parameters:
content- the content to add as a single table row within the table- Returns:
this
-
tr
public Table tr(TableRowContent... content)
- Parameters:
content- the content to add as a single table row within the table- Returns:
this
-
tr
public Table tr(Iterable<? extends TableRowContent> content)
- Parameters:
content- the content to add as a single table row within the table- Returns:
this
-
tr
public Table tr(Stream<? extends TableRowContent> content)
- Parameters:
content- the content to add as a single table row within the table- Returns:
this
-
isNumberColumnEnabled
public boolean isNumberColumnEnabled()
-
withNumberColumn
public Table withNumberColumn()
-
withoutNumberColumn
public Table withoutNumberColumn()
-
layout
public Optional<Table.Layout> layout()
-
layout
public Table layout(@Nullable Table.Layout layout)
-
contentClass
public Class<TableRow> contentClass()
Description copied from interface:ContentNodeReturnsClass<N>, the class representing the type of items held by this node.- Specified by:
contentClassin interfaceContentNode<Table,TableRow>
-
copy
public Table 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.
-
elementType
public String elementType()
Description copied from interface:ElementThetypevalue that identifies this element, such as"paragraph"or"strong".- Specified by:
elementTypein interfaceElement
-
markedContentNodeEquals
protected boolean markedContentNodeEquals(Table other)
- Overrides:
markedContentNodeEqualsin classAbstractMarkedContentNode<Table,TableRow,TableMark>
-
markedContentNodeHashCode
protected int markedContentNodeHashCode()
- Overrides:
markedContentNodeHashCodein classAbstractMarkedContentNode<Table,TableRow,TableMark>
-
appendMarkedContentNodeFields
protected void appendMarkedContentNodeFields(AbstractNode.ToStringHelper buf)
- Overrides:
appendMarkedContentNodeFieldsin classAbstractMarkedContentNode<Table,TableRow,TableMark>
-
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<Table,TableRow>- Parameters:
sb- where to write the result
-
-