Class CodeBlock

    • Method Detail

      • codeBlock

        public static CodeBlock codeBlock()
        Returns:
        a new, empty code block. At least one text node must be added for it to be valid.
      • codeBlock

        public static CodeBlock codeBlock​(String content)
        Parameters:
        content - the text to include in the code block. As a convenience, it is implicitly wrapped in a text node.
        Returns:
        a new code block with the given content
      • codeBlock

        public static CodeBlock codeBlock​(String... content)
        Parameters:
        content - the text to include in the code block. As a convenience, it is implicitly wrapped as text nodes.
        Returns:
        a new code block with the given content
      • codeBlock

        public static CodeBlock codeBlock​(Text content)
        Returns:
        a new code block with the given content
      • codeBlock

        public static CodeBlock codeBlock​(Text... content)
        Returns:
        a new code block with the given content
      • codeBlock

        public static CodeBlock codeBlock​(Iterable<? extends Text> content)
        Returns:
        a new code block with the given content
      • codeBlock

        public static CodeBlock codeBlock​(Stream<? extends Text> content)
        Returns:
        a new code block with the given content
      • copy

        public CodeBlock copy()
        Description copied from interface: Element
        Returns 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, a text node that is used inside a codeBlock will 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 this if the element is immutable. The @Immutable annotation 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 parse and toMap methods already have to be updated in these circumstances, so it makes sense to take advantage of that.
        Specified by:
        copy in interface ContentNode<CodeBlock,​Text>
        Specified by:
        copy in interface Element
        Specified by:
        copy in interface Marked<CodeBlock,​CodeBlockMark>
        Specified by:
        copy in interface Node
        Returns:
        a copy of this element, or this if the element is immutable anyway
      • content

        public CodeBlock content​(String content)
        Parameters:
        content - the text to include in the code block. As a convenience, it is implicitly wrapped in a text node.
        Returns:
        this
      • content

        public CodeBlock content​(String... content)
        Parameters:
        content - the text to include in the code block. As a convenience, it is implicitly wrapped as text nodes.
        Returns:
        this
      • language

        public Optional<String> language()
        Returns the language setting for this code block, if set.
        Returns:
        the language setting for this code block, or empty() if not set.
      • language

        public CodeBlock language​(@Nullable
                                  String language)
        Sets the language that should be used to interpret the code block's contents.
        Parameters:
        language - the language code for the table language. Unsupported values result in plain, monospace text.
        Returns:
        this
        See Also:
        Available languages
      • defaultWidth

        public CodeBlock defaultWidth()
      • elementType

        public String elementType()
        Description copied from interface: Element
        The type value that identifies this element, such as "paragraph" or "strong".
        Specified by:
        elementType in interface Element
      • toMap

        public Map<String,​?> toMap()
        Description copied from interface: Element
        Transforms this element to a map of String values to various basic object types suitable for direct rendering as JSON content.
        Specified by:
        toMap in interface Element
        Returns:
        the map representation of this ADF element