パッケージ org.mixer2

クラス Mixer2Engine


  • public class Mixer2Engine
    extends java.lang.Object

    mixer2 engine. The instance of this class should be a singleton because of high cost to initialize.

    作成者:
    nabedge
    • コンストラクタの詳細

      • Mixer2Engine

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

      • init

        public void init()

        initialize method. This is called automatically by constructor method.

      • loadHtmlTemplate

        public Html loadHtmlTemplate​(java.io.File file)
                              throws java.io.IOException

        load (unmarshal) a xhtml template to Html type object. Doctype declaration on template will be deleted.

        If error to parse xhtml string, returns null.

        パラメータ:
        file -
        戻り値:
        html tag object. If parse error, returns null.
        例外:
        java.io.IOException
      • loadHtmlTemplate

        public Html loadHtmlTemplate​(java.lang.String str)
        パラメータ:
        str -
        戻り値:
        html tag object. If parse error, returns null.
        関連項目:
        loadHtmlTemplate(File)
      • loadHtmlTemplate

        public Html loadHtmlTemplate​(java.lang.StringBuffer sb)
        パラメータ:
        sb -
        戻り値:
        html tag object. If parse error, returns null.
        関連項目:
        loadHtmlTemplate(File)
      • loadHtmlTemplate

        public Html loadHtmlTemplate​(java.lang.StringBuilder sb)
        パラメータ:
        sb - xhtml template string.
        戻り値:
        html tag object. If parse error, returns null.
        関連項目:
        loadHtmlTemplate(File)
      • loadHtmlTemplate

        public Html loadHtmlTemplate​(java.io.InputStream inputStream)
                              throws java.io.IOException

        load html template from input stream. inputStream will be closed at the end of this method. Doctype declaration on template will be deleted. If failed to parse error, returns null.

        パラメータ:
        inputStream -
        戻り値:
        html tag object. If parse error, returns null.
        例外:
        java.io.IOException - if inputStream is null.
      • saveToString

        public <T extends AbstractJaxb> java.lang.String saveToString​(T tag)

        marshal tag object to string and return it.

      • saveToStringWriter

        public <T extends AbstractJaxb> void saveToStringWriter​(T tag,
                                                                java.io.StringWriter writer)

        marshal tag object and write to StringWriter.

      • saveToString

        public java.lang.String saveToString​(java.util.List<java.lang.Object> list)

        marshal the inner objects of tag to string and return it.

             <-- html -->
             <div id="foo">aaa<span>bbb</span>ccc</div>
         
             // code
             List<Object> list = html.getById("foo", Div.class).getContent();
             String contents = mixer2Engine.saveToString(list);
             // "contents" has "aaa<span>bbb</span>ccc"
         
        パラメータ:
        list -
        戻り値:
      • removeDoctypeDeclaration

        public java.lang.StringBuilder removeDoctypeDeclaration​(java.lang.StringBuilder sb)

        remove doctype declaration

      • replaceNamedEntity

        public java.lang.StringBuilder replaceNamedEntity​(java.lang.StringBuilder sb)

        replace the reference of character entity reference to numeric character reference.

        パラメータ:
        sb - xhtml template
        戻り値:
        replaced xhtml template
      • fileToStringBuilder

        protected java.lang.StringBuilder fileToStringBuilder​(java.io.File file)
                                                       throws java.io.IOException
        例外:
        java.io.IOException
      • inputStreamToStringBuilder

        protected java.lang.StringBuilder inputStreamToStringBuilder​(java.io.InputStream inputStream)
                                                              throws java.io.IOException
        例外:
        java.io.IOException
      • replaceIframeEndTag

        protected java.lang.StringBuilder replaceIframeEndTag​(java.lang.StringBuilder sb)
      • unmarshal

        protected Html unmarshal​(java.lang.StringBuilder sb)
                          throws javax.xml.bind.JAXBException

        unmarshal from html string to html object.

        パラメータ:
        sb -
        戻り値:
        例外:
        javax.xml.bind.JAXBException