Package com.atlassian.adf.model.node
Interface Node
-
- All Superinterfaces:
Element
- All Known Subinterfaces:
CaptionContent,ContentNode<C,N>,DocContent,ExtensionNode<N,M>,InlineContent,InternalMediaNode,LayoutColumnContent,ListItemContent,ListNode<L>,Marked<N,M>,Media,NestedExpandContent,NonNestableBlockContent,PanelContent,TableCellContent,TableCellNode<N>,TableRowContent,TaskListContent
- All Known Implementing Classes:
AbstractContentNode,AbstractListNode,AbstractMarkedContentNode,AbstractMarkedNode,AbstractNode,AbstractTableCellNode,BlockCard,Blockquote,BodiedExtension,BulletList,Caption,CodeBlock,Date,DecisionItem,DecisionList,Doc,EmbedCard,Emoji,Expand,Extension,HardBreak,Heading,InlineCard,InlineExtension,LayoutColumn,LayoutSection,ListItem,Media.AbstractMedia,Media.ExternalMedia,Media.FileMedia,Media.FileOrLinkMedia,Media.LinkMedia,MediaGroup,MediaInline,MediaSingle,Mention,NestedExpand,OrderedList,Panel,Paragraph,Placeholder,Rule,Status,Table,TableCell,TableHeader,TableRow,TaskItem,TaskList,Text,UnsupportedNode
public interface Node extends Element
A node in the Atlassian Document Format describes an element to be rendered as rich content. In the JSON transport format, each node is represented as an object with a mandatorytypeproperty that identifies what kind of node it represents.WARNING: Some node types are not supported on mobile. Consider your audience when building content in an automated fashion and whether you have provided enough information for those environments where, for example, tables may not be rendered.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceNode.AttrConstants used as theattributenames in nodes.static interfaceNode.KeyConstants used as property names in nodes.static interfaceNode.TypeConstants used as thetypenames for the various ADF nodes.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidappendPlainText(StringBuilder sb)Renders this node as plain-text suitable for viewing by end users.Nodecopy()Returns a deep copy of this element, including copies of any nodes or marks that it contains.static <T extends Node>
Tparse(Class<T> requiredClass, Map<String,?> map)Parses a node of unknown type and without any known context for it.static Nodeparse(Map<String,?> map)Parses a node of unknown type and without any known context for it.StringtoPlainText()Renders this node as plain-text suitable for viewing by end users.-
Methods inherited from interface com.atlassian.adf.model.Element
elementType, isSupported, toMap, validate
-
-
-
-
Method Detail
-
parse
static Node parse(Map<String,?> map)
Parses a node of unknown type and without any known context for it. If the node happens to be adoc, then this is equivalent to callingDoc.parse(Map)directly. Otherwise, the ADF node is parsed as an isolated fragment with no restrictions on the type of node it may be.- Parameters:
map- the ADF content to parse.- Returns:
- the parsed node
- Throws:
AdfException- if the content cannot be parsed
-
parse
static <T extends Node> T parse(Class<T> requiredClass, Map<String,?> map)
Parses a node of unknown type and without any known context for it. If the node happens to be adocand therequiredClassis appropriate, then this is equivalent to callingDoc.parse(Map)directly. Otherwise, the ADF node is parsed as an isolated fragment with the only restriction being that the returned node must be assignable torequiredClass.- Parameters:
requiredClass- a return type to restrict the types of nodes that may be returnedmap- the ADF content to parse.- Returns:
- the parsed node
- Throws:
AdfException- if the content cannot be parsed or is not assignable torequiredClass
-
copy
Node 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.
-
toPlainText
String toPlainText()
Renders this node as plain-text suitable for viewing by end users. Note that this is distinct from the more informativetoString()value, which is meant for debugging and logging, only.
-
appendPlainText
void appendPlainText(StringBuilder sb)
Renders this node as plain-text suitable for viewing by end users. This is equivalent to callingtoPlainText()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.- Parameters:
sb- where to write the result
-
-