パッケージ org.mixer2.xhtml

クラス AbstractJaxb

    • コンストラクタの概要

      コンストラクタ 
      コンストラクタ 説明
      AbstractJaxb()  
    • メソッドの概要

      すべてのメソッド インスタンス・メソッド concreteメソッド 
      修飾子とタイプ メソッド 説明
      <T extends AbstractJaxb>
      void
      addCssClass​(java.lang.String clazz)
      add class attribute.
      <T> T cast​(java.lang.Class<T> clazz)
      type cast.
      <T extends AbstractJaxb>
      T
      copy​(java.lang.Class<T> tagType)
      return deep copy of myself
      <T extends AbstractJaxb>
      T
      copyNoException​(java.lang.Class<T> tagType)
      same as copy(Class) but never throw exception.
      java.lang.String getAria​(java.lang.String key)
      return the value of area-* attribute.
      <T extends AbstractJaxb>
      T
      getById​(java.lang.String id)
      get tag that has specified id attribute.
      <T extends AbstractJaxb>
      T
      getById​(java.lang.String id, java.lang.Class<T> tagType)
      get tag that has specified id attribute.
      <T extends AbstractJaxb>
      T
      getByName​(java.lang.String name, java.lang.Class<T> tagType)
      find tag by "name" property.
      <T extends AbstractJaxb>
      java.util.List<T>
      getByNameAsList​(java.lang.String name, java.lang.Class<T> tagType)
      find tag by "name" property returning as List.
      java.util.List<java.lang.String> getCssClass()
      return class attribute as List.
      java.lang.String getData​(java.lang.String key)
      return the value of data-* attribute.
      <T extends AbstractJaxb>
      java.util.List<T>
      getDescendants​(java.lang.Class<T> tagType)
      scan descendant elements that has specified tag type and return it as List.
      <T extends AbstractJaxb>
      java.util.List<T>
      getDescendants​(java.lang.String clazz)
      scan descendant elements that has specified class attribute and return it as List
      <T extends AbstractJaxb>
      java.util.List<T>
      getDescendants​(java.lang.String clazz, java.lang.Class<T> tagType)
      scan descendant element that is specified tag type having specified class attribute and return it as List.
      Footer getFooter()
      get footer tag (the first one in this tag)
      java.util.List<Footer> getFooterAsList()
      get footer tag
      Header getHeader()
      get header tag (the first one in this tag)
      java.util.List<Header> getHeaderAsList()
      get header tag
      java.lang.String getId()
      get id attribute.
      java.util.Map<javax.xml.namespace.QName,​java.lang.String> getOtherAttributes()
      get other attribute map.
      java.lang.String getStyle()
      NOTICE: this method is dummy for make coding easy.
      java.util.TreeMap<java.lang.String,​java.lang.String> getStyleAsTreeMap()
      return style attributes as TreeMap
      <T extends AbstractJaxb>
      boolean
      hasCssClass​(java.lang.String clazz)
      return true if have specified class attribute.
      boolean insertAfterId​(java.lang.String id, java.lang.String insString)
      insert String after the element having specified id attribute
      <T extends AbstractJaxb>
      boolean
      insertAfterId​(java.lang.String id, T insObject)
      insert element after the element having specified id attribute.
      boolean insertBeforeId​(java.lang.String id, java.lang.String insString)
      insert string before the element having specified id attribute.
      <T extends AbstractJaxb>
      boolean
      insertBeforeId​(java.lang.String id, T insObject)
      insert element before the element having specified id attribute.
      boolean isSetId()
      NOTICE: this method is dummy for make coding easy.
      <T extends AbstractJaxb>
      boolean
      remove​(T target)
      delete element that has specified attribute within descendant element of oneself.
      java.lang.String removeAria​(java.lang.String key)
      remove a specified aria-* attribute.
      boolean removeById​(java.lang.String id)
      delete element that has specified id attribute within descendant element of oneself.
      <T extends AbstractJaxb>
      void
      removeCssClass​(java.lang.String clazz)
      remove specified class attribute if having it.
      java.lang.String removeData​(java.lang.String key)
      remove a specified data-* attribute.
      <T extends AbstractJaxb>
      void
      removeDescendants​(java.lang.Class<T> tagType)
      delete all descendant elements that is specified tag type.
      <T extends AbstractJaxb>
      void
      removeDescendants​(java.lang.String clazz)
      delete all descendant elements having specified class attribute
      <T extends AbstractJaxb>
      void
      removeDescendants​(java.lang.String clazz, java.lang.Class<T> tagType)
      delete all descendant elements that is specified tag type having specified class attribute.
      void removeEmptyCssClass()
      Remove class attribute if it has no value.
      void removeInner()
      remove inner content of this tag.
      <T extends AbstractJaxb>
      boolean
      replace​(T target, T replacement)
      replace element that has specified attribute within descendant element of oneself.
      <T extends AbstractJaxb>
      boolean
      replaceById​(java.lang.String id, java.lang.String replacement)
      replace element by string.
      <T extends AbstractJaxb>
      boolean
      replaceById​(java.lang.String id, T replacement)
      replace element that has specified id attribute within descendant element of oneself.
      <T extends AbstractJaxb>
      void
      replaceDescendants​(java.lang.Class<T> tagType, java.lang.String replacement)
      replace all descendant element that is specified tag type by String
      <T extends AbstractJaxb>
      void
      replaceDescendants​(java.lang.Class<T> tagType, T replacement)
      replace all descendant elements that is specified tag type.
      <T extends AbstractJaxb>
      void
      replaceDescendants​(java.lang.String clazz, java.lang.Class<T> tagType, java.lang.String replacement)
      replace all the descendant elements by String.
      <T extends AbstractJaxb>
      void
      replaceDescendants​(java.lang.String clazz, java.lang.Class<T> tagType, T replacement)
      replace all the descendant elements that is specified tag type having specified class attribute.
      <T extends AbstractJaxb>
      void
      replaceDescendants​(java.lang.String clazz, java.lang.String replacement)
      replace descendant tag with string.
      <T extends AbstractJaxb>
      void
      replaceDescendants​(java.lang.String clazz, T replacement)
      replace all descendant elements that has specified class attribute.
      void replaceInner​(java.lang.String replacement)
      Replace whole of inside the tag by replacement.
      If this tag can not have String directory (ex.
      void replaceInner​(java.util.List<? extends java.lang.Object> replacement)
      Replace whole of inside the tag by the whole elements of the list.
      If the element can not be use in this tag, There is a case that will be exclude.
      <T extends AbstractJaxb>
      void
      replaceInner​(T replacement)
      Replace whole of inside the tag by replacement.
      For various reasons, this method does NOT use deep copy of replacement.
      It is recommended to use copy(T) in method argument.
      void setAria​(java.lang.String key, java.lang.String value)
      set area-* attribute
      void setData​(java.lang.String key, java.lang.String value)
      set data-* attribute
      void setId​(java.lang.String id)
      set id attribute.
      void setStyle​(java.lang.String value)
      NOTICE: this method is dummy for make coding easy.
      <T extends AbstractJaxb>
      void
      setStyleByTreeMap​(java.util.TreeMap<java.lang.String,​java.lang.String> styleMap)
      write style attribute by TreeMap
      byte[] toByteArray()
      returns byte sequence of myself.
      java.lang.String toString()
      FOR DEBUG.
      void unsetAllId()
      remove id attribute of all descendant elements.
      void unsetAllId​(java.util.regex.Pattern pattern)
      remove id attribute that matches specified regex.
      • クラスから継承されたメソッド java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • コンストラクタの詳細

      • AbstractJaxb

        public AbstractJaxb()
    • メソッドの詳細

      • cast

        public <T> T cast​(java.lang.Class<T> clazz)

        type cast.

         // usage:
         // get a TD tag of first row, first column.
         Td td = html.getById("foo", Table.class).getTr().get(0).getThOrTd().get(0)
                 .cast(Td.class);
         
        パラメータ:
        clazz - tag type of org.mixer2.jaxb.xhtml.*
        戻り値:
      • getById

        public <T extends AbstractJaxb> T getById​(java.lang.String id,
                                                  java.lang.Class<T> tagType)
                                           throws TagTypeUnmatchException

        get tag that has specified id attribute. You don't need to cast() because you can specify the tag type.

         // sample: get a Div tag having id="foo" attribute.
         html.getById("foo", Div.class);
         
        パラメータ:
        id -
        tagType -
        戻り値:
        例外:
        TagTypeUnmatchException
      • getById

        public <T extends AbstractJaxb> T getById​(java.lang.String id)

        get tag that has specified id attribute. To use return value as ussual tag, you must cast() it.

        パラメータ:
        id -
        戻り値:
      • remove

        public <T extends AbstractJaxb> boolean remove​(T target)

        delete element that has specified attribute within descendant element of oneself. you can't delete oneself.

        パラメータ:
        target -
        戻り値:
        if success to delete, return true. if no hit, return false.
      • removeInner

        public void removeInner()

        remove inner content of this tag.

      • removeById

        public boolean removeById​(java.lang.String id)

        delete element that has specified id attribute within descendant element of oneself. you can't delete oneself.

        パラメータ:
        id -
        戻り値:
      • replace

        public <T extends AbstractJaxb> boolean replace​(T target,
                                                        T replacement)
                                                 throws TagTypeUnmatchException

        replace element that has specified attribute within descendant element of oneself. you can't replace oneself. It will be replaced by deep copy of "replacement"

        パラメータ:
        target -
        replacement -
        戻り値:
        if success to replace, return true. if no hit, return false.
        例外:
        TagTypeUnmatchException
      • replaceById

        public <T extends AbstractJaxb> boolean replaceById​(java.lang.String id,
                                                            T replacement)
                                                     throws TagTypeUnmatchException

        replace element that has specified id attribute within descendant element of oneself. you can't replace oneself. It will be replaced by deep copy of "replacement"

        パラメータ:
        id -
        replacement -
        戻り値:
        if success to replace, return true. if no hit, return false.
        例外:
        TagTypeUnmatchException
      • replaceById

        public <T extends AbstractJaxb> boolean replaceById​(java.lang.String id,
                                                            java.lang.String replacement)
                                                     throws TagTypeUnmatchException

        replace element by string. you can't replace oneself.

        パラメータ:
        id -
        replacement -
        戻り値:
        if success to replace, return true. if no hit, return false.
        例外:
        TagTypeUnmatchException
      • getDescendants

        public <T extends AbstractJaxb> java.util.List<T> getDescendants​(java.lang.String clazz,
                                                                         java.lang.Class<T> tagType)

        scan descendant element that is specified tag type having specified class attribute and return it as List.

         // usage:
         // get all div objects having "foo" class
         List<Div> divList = html.getDescendants("foo", Div.class);
         // get all Table objects having "bar" class within <div id="foo">
         List<Table> tbList = html.getById("foo", Div.class).getDescendants("bar",
                 Table.class);
         
        パラメータ:
        clazz -
        tagType -
        戻り値:
      • getDescendants

        public <T extends AbstractJaxb> java.util.List<T> getDescendants​(java.lang.Class<T> tagType)

        scan descendant elements that has specified tag type and return it as List.

         // usage:
         // get all div objects.
         html.getDescendants(Div.class);
         // get all table objects within <div id="foo">
         html.getById("foo", Div.class).getDescendants(Table.class);
         
        パラメータ:
        tagType -
        戻り値:
      • getDescendants

        public <T extends AbstractJaxb> java.util.List<T> getDescendants​(java.lang.String clazz)

        scan descendant elements that has specified class attribute and return it as List

        パラメータ:
        clazz - class attribute
        戻り値:
      • removeDescendants

        public <T extends AbstractJaxb> void removeDescendants​(java.lang.String clazz,
                                                               java.lang.Class<T> tagType)

        delete all descendant elements that is specified tag type having specified class attribute.

        パラメータ:
        clazz - class attribute
        tagType -
      • removeDescendants

        public <T extends AbstractJaxb> void removeDescendants​(java.lang.Class<T> tagType)

        delete all descendant elements that is specified tag type.

        パラメータ:
        tagType -
      • removeDescendants

        public <T extends AbstractJaxb> void removeDescendants​(java.lang.String clazz)

        delete all descendant elements having specified class attribute

        パラメータ:
        clazz - class attribute
      • replaceDescendants

        public <T extends AbstractJaxb> void replaceDescendants​(java.lang.String clazz,
                                                                java.lang.Class<T> tagType,
                                                                T replacement)
                                                         throws TagTypeUnmatchException

        replace all the descendant elements that is specified tag type having specified class attribute. this method use deep copy of "replacement"

        パラメータ:
        clazz - class attribute
        tagType -
        replacement -
        例外:
        TagTypeUnmatchException
      • replaceDescendants

        public <T extends AbstractJaxb> void replaceDescendants​(java.lang.String clazz,
                                                                java.lang.Class<T> tagType,
                                                                java.lang.String replacement)
                                                         throws TagTypeUnmatchException

        replace all the descendant elements by String. The target is specified tag type having specified class attribute.

        パラメータ:
        clazz - class attribute
        tagType -
        replacement -
        例外:
        TagTypeUnmatchException
      • replaceDescendants

        public <T extends AbstractJaxb> void replaceDescendants​(java.lang.Class<T> tagType,
                                                                T replacement)
                                                         throws TagTypeUnmatchException

        replace all descendant elements that is specified tag type. This method use deep copy of "replacement"

        パラメータ:
        tagType -
        replacement -
        例外:
        TagTypeUnmatchException
      • replaceDescendants

        public <T extends AbstractJaxb> void replaceDescendants​(java.lang.String clazz,
                                                                T replacement)
                                                         throws TagTypeUnmatchException
        replace all descendant elements that has specified class attribute. This method user deep copy of "replacement"
        パラメータ:
        clazz - class attribute
        replacement -
        例外:
        TagTypeUnmatchException
      • replaceDescendants

        public <T extends AbstractJaxb> void replaceDescendants​(java.lang.Class<T> tagType,
                                                                java.lang.String replacement)
                                                         throws TagTypeUnmatchException

        replace all descendant element that is specified tag type by String

        指定したタグ型の子孫要素を文字列で置換します。

        パラメータ:
        tagType -
        replacement -
        例外:
        TagTypeUnmatchException
      • replaceDescendants

        public <T extends AbstractJaxb> void replaceDescendants​(java.lang.String clazz,
                                                                java.lang.String replacement)
                                                         throws TagTypeUnmatchException

        replace descendant tag with string. specifying class property.

        パラメータ:
        clazz - class attribute
        replacement -
        例外:
        TagTypeUnmatchException
      • replaceInner

        public <T extends AbstractJaxb> void replaceInner​(T replacement)

        Replace whole of inside the tag by replacement.
        For various reasons, this method does NOT use deep copy of replacement.
        It is recommended to use copy(T) in method argument.

        recommended pattern.
         // div and p is instance of Div, p tag object.
         Div div = TagCreator.div();
         P p = TagCreator.p();
         p.getContent().add("foo");
         div.replaceInner(p.copy(P.class)); // *** using copy()
         p.getContent().add("bar");
         System.out.println(mixer2Engine.saveToString(div));
         // you get <div><p>foo</p></div>
         
        anti pattern. use with caution.
         // divA and divB is instance of Div tag object.
         Div div = TagCreator.div();
         P p = TagCreator.p();
         p.getContent().add("foo");
         div.replaceInner(p); // *** without copy()
         p.getContent().add("bar");
         System.out.println(mixer2Engine.saveToString(div));
         // you get <div><p>foo bar</p></div>
         
        パラメータ:
        replacement -
      • replaceInner

        public void replaceInner​(java.lang.String replacement)

        Replace whole of inside the tag by replacement.
        If this tag can not have String directory (ex. <table> tag), do nothing.

        パラメータ:
        replacement -
      • replaceInner

        public void replaceInner​(java.util.List<? extends java.lang.Object> replacement)

        Replace whole of inside the tag by the whole elements of the list.
        If the element can not be use in this tag, There is a case that will be exclude.

        パラメータ:
        replacement -
      • insertAfterId

        public <T extends AbstractJaxb> boolean insertAfterId​(java.lang.String id,
                                                              T insObject)
                                                       throws TagTypeUnmatchException

        insert element after the element having specified id attribute. This method use deep copy of "insObject"

        パラメータ:
        id - id attribute
        insObject -
        戻り値:
        true if success to insert. if no hit, return false.
        例外:
        TagTypeUnmatchException
      • insertAfterId

        public boolean insertAfterId​(java.lang.String id,
                                     java.lang.String insString)
                              throws TagTypeUnmatchException

        insert String after the element having specified id attribute

        パラメータ:
        id -
        insString -
        戻り値:
        true if success to insert. if no hit, return false.
        例外:
        TagTypeUnmatchException
      • insertBeforeId

        public <T extends AbstractJaxb> boolean insertBeforeId​(java.lang.String id,
                                                               T insObject)
                                                        throws TagTypeUnmatchException

        insert element before the element having specified id attribute. This method use deep copy of insObject

        パラメータ:
        id -
        insObject -
        戻り値:
        true if success to insert. if no hit, return false.
        例外:
        TagTypeUnmatchException
      • insertBeforeId

        public boolean insertBeforeId​(java.lang.String id,
                                      java.lang.String insString)
                               throws TagTypeUnmatchException

        insert string before the element having specified id attribute.

        パラメータ:
        id -
        insString -
        戻り値:
        true if success to insert. if no hit, return false.
        例外:
        TagTypeUnmatchException
      • setStyleByTreeMap

        public <T extends AbstractJaxb> void setStyleByTreeMap​(java.util.TreeMap<java.lang.String,​java.lang.String> styleMap)

        write style attribute by TreeMap

         // usage:
         TreeMap<String, String> styleMap = new TreeMap<String, String>();
         styleMap.put("border-color", "red");
         html.getById(Div.class, "hellomsg").setStyleByTreeMap(styleMap);
         // output:
         // <div id="hellomsg" style="border-color:red;">...</div>
         
        パラメータ:
        styleMap -
      • getStyleAsTreeMap

        public java.util.TreeMap<java.lang.String,​java.lang.String> getStyleAsTreeMap()

        return style attributes as TreeMap

        戻り値:
      • copy

        public <T extends AbstractJaxb> T copy​(java.lang.Class<T> tagType)
                                        throws TagTypeUnmatchException

        return deep copy of myself

        NOTICE: DO NOT USE clone() and copyTo() method ! They has bug. Use this copy() method instead of them.

         // usage
         Div div = html.getById(Div.class, "foo");
         Div div2 = div.copy(Div.class);
         
        パラメータ:
        tagType -
        戻り値:
        例外:
        TagTypeUnmatchException
      • copyNoException

        public <T extends AbstractJaxb> T copyNoException​(java.lang.Class<T> tagType)

        same as copy(Class) but never throw exception. return null if failed to copy.

        パラメータ:
        tagType -
        戻り値:
      • setData

        public void setData​(java.lang.String key,
                            java.lang.String value)

        set data-* attribute

         Div div = new Div();
         div.setData("foo", "bar");
         // you get <div data-foo="bar"></div>
         
        パラメータ:
        key - data-"key"
      • getData

        public java.lang.String getData​(java.lang.String key)

        return the value of data-* attribute. If not set, return null.

        パラメータ:
        key - data-"key"
        戻り値:
        null if not found attribute
      • setAria

        public void setAria​(java.lang.String key,
                            java.lang.String value)

        set area-* attribute

        パラメータ:
        key - aria-"key"
        value -
      • getAria

        public java.lang.String getAria​(java.lang.String key)

        return the value of area-* attribute. If not set, return null.

        パラメータ:
        key - aria-"key"
        戻り値:
      • removeData

        public java.lang.String removeData​(java.lang.String key)

        remove a specified data-* attribute.

        パラメータ:
        key - data-"key"
        戻り値:
        the previous value associated with key, or null if there was no mapping for key.
      • removeAria

        public java.lang.String removeAria​(java.lang.String key)

        remove a specified aria-* attribute.

        パラメータ:
        key - data-"key"
        戻り値:
        the previous value associated with key, or null if there was no mapping for key.
      • getOtherAttributes

        public java.util.Map<javax.xml.namespace.QName,​java.lang.String> getOtherAttributes()

        get other attribute map. NOTICE: this method is dummy for make coding easy. Acrually, this method is overridden by each tag class.

        戻り値:
      • getId

        public java.lang.String getId()

        get id attribute. return null if not set. NOTICE: this method is dummy for make coding easy. Acrually, this method is overridden by each tag class.

        戻り値:
      • setId

        public void setId​(java.lang.String id)

        set id attribute. NOTICE: this method is dummy for make coding easy. Acrually, this method is overridden by each tag class.

      • isSetId

        public boolean isSetId()

        NOTICE: this method is dummy for make coding easy. Acrually, this method is overridden by each tag class.

      • unsetAllId

        public void unsetAllId()

        remove id attribute of all descendant elements. Also, remove id attribute of myself.

      • unsetAllId

        public void unsetAllId​(java.util.regex.Pattern pattern)

        remove id attribute that matches specified regex. Also, matches and remove of myself.

      • getStyle

        public java.lang.String getStyle()

        NOTICE: this method is dummy for make coding easy. Acrually, this method is overridden by each tag class.

        戻り値:
      • setStyle

        public void setStyle​(java.lang.String value)

        NOTICE: this method is dummy for make coding easy. Acrually, this method is overridden by each tag class.

        パラメータ:
        value -
      • getCssClass

        public java.util.List<java.lang.String> getCssClass()

        return class attribute as List. NOTICE: this method is dummy for make coding easy. Acrually, this method is overridden by each tag class.

        戻り値:
      • hasCssClass

        public <T extends AbstractJaxb> boolean hasCssClass​(java.lang.String clazz)

        return true if have specified class attribute.

        パラメータ:
        clazz - class attribute
        戻り値:
      • addCssClass

        public <T extends AbstractJaxb> void addCssClass​(java.lang.String clazz)

        add class attribute. If already set, do nothing.

      • removeCssClass

        public <T extends AbstractJaxb> void removeCssClass​(java.lang.String clazz)

        remove specified class attribute if having it.

      • removeEmptyCssClass

        public void removeEmptyCssClass()

        Remove class attribute if it has no value. This method prevent no-meaning class attribute like below.

         <div class="">....</div>
         
      • getByNameAsList

        public <T extends AbstractJaxb> java.util.List<T> getByNameAsList​(java.lang.String name,
                                                                          java.lang.Class<T> tagType)

        find tag by "name" property returning as List.

        型パラメータ:
        T -
        パラメータ:
        name -
        tagType -
        戻り値:
        if not found, returns empty list.
      • getByName

        public <T extends AbstractJaxb> T getByName​(java.lang.String name,
                                                    java.lang.Class<T> tagType)

        find tag by "name" property. (the first one in this tag)

        型パラメータ:
        T -
        パラメータ:
        name -
        tagType -
        戻り値:
        null if not found.
      • getHeaderAsList

        public java.util.List<Header> getHeaderAsList()

        get header tag

        戻り値:
      • getHeader

        public Header getHeader()

        get header tag (the first one in this tag)

        戻り値:
        null if not found.
      • getFooterAsList

        public java.util.List<Footer> getFooterAsList()

        get footer tag

        戻り値:
      • getFooter

        public Footer getFooter()

        get footer tag (the first one in this tag)

        戻り値:
        null if not found.
      • toByteArray

        public byte[] toByteArray()
                           throws java.io.IOException

        returns byte sequence of myself.

        戻り値:
        例外:
        java.io.IOException
      • toString

        public java.lang.String toString()

        FOR DEBUG. This method does not include the field of a null object in the returned string.

        オーバーライド:
        toString クラス内 java.lang.Object