Class Xml.Tag

  • All Implemented Interfaces:
    org.openrewrite.Tree, Content, Xml
    Enclosing interface:
    Xml

    public static class Xml.Tag
    extends java.lang.Object
    implements Xml, Content
    • Constructor Detail

      • Tag

        public Tag()
    • Method Detail

      • build

        public static Xml.Tag build​(java.lang.String tagSource)
      • withName

        public Xml.Tag withName​(java.lang.String name)
      • withValue

        public Xml.Tag withValue​(java.lang.String value)
      • getChild

        public java.util.Optional<Xml.Tag> getChild​(java.lang.String name)
      • getChildren

        public java.util.List<Xml.Tag> getChildren​(java.lang.String name)
      • getChildren

        public java.util.List<Xml.Tag> getChildren()
      • withChildValue

        public Xml.Tag withChildValue​(java.lang.String childName,
                                      java.lang.String text)
        Locate an child tag with the given name and set its text value.
        Parameters:
        childName - The child tag to locate. This assumes there is one and only one.
        text - The text value to set.
        Returns:
        This tag.
      • getValue

        public java.util.Optional<java.lang.String> getValue()
        Returns:
        If this tag's content is only character data, consider it the value.
      • getChildValue

        public java.util.Optional<java.lang.String> getChildValue​(java.lang.String name)
        A shortcut for getChild(String) and getValue().
        Parameters:
        name - The name of the child element to look for.
        Returns:
        The character data of the first child element matching the provided name, if any.
      • getSibling

        public java.util.Optional<Xml.Tag> getSibling​(java.lang.String name,
                                                      org.openrewrite.Cursor cursor)
      • withContent

        public Xml.Tag withContent​(@Nullable
                                   @Nullable java.util.List<? extends Content> content)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object