Class TagRepository

java.lang.Object
com.webfirmframework.wffweb.tag.html.AbstractHtmlRepository
com.webfirmframework.wffweb.tag.repository.TagRepository
All Implemented Interfaces:
Serializable

public class TagRepository extends AbstractHtmlRepository implements Serializable
TagRepository class for tag operations like finding tags/attributes with certain criteria, upserting/deleting wffObjects from tag etc... The object of TagRepository class may be got by BrowserPage.getTagRepository() method.
Since:
2.1.8
See Also:
  • Constructor Details

    • TagRepository

      @Deprecated public TagRepository(Object accessObject, BrowserPage browserPage, AbstractHtml... rootTags)
      Deprecated.
      since 3.0.0
      This constructor is only for internal use. To get an object of TagRepository use BrowserPage#getTagRepository() method.
      Parameters:
      browserPage - the instance of BrowserPage
      rootTags - the rootTags in the browserPage instance.
      Since:
      2.1.8
    • TagRepository

      public TagRepository(Object accessObject, BrowserPage browserPage, Map<String,AbstractHtml> tagByWffId, AbstractHtml... rootTags)
      This constructor is only for internal use. To get an object of TagRepository use BrowserPage#getTagRepository() method.
      Parameters:
      browserPage - the instance of BrowserPage
      tagByWffId - map containing wff id and its corresponding AbstractHtml.
      rootTags - the rootTags in the browserPage instance.
      Since:
      2.1.16
  • Method Details

    • findTagById

      public static AbstractHtml findTagById(String id, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the first tag matching with the given id.
      Parameters:
      id - the value of id attribute.
      fromTags - from the given tags and its nested children the finding to be done.
      Returns:
      the first found tag with the given id
      Throws:
      NullValueException - if the id or fromTags is null
      Since:
      2.1.8
    • findTagById

      public static AbstractHtml findTagById(boolean parallel, String id, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the first tag matching with the given id.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      id - the value of id attribute.
      fromTags - from the given tags and its nested children the finding to be done.
      Returns:
      the first found tag with the given id
      Throws:
      NullValueException - if the id or fromTags is null
      Since:
      3.0.0
    • findTagById

      public AbstractHtml findTagById(String id) throws NullValueException
      Finds and returns the first tag matching with the given id.
      Parameters:
      id - the value of id attribute.
      Returns:
      the first found tag with the given id
      Throws:
      NullValueException - if the id is null
      Since:
      2.1.8
    • findTagById

      public AbstractHtml findTagById(boolean parallel, String id) throws NullValueException
      Finds and returns the first tag matching with the given id.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      id - the value of id attribute.
      Returns:
      the first found tag with the given id
      Throws:
      NullValueException - if the id is null
      Since:
      3.0.0
    • findTagsByAttribute

      public static Collection<AbstractHtml> findTagsByAttribute(String attributeName, String attributeValue, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the given attribute name and value.
      Parameters:
      attributeName - the name of the attribute.
      attributeValue - the value of the attribute
      fromTags - from which the findings to be done.
      Returns:
      the collection of tags matching with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName, attributeValue or fromTags is null
      Since:
      2.1.8
    • findTagsByAttribute

      public static Collection<AbstractHtml> findTagsByAttribute(boolean parallel, String attributeName, String attributeValue, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the given attribute name and value.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      attributeName - the name of the attribute.
      attributeValue - the value of the attribute
      fromTags - from which the findings to be done.
      Returns:
      the collection of tags matching with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName, attributeValue or fromTags is null
      Since:
      3.0.0
    • findTagsByTagName

      public static Collection<AbstractHtml> findTagsByTagName(String tagName, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the give tag name.
      Parameters:
      tagName - the name of the tag.
      fromTags - from which the findings to be done.
      Returns:
      the collection of tags matching with the given tag name .
      Throws:
      NullValueException - if the tagName or fromTags is null
      Since:
      2.1.11
    • findTagsByTagName

      public static Collection<AbstractHtml> findTagsByTagName(boolean parallel, String tagName, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the give tag name.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      tagName - the name of the tag.
      fromTags - from which the findings to be done.
      Returns:
      the collection of tags matching with the given tag name .
      Throws:
      NullValueException - if the tagName or fromTags is null
      Since:
      3.0.0
    • findAttributesByTagName

      public static Collection<AbstractAttribute> findAttributesByTagName(String tagName, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of attributes (including from nested tags) of the tags matching with the give tag name.
      Parameters:
      tagName - the name of the tag.
      fromTags - from which the findings to be done.
      Returns:
      the collection of attributes of the tags matching with the given tag name.
      Throws:
      NullValueException - if the tagName or fromTags is null
      Since:
      2.1.11
    • findAttributesByAttributeFilter

      public static Collection<AbstractAttribute> findAttributesByAttributeFilter(Predicate<? super AbstractAttribute> filter, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of attributes (including from nested tags) of the tags by the given filter.
      Parameters:
      filter - the filter lambda expression containing return true to include and false to exclude.
      fromTags - from which the findings to be done.
      Returns:
      the collection of attributes of the tags by the given filter.
      Throws:
      NullValueException - if the filter or fromTags is null
      Since:
      3.0.0
    • findAttributesByAttributeFilter

      public static Collection<AbstractAttribute> findAttributesByAttributeFilter(boolean parallel, Predicate<? super AbstractAttribute> filter, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of attributes (including from nested tags) of the tags by the given filter.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      filter - the filter lambda expression containing return true to include and false to exclude.
      fromTags - from which the findings to be done.
      Returns:
      the collection of attributes of the tags by the given filter.
      Throws:
      NullValueException - if the filter or fromTags is null
      Since:
      3.0.0
    • findAttributesByTagName

      public static Collection<AbstractAttribute> findAttributesByTagName(boolean parallel, String tagName, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of attributes (including from nested tags) of the tags matching with the give tag name.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      tagName - the name of the tag.
      fromTags - from which the findings to be done.
      Returns:
      the collection of attributes of the tags matching with the given tag name.
      Throws:
      NullValueException - if the tagName or fromTags is null
      Since:
      3.0.0
    • findAttributesByTagFilter

      public static Collection<AbstractAttribute> findAttributesByTagFilter(Predicate<? super AbstractHtml> filter, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of attributes (including from nested tags) of the tags by the given filter
      Parameters:
      filter - the filter lambda expression containing return true to include and false to exclude.
      Returns:
      the collection of attributes of the tags by the given tag filter
      Throws:
      NullValueException - if the filter or fromTags is null
      Since:
      3.0.0
    • findAttributesByTagFilter

      public static Collection<AbstractAttribute> findAttributesByTagFilter(boolean parallel, Predicate<? super AbstractHtml> filter, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of attributes (including from nested tags) of the tags by the given filter
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      filter - the filter lambda expression containing return true to include and false to exclude.
      Returns:
      the collection of attributes of the tags by the given tag filter
      Throws:
      NullValueException - if the filter or fromTags is null
      Since:
      3.0.0
    • findOneTagByAttribute

      public static AbstractHtml findOneTagByAttribute(String attributeName, String attributeValue, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given attribute name and value.
      Parameters:
      attributeName - the name of the attribute.
      attributeValue - the value of the attribute
      fromTags - from which the findings to be done.
      Returns:
      the first matching tag with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName, attributeValue or fromTags is null
      Since:
      2.1.8
    • findOneTagByAttribute

      public static AbstractHtml findOneTagByAttribute(boolean parallel, String attributeName, String attributeValue, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given attribute name and value.
      Parameters:
      attributeName - the name of the attribute.
      attributeValue - the value of the attribute
      fromTags - from which the findings to be done.
      Returns:
      the first matching tag with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName, attributeValue or fromTags is null
      Since:
      3.0.0
    • findOneTagByTagName

      public static AbstractHtml findOneTagByTagName(String tagName, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given tag name.
      Parameters:
      tagName - the name of the tag.
      fromTags - from which the findings to be done.
      Returns:
      the first matching tag with the given tag name.
      Throws:
      NullValueException - if the tagName or fromTags is null
      Since:
      2.1.11
    • findOneTagByTagName

      public static AbstractHtml findOneTagByTagName(boolean parallel, String tagName, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given tag name.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      tagName - the name of the tag.
      fromTags - from which the findings to be done.
      Returns:
      the first matching tag with the given tag name.
      Throws:
      NullValueException - if the tagName or fromTags is null
      Since:
      3.0.0
    • findOneTagAssignableToTag

      public static <T extends AbstractHtml> T findOneTagAssignableToTag(Class<T> tagClass, AbstractHtml... fromTags) throws NullValueException, InvalidTagException
      Finds and returns the first matching (including from nested tags) tag (which is assignable to the given tag class).

       
       Html html = new Html(null) {{
            new Head(this) {{
                new TitleTag(this){{
                    new NoTag(this, "some title");
                }};
            }};
            new Body(this, new Id("one")) {{
                new Div(this);
            }};
        }};
      
        TitleTag titleTag = TagRepository.findOneTagAssignableToTagClass(TitleTag.class, html);
      
        System.out.println(titleTag.getTagName());
        System.out.println(titleTag.toHtmlString());
      
        //prints
      
        title
        <title>some title</title>
      
       
       
      Parameters:
      tagClass - the class of the tag.
      fromTags - from which the findings to be done.
      Returns:
      the first matching tag which is assignable to the given tag class.
      Throws:
      NullValueException - if the tagClass or fromTags is null
      InvalidTagException - if the given tag class is NoTag.class
      Since:
      2.1.11
    • findOneTagAssignableToTag

      public static <T extends AbstractHtml> T findOneTagAssignableToTag(boolean parallel, Class<T> tagClass, AbstractHtml... fromTags) throws NullValueException, InvalidTagException
      Finds and returns the first matching (including from nested tags) tag (which is assignable to the given tag class).

       
       Html html = new Html(null) {{
            new Head(this) {{
                new TitleTag(this){{
                    new NoTag(this, "some title");
                }};
            }};
            new Body(this, new Id("one")) {{
                new Div(this);
            }};
        }};
      
        TitleTag titleTag = TagRepository.findOneTagAssignableToTagClass(TitleTag.class, html);
      
        System.out.println(titleTag.getTagName());
        System.out.println(titleTag.toHtmlString());
      
        //prints
      
        title
        <title>some title</title>
      
       
       
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      tagClass - the class of the tag.
      fromTags - from which the findings to be done.
      Returns:
      the first matching tag which is assignable to the given tag class.
      Throws:
      NullValueException - if the tagClass or fromTags is null
      InvalidTagException - if the given tag class is NoTag.class
      Since:
      3.0.0
    • findTagsAssignableToTag

      public static <T extends AbstractHtml> Collection<T> findTagsAssignableToTag(Class<T> tagClass, AbstractHtml... fromTags) throws NullValueException, InvalidTagException
      Finds and returns the all matching (including from nested tags) tags (which is assignable to the given tag class).

       
       Html html = new Html(null) {{
            new Head(this) {{
                new TitleTag(this){{
                    new NoTag(this, "some title");
                }};
            }};
            new Body(this, new Id("one")) {{
                new Div(this);
                new Div(this) {{
                    new Div(this) {{
                        new Div(this);
                    }};
                }};
                new Div(this);
            }};
        }};
      
        Collection<Head> heads = TagRepository.findTagsAssignableToTag(Head.class, html);
        Collection<Div> divs = TagRepository.findTagsAssignableToTag(Div.class, html);
      
        System.out.println(heads.size());
        System.out.println(divs.size());
      
        //prints
      
        1
        5
      
       
       
      Parameters:
      tagClass - the class of the tag.
      fromTags - from which the findings to be done.
      Returns:
      the all matching tags which is assignable to the given tag class.
      Throws:
      NullValueException - if the tagClass or fromTags is null
      InvalidTagException - if the given tag class is NoTag.class
      Since:
      2.1.11
    • findTagsAssignableToTag

      public static <T extends AbstractHtml> Collection<T> findTagsAssignableToTag(boolean parallel, Class<T> tagClass, AbstractHtml... fromTags) throws NullValueException, InvalidTagException
      Finds and returns the all matching (including from nested tags) tags (which is assignable to the given tag class).

       
       Html html = new Html(null) {{
            new Head(this) {{
                new TitleTag(this){{
                    new NoTag(this, "some title");
                }};
            }};
            new Body(this, new Id("one")) {{
                new Div(this);
                new Div(this) {{
                    new Div(this) {{
                        new Div(this);
                    }};
                }};
                new Div(this);
            }};
        }};
      
        Collection<Head> heads = TagRepository.findTagsAssignableToTag(Head.class, html);
        Collection<Div> divs = TagRepository.findTagsAssignableToTag(Div.class, html);
      
        System.out.println(heads.size());
        System.out.println(divs.size());
      
        //prints
      
        1
        5
      
       
       
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      tagClass - the class of the tag.
      fromTags - from which the findings to be done.
      Returns:
      the all matching tags which is assignable to the given tag class.
      Throws:
      NullValueException - if the tagClass or fromTags is null
      InvalidTagException - if the given tag class is NoTag.class
      Since:
      3.0.0
    • findOneTagByAttributeName

      public static AbstractHtml findOneTagByAttributeName(String attributeName, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given attribute name.
      Parameters:
      attributeName - the name of the attribute.
      fromTags - from which the findings to be done.
      Returns:
      the first matching tag with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName or fromTags is null
      Since:
      2.1.8
    • findOneTagByAttributeName

      public static AbstractHtml findOneTagByAttributeName(boolean parallel, String attributeName, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given attribute name.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      attributeName - the name of the attribute.
      fromTags - from which the findings to be done.
      Returns:
      the first matching tag with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName or fromTags is null
      Since:
      3.0.0
    • findTagsByAttributeName

      public static Collection<AbstractHtml> findTagsByAttributeName(String attributeName, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the given attribute name.
      Parameters:
      attributeName - the name of the attribute.
      fromTags - from which the findings to be done.
      Returns:
      the collection of tags matching with the given attribute.
      Throws:
      NullValueException - if the attributeName or fromTags is null
      Since:
      2.1.8
    • findTagsByAttributeName

      public static Collection<AbstractHtml> findTagsByAttributeName(boolean parallel, String attributeName, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the given attribute name.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      attributeName - the name of the attribute.
      fromTags - from which the findings to be done.
      Returns:
      the collection of tags matching with the given attribute.
      Throws:
      NullValueException - if the attributeName or fromTags is null
      Since:
      3.0.0
    • findTagsByAttributeName

      public Collection<AbstractHtml> findTagsByAttributeName(String attributeName) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the given attribute name.
      Parameters:
      attributeName - the name of the attribute.
      Returns:
      the collection of tags matching with the given attribute.
      Throws:
      NullValueException - if the attributeName is null
      Since:
      2.1.8
    • findTagsByAttributeName

      public Collection<AbstractHtml> findTagsByAttributeName(boolean parallel, String attributeName) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the given attribute name.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      attributeName - the name of the attribute.
      Returns:
      the collection of tags matching with the given attribute.
      Throws:
      NullValueException - if the attributeName is null
      Since:
      3.0.0
    • findTagsByAttribute

      public Collection<AbstractHtml> findTagsByAttribute(String attributeName, String attributeValue) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the given attribute name and value.
      Parameters:
      attributeName - the name of the attribute.
      attributeValue - the value of the attribute
      Returns:
      the collection of tags matching with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName or attributeValue is null
      Since:
      2.1.8
    • findTagsByAttribute

      public Collection<AbstractHtml> findTagsByAttribute(boolean parallel, String attributeName, String attributeValue) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the given attribute name and value.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      attributeName - the name of the attribute.
      attributeValue - the value of the attribute
      Returns:
      the collection of tags matching with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName or attributeValue is null
      Since:
      3.0.0
    • findTagsByTagName

      public Collection<AbstractHtml> findTagsByTagName(String tagName) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the give tag name and value.
      Parameters:
      tagName - the name of the tag.
      Returns:
      the collection of tags matching with the given tag name and value.
      Throws:
      NullValueException - if the tagName is null
      Since:
      2.1.11
    • findTagsByTagName

      public Collection<AbstractHtml> findTagsByTagName(boolean parallel, String tagName) throws NullValueException
      Finds and returns the collection of tags (including the nested tags) matching with the give tag name and value.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      tagName - the name of the tag.
      Returns:
      the collection of tags matching with the given tag name and value.
      Throws:
      NullValueException - if the tagName is null
      Since:
      3.0.0
    • findTagsByTagFilter

      public Collection<AbstractHtml> findTagsByTagFilter(Predicate<? super AbstractHtml> filter) throws NullValueException
      Finds and returns the collection of tags (including the nested tags but excluding NoTag ) filtered by the given filter.
      Parameters:
      filter - the filter lambda expression containing return true to include and false to exclude.
      Returns:
      the collection of tags by the given filter.
      Throws:
      NullValueException - if the Predicate filter is null
      Since:
      3.0.0
    • findTagsByTagFilter

      public Collection<AbstractHtml> findTagsByTagFilter(boolean parallel, Predicate<? super AbstractHtml> filter) throws NullValueException
      Finds and returns the collection of tags (including the nested tags but excluding NoTag ) filtered by the given filter.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      filter - the filter lambda expression containing return true to include and false to exclude.
      Returns:
      the collection of tags by the given filter.
      Throws:
      NullValueException - if the Predicate filter is null
      Since:
      3.0.0
    • findTagsByTagFilter

      public static Collection<AbstractHtml> findTagsByTagFilter(boolean parallel, Predicate<? super AbstractHtml> filter, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of tags (including the nested tags and NoTag) filtered by the given filter.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      filter - the filter lambda expression containing return true to include and false to exclude.
      Returns:
      the collection of tags by the given filter.
      Throws:
      NullValueException - if the Predicate filter or fromTags is null
      Since:
      3.0.0
    • findTagsByTagFilter

      public static Collection<AbstractHtml> findTagsByTagFilter(Predicate<? super AbstractHtml> filter, AbstractHtml... fromTags) throws NullValueException
      Finds and returns the collection of tags (including the nested tags and NoTag) filtered by the given filter.
      Parameters:
      filter - the filter lambda expression containing return true to include and false to exclude.
      Returns:
      the collection of tags matching with the given tag name and value.
      Throws:
      NullValueException - if the tagName or fromTags is null
      Since:
      3.0.0
    • findAttributesByTagName

      public Collection<AbstractAttribute> findAttributesByTagName(String tagName) throws NullValueException
      Finds and returns the collection of attributes (including from nested tags) of the tags matching with the give tag name.
      Parameters:
      tagName - the name of the tag.
      Returns:
      the collection of attributes of the tags matching with the given tag name.
      Throws:
      NullValueException - if the tagName or fromTags is null
      Since:
      2.1.11
    • findAttributesByTagName

      public Collection<AbstractAttribute> findAttributesByTagName(boolean parallel, String tagName) throws NullValueException
      Finds and returns the collection of attributes (including from nested tags) of the tags matching with the give tag name.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      tagName - the name of the tag.
      Returns:
      the collection of attributes of the tags matching with the given tag name.
      Throws:
      NullValueException - if the tagName is null
      Since:
      3.0.0
    • findAttributesByAttributeFilter

      public Collection<AbstractAttribute> findAttributesByAttributeFilter(Predicate<? super AbstractAttribute> filter) throws NullValueException
      Finds and returns the collection of attributes (including from nested tags) of the tags filtered by the given filter
      Parameters:
      filter - the filter lambda expression containing return true to include and false to exclude.
      Returns:
      the collection of attributes by the given filter.
      Throws:
      NullValueException - if the tagName is null
      Since:
      3.0.0
    • findAttributesByAttributeFilter

      public Collection<AbstractAttribute> findAttributesByAttributeFilter(boolean parallel, Predicate<? super AbstractAttribute> filter) throws NullValueException
      Finds and returns the collection of attributes (including from nested tags) of the tags filtered by the given filter
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      filter - the filter lambda expression containing return true to include and false to exclude.
      Returns:
      the collection of attributes by the given filter.
      Throws:
      NullValueException - if the tagName is null
      Since:
      3.0.0
    • findOneTagByAttribute

      public AbstractHtml findOneTagByAttribute(String attributeName, String attributeValue) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given attribute name and value.
      Parameters:
      attributeName - the name of the attribute.
      attributeValue - the value of the attribute
      Returns:
      the first matching tag with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName or attributeValue is null
      Since:
      2.1.8
    • findOneTagByAttribute

      public AbstractHtml findOneTagByAttribute(boolean parallel, String attributeName, String attributeValue) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given attribute name and value.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      attributeName - the name of the attribute.
      attributeValue - the value of the attribute
      Returns:
      the first matching tag with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName or attributeValue is null
      Since:
      3.0.0
    • findOneTagByTagName

      public AbstractHtml findOneTagByTagName(String tagName) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given tag name.
      Parameters:
      tagName - the name of the tag.
      Returns:
      the first matching tag with the given tag name.
      Throws:
      NullValueException - if the tagName is null
      Since:
      2.1.11
    • findOneTagByTagName

      public AbstractHtml findOneTagByTagName(boolean parallel, String tagName) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given tag name.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      tagName - the name of the tag.
      Returns:
      the first matching tag with the given tag name.
      Throws:
      NullValueException - if the tagName is null
      Since:
      3.0.0
    • findOneTagAssignableToTag

      public <T extends AbstractHtml> T findOneTagAssignableToTag(Class<T> tagClass) throws NullValueException
      Finds and returns the first matching (including from nested tags) tag (which is assignable to the given tag class).

       
       Html html = new Html(null) {{
            new Head(this) {{
                new TitleTag(this){{
                    new NoTag(this, "some title");
                }};
            }};
            new Body(this, new Id("one")) {{
                new Div(this);
            }};
        }};
      
        TitleTag titleTag = TagRepository.findOneTagAssignableToTagClass(TitleTag.class, html);
      
        System.out.println(titleTag.getTagName());
        System.out.println(titleTag.toHtmlString());
      
        //prints
      
        title
        <title>some title</title>
      
       
       
      Parameters:
      tagClass - the class of the tag.
      Returns:
      the first matching tag which is assignable to the given tag class.
      Throws:
      NullValueException - if the tagClass is null
      Since:
      2.1.11
    • findOneTagAssignableToTag

      public <T extends AbstractHtml> T findOneTagAssignableToTag(boolean parallel, Class<T> tagClass) throws NullValueException
      Finds and returns the first matching (including from nested tags) tag (which is assignable to the given tag class).

       
       Html html = new Html(null) {{
            new Head(this) {{
                new TitleTag(this){{
                    new NoTag(this, "some title");
                }};
            }};
            new Body(this, new Id("one")) {{
                new Div(this);
            }};
        }};
      
        TitleTag titleTag = TagRepository.findOneTagAssignableToTagClass(TitleTag.class, html);
      
        System.out.println(titleTag.getTagName());
        System.out.println(titleTag.toHtmlString());
      
        //prints
      
        title
        <title>some title</title>
      
       
       
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      tagClass - the class of the tag.
      Returns:
      the first matching tag which is assignable to the given tag class.
      Throws:
      NullValueException - if the tagClass is null
      Since:
      3.0.0
    • findTagsAssignableToTag

      public <T extends AbstractHtml> Collection<T> findTagsAssignableToTag(Class<T> tagClass) throws NullValueException, InvalidTagException
      Finds and returns the all matching (including from nested tags) tags (which is assignable to the given tag class).

       
       Html html = new Html(null) {{
            new Head(this) {{
                new TitleTag(this){{
                    new NoTag(this, "some title");
                }};
            }};
            new Body(this, new Id("one")) {{
                new Div(this);
                new Div(this) {{
                    new Div(this) {{
                        new Div(this);
                    }};
                }};
                new Div(this);
            }};
        }};
      
        Collection<Head> heads = TagRepository.findTagsAssignableToTag(Head.class, html);
        Collection<Div> divs = TagRepository.findTagsAssignableToTag(Div.class, html);
      
        System.out.println(heads.size());
        System.out.println(divs.size());
      
        //prints
      
        1
        5
      
       
       
      Parameters:
      tagClass - the class of the tag.
      Returns:
      the all matching tags which is assignable to the given tag class.
      Throws:
      NullValueException - if the tagClass is null
      InvalidTagException - if the given tag class is NoTag.class
      Since:
      2.1.11
    • findTagsAssignableToTag

      public <T extends AbstractHtml> Collection<T> findTagsAssignableToTag(boolean parallel, Class<T> tagClass) throws NullValueException, InvalidTagException
      Finds and returns the all matching (including from nested tags) tags (which is assignable to the given tag class).

       
       Html html = new Html(null) {{
            new Head(this) {{
                new TitleTag(this){{
                    new NoTag(this, "some title");
                }};
            }};
            new Body(this, new Id("one")) {{
                new Div(this);
                new Div(this) {{
                    new Div(this) {{
                        new Div(this);
                    }};
                }};
                new Div(this);
            }};
        }};
      
        Collection<Head> heads = TagRepository.findTagsAssignableToTag(Head.class, html);
        Collection<Div> divs = TagRepository.findTagsAssignableToTag(Div.class, html);
      
        System.out.println(heads.size());
        System.out.println(divs.size());
      
        //prints
      
        1
        5
      
       
       
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      tagClass - the class of the tag.
      Returns:
      the all matching tags which is assignable to the given tag class.
      Throws:
      NullValueException - if the tagClass is null
      InvalidTagException - if the given tag class is NoTag.class
      Since:
      3.0.0
    • findOneTagByAttributeName

      public AbstractHtml findOneTagByAttributeName(String attributeName) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given attribute name.
      Parameters:
      attributeName - the name of the attribute.
      Returns:
      the first matching tag with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName is null
      Since:
      2.1.8
    • findOneTagByAttributeName

      public AbstractHtml findOneTagByAttributeName(boolean parallel, String attributeName) throws NullValueException
      Finds and returns the first (including the nested tags) matching with the given attribute name.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      attributeName - the name of the attribute.
      Returns:
      the first matching tag with the given attribute name and value.
      Throws:
      NullValueException - if the attributeName is null
      Since:
      3.0.0
    • findTagsByAttribute

      public Collection<AbstractHtml> findTagsByAttribute(AbstractAttribute attribute) throws NullValueException
      Finds tags by attribute instance.
      Parameters:
      attribute -
      Returns:
      all tags which are consuming the given attribute instance. It returns the only tags consuming the given attribute object which are available in browserPage.
      Throws:
      NullValueException - if the attribute is null
      Since:
      2.1.8
    • findOneTagByAttribute

      public AbstractHtml findOneTagByAttribute(AbstractAttribute attribute)
      Finds one tag by attribute instance.
      Parameters:
      attribute -
      Returns:
      the first matching tag consuming the given attribute instance. There must be a consuming tag which is available in the browserPage instance otherwise returns null.
      Throws:
      NullValueException - if the attribute is null
      Since:
      2.1.8
    • upsert

      public void upsert(AbstractHtml tag, String key, WffBMObject bmObject) throws InvalidTagException, NullValueException
      Inserts or replaces (if already exists) the key bmObject pair in the wffObjects property of tag. The conventional JavaScript object of WffBMObject will be set to the wffObjects property of the given tag at client side.
      Parameters:
      tag - the tag object on which the given bmObject to be set.
      key - key to set in wffObjects property of the tag.
      bmObject -
      Throws:
      InvalidTagException - if the given instance is of NoTag / Blank
      NullValueException - if tag, key or bmObject is null
      Since:
      2.1.8
    • upsert

      public void upsert(AbstractHtml tag, String key, WffBMArray bmArray) throws InvalidTagException, NullValueException
      Inserts or replaces (if already exists) the key bmArray pair in the wffObjects property of tag. The conventional JavaScript array of WffBMArray will be set to the wffObjects property of the given tag at client side.
      Parameters:
      tag - the tag object on which the given bmArray to be set.
      key - key to set in wffObjects property of the tag.
      bmArray -
      Throws:
      InvalidTagException - if the given instance is of NoTag / Blank
      NullValueException - if tag, key or bmArray is null
      Since:
      2.1.8
    • delete

      public void delete(AbstractHtml tag, String key) throws InvalidTagException, NullValueException
      Deletes the key-WffBMObject/WffBMArray pair from the wffObjects property of tag.
      Parameters:
      tag -
      key -
      Throws:
      InvalidTagException - if the given instance is of NoTag / Blank
      NullValueException - if tag or key is null
      Since:
      2.1.8
    • getWffBMData

      public WffBMData getWffBMData(AbstractHtml tag, String key) throws InvalidTagException, NullValueException
      gets the WffBMObject/WffBMArray from the wffObjects property of tag in the form of WffBMData.
      Parameters:
      tag -
      key -
      Returns:
      WffBMData which may be type casted to either WffBMObject or WffBMArray.
      Throws:
      InvalidTagException - if the given instance is of NoTag / Blank
      NullValueException - if tag or key is null
      Since:
      3.0.1
    • findAllTags

      public Collection<AbstractHtml> findAllTags()
      Finds all tags excluding NoTag. To get NoTag included collection use static method TagRepository.findAllTags(AbstractHtml... fromTags). This method may perform better than the static method.
      Returns:
      the collection of all tags
      Since:
      2.1.8
    • findAllTags

      public Collection<AbstractHtml> findAllTags(boolean parallel)
      Finds all tags excluding NoTag. To get NoTag included collection use static method TagRepository.findAllTags(boolean parallel, AbstractHtml... fromTags). This method may perform better than the static method.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      Returns:
      the collection of all tags
      Since:
      3.0.0
    • buildAllTagsStream

      public Stream<AbstractHtml> buildAllTagsStream(boolean parallel)
      Finds all tags excluding NoTag.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      Returns:
      the stream of all tags
      Since:
      3.0.0
    • findAllTags

      public static Collection<AbstractHtml> findAllTags(AbstractHtml... fromTags) throws NullValueException
      Finds all tags including the nested tags (and including NoTag) from the given tags.
      Parameters:
      fromTags - to find all tags from these tags
      Returns:
      all tags including the nested tags from the given tags.
      Throws:
      NullValueException - if fromTags is null
      Since:
      2.1.9
    • findAllTags

      public static Collection<AbstractHtml> findAllTags(boolean parallel, AbstractHtml... fromTags) throws NullValueException
      Finds all tags including the nested tags (and including NoTag) from the given tags.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      fromTags - to find all tags from these tags
      Returns:
      all tags including the nested tags from the given tags.
      Throws:
      NullValueException - if fromTags is null
      Since:
      3.0.0
    • findAllAttributes

      public Collection<AbstractAttribute> findAllAttributes()
      Finds all attributes from all tags.
      Returns:
      the collection of all attributes
      Since:
      2.1.8
    • findAllAttributes

      public Collection<AbstractAttribute> findAllAttributes(boolean parallel)
      Finds all attributes from all tags.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      Returns:
      the collection of all attributes
      Since:
      3.0.0
    • buildAllAttributesStream

      public Stream<AbstractAttribute> buildAllAttributesStream(boolean parallel)
      Finds all attributes as stream from all tags.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      Returns:
      the stream of all attributes
      Since:
      3.0.0
    • findAllAttributes

      public static Collection<AbstractAttribute> findAllAttributes(AbstractHtml... fromTags) throws NullValueException
      Finds all attributes from the given tags
      Parameters:
      fromTags - the tags to find the attributes from.
      Returns:
      the all attributes from the given tags including the nested tags.
      Throws:
      NullValueException - if fromTags is null
      Since:
      2.1.9
    • findAllAttributes

      public static Collection<AbstractAttribute> findAllAttributes(boolean parallel, AbstractHtml... fromTags) throws NullValueException
      Finds all attributes from the given tags
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      fromTags - the tags to find the attributes from.
      Returns:
      the all attributes from the given tags including the nested tags.
      Throws:
      NullValueException - if fromTags is null
      Since:
      3.0.0
    • exists

      public boolean exists(AbstractHtml tag) throws NullValueException, InvalidTagException
      Checks the existence of a tag instance.
      Parameters:
      tag -
      Returns:
      true if the given tag instance exists anywhere in the browser page.
      Throws:
      NullValueException - if the tag is null
      InvalidTagException - if the given tag is NoTag.
      Since:
      2.1.8
    • exists

      public boolean exists(AbstractAttribute attribute) throws NullValueException
      Checks the existence of an attribute instance.
      Parameters:
      attribute -
      Returns:
      true if the given attribute instance exists anywhere in the browser page.
      Throws:
      NullValueException - if the attribute is null
      Since:
      2.1.8
    • executeJs

      public boolean executeJs(String js)
      Executes the JavaScript at the client browser page. This method is equalent to calling
       
       try {
            browserPage.performBrowserPageAction(
                    BrowserPageAction.getActionByteBufferForExecuteJS(js));
            return true;
        } catch (final UnsupportedEncodingException e) {
            e.printStackTrace();
        }
       
       
      Eg:-
       
       tagRepository.executeJs("alert('This is an alert');");
       
       
      This shows an alert in the browser: This is an alert.
      Parameters:
      js - the JavaScript to be executed at the client browser page.
      Returns:
      true if the given js string is in a supported encoding otherwise false. Returning true DOESN'T mean the given js string is valid , successfully sent to the client browser to execute or executed successfully.
      Since:
      2.1.11
    • execute

      public void execute(BrowserPageAction pageAction)
      Performs the given BrowserPageAction. This method is equalent to calling browserPage.performBrowserPageAction(pageAction.getActionByteBuffer());.

      Eg, the below code reloads the client browser page.:-
       
       tagRepository.execute(BrowserPageAction.RELOAD);
       
       
      Parameters:
      pageAction - to perform the given BrowserPageAction
      Since:
      2.1.11
    • findBodyTag

      public Body findBodyTag()
      Finds the body tag.
      Returns:
      the body tag. If there are multiple body tags available any one of them will be returned. If no body tag found then null will be returned.
      Since:
      3.0.0
    • findBodyTag

      public Body findBodyTag(boolean parallel)
      Finds the body tag.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      Returns:
      the body tag. If there are multiple body tags available any one of them will be returned. If no body tag found then null will be returned.
      Since:
      3.0.0
    • findHeadTag

      public Head findHeadTag()
      Finds the head tag.
      Returns:
      the head tag. If there are multiple head tags available any one of them will be returned. If no head tag found then null will be returned.
      Since:
      3.0.0
    • findHeadTag

      public Head findHeadTag(boolean parallel)
      Finds the head tag.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      Returns:
      the head tag. If there are multiple head tags available any one of them will be returned. If no head tag found then null will be returned.
      Since:
      3.0.0
    • findTitleTag

      public TitleTag findTitleTag()
      Finds the title tag.
      Returns:
      the title tag. If there are multiple title tags available any one of them will be returned. If no title tag found then null will be returned.
      Since:
      3.0.0
    • findTitleTag

      public TitleTag findTitleTag(boolean parallel)
      Finds the title tag.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      Returns:
      the title tag. If there are multiple title tags available any one of them will be returned. If no title tag found then null will be returned.
      Since:
      3.0.0
    • buildAllTagsStream

      public static Stream<AbstractHtml> buildAllTagsStream(boolean parallel, AbstractHtml... fromTags)
      Builds all tags stream from the given tags and its nested children.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      fromTags - the tags to to build stream of nested children from.
      Returns:
      Stream<AbstractHtml>
      Since:
      3.0.0
    • buildAllTagsStream

      public static Stream<AbstractHtml> buildAllTagsStream(AbstractHtml... fromTags)
      Builds all tags stream from the given tags and its nested children.
      Parameters:
      fromTags - the tags to build stream of nested children from.
      Returns:
      Stream<AbstractHtml>
      Since:
      3.0.0
    • buildAllAttributesStream

      public static Stream<AbstractAttribute> buildAllAttributesStream(AbstractHtml... fromTags)
      Builds all attributes stream from the given tags.
      Parameters:
      fromTags - the tags to build stream of nested children's attributes from.
      Returns:
      Stream<AbstractAttribute>
      Since:
      3.0.0
    • buildAllAttributesStream

      public static Stream<AbstractAttribute> buildAllAttributesStream(boolean parallel, AbstractHtml... fromTags)
      Builds all attributes stream from the given tags.
      Parameters:
      parallel - true to internally use parallel stream. If true it will split the finding task to different batches and will execute the batches in different threads in parallel consuming all CPUs. It will perform faster in finding from extremely large number of tags but at the same time it will less efficient in finding from small number of tags.
      fromTags - the tags to build stream of nested children's attributes from.
      Returns:
      Stream<AbstractAttribute>
      Since:
      3.0.0
    • buildAllAttributesStream

      public Stream<AbstractAttribute> buildAllAttributesStream()
      Builds all attributes stream from all tags.
      Returns:
      Stream<AbstractAttribute>
      Since:
      3.0.0
    • findFirstParentTagAssignableToTag

      public static <T extends AbstractHtml> T findFirstParentTagAssignableToTag(Class<T> tagClass, AbstractHtml fromTag) throws NullValueException, InvalidTagException
      Finds and returns the first matching parent tag (including nested parent) (which is assignable to the given tag class).
      Parameters:
      tagClass - the class of the tag.
      fromTag - from which the findings to be done.
      Returns:
      the first matching tag which is assignable to the given tag class or null if not found.
      Throws:
      NullValueException - if the tagClass or fromTags is null
      InvalidTagException - if the given tag class is NoTag.class
      Since:
      3.0.15