public class Mixer2Engine extends Object
mixer2 engine. The instance of this class should be a singleton because of high cost to initialize.
| Constructor and Description |
|---|
Mixer2Engine() |
| Modifier and Type | Method and Description |
|---|---|
Html |
checkAndLoadHtmlTemplate(File file)
This is the same as
loadHtmlTemplate(File) but if fail to
parse xhtml, throws Mixer2JAXBException. |
Html |
checkAndLoadHtmlTemplate(InputStream inputStream)
This is the same as
loadHtmlTemplate(InputStream) but if fail to
parse xhtml, throws Mixer2JAXBException. |
Html |
checkAndLoadHtmlTemplate(String str) |
Html |
checkAndLoadHtmlTemplate(StringBuffer sb) |
Html |
checkAndLoadHtmlTemplate(StringBuilder sb) |
protected StringBuilder |
fileToStringBuilder(File file) |
void |
init()
initialize method.
|
protected StringBuilder |
inputStreamToStringBuilder(InputStream inputStream) |
Html |
loadHtmlTemplate(File file)
load (unmarshal) a xhtml template to Html type object.
|
Html |
loadHtmlTemplate(InputStream inputStream)
load html template from input stream.
|
Html |
loadHtmlTemplate(String str) |
Html |
loadHtmlTemplate(StringBuffer sb) |
Html |
loadHtmlTemplate(StringBuilder sb) |
StringBuilder |
removeDoctypeDeclaration(StringBuilder sb)
remove doctype declaration
|
protected StringBuilder |
replaceIframeEndTag(StringBuilder sb) |
StringBuilder |
replaceNamedEntity(StringBuilder sb)
replace the reference of character entity reference to numeric character
reference.
|
String |
saveToString(List<Object> list)
marshal the inner objects of tag to string and return it.
|
<T extends AbstractJaxb> |
saveToString(T tag)
marshal tag object to string and return it.
|
<T extends AbstractJaxb> |
saveToStringWriter(T tag,
StringWriter writer)
marshal tag object and write to StringWriter.
|
protected Html |
unmarshal(StringBuilder sb)
unmarshal from html string to html object.
|
public void init()
initialize method. This is called automatically by constructor method.
public Html loadHtmlTemplate(File file) throws 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 - IOExceptionpublic Html checkAndLoadHtmlTemplate(File file) throws IOException, Mixer2JAXBException
This is the same as
loadHtmlTemplate(File) but if fail to
parse xhtml, throws Mixer2JAXBException.
file - IOExceptionMixer2JAXBException - if xhtml parse error.loadHtmlTemplate(File)public Html loadHtmlTemplate(String str)
str - loadHtmlTemplate(File)public Html checkAndLoadHtmlTemplate(String str) throws Mixer2JAXBException
str - Mixer2JAXBExceptioncheckAndLoadHtmlTemplate(File)public Html loadHtmlTemplate(StringBuffer sb)
sb - loadHtmlTemplate(File)public Html checkAndLoadHtmlTemplate(StringBuffer sb) throws Mixer2JAXBException
Mixer2JAXBExceptionpublic Html loadHtmlTemplate(StringBuilder sb)
sb - xhtml template string.loadHtmlTemplate(File)public Html checkAndLoadHtmlTemplate(StringBuilder sb) throws Mixer2JAXBException
sb - xhtml template string.Mixer2JAXBExceptioncheckAndLoadHtmlTemplate(File)public Html loadHtmlTemplate(InputStream inputStream) throws 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 - IOException - if inputStream is null.public Html checkAndLoadHtmlTemplate(InputStream inputStream) throws IOException, Mixer2JAXBException
loadHtmlTemplate(InputStream) but if fail to
parse xhtml, throws Mixer2JAXBException.inputStream - IOExceptionMixer2JAXBExceptionloadHtmlTemplate(InputStream)public <T extends AbstractJaxb> String saveToString(T tag)
marshal tag object to string and return it.
public <T extends AbstractJaxb> void saveToStringWriter(T tag, StringWriter writer)
marshal tag object and write to StringWriter.
public String saveToString(List<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 - public StringBuilder removeDoctypeDeclaration(StringBuilder sb)
remove doctype declaration
public StringBuilder replaceNamedEntity(StringBuilder sb)
replace the reference of character entity reference to numeric character reference.
sb - xhtml templateprotected StringBuilder fileToStringBuilder(File file) throws IOException
IOExceptionprotected StringBuilder inputStreamToStringBuilder(InputStream inputStream) throws IOException
IOExceptionprotected StringBuilder replaceIframeEndTag(StringBuilder sb)
protected Html unmarshal(StringBuilder sb) throws JAXBException
unmarshal from html string to html object.
sb - JAXBExceptionCopyright © 2021 Project Mixer2. All rights reserved.