|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmixer.Mixer
Title: Mixer
Description: Mixer is a simple helper-class (that is easy to use) for Servlet programmers that enable a complete separation of Servlet- and HTML-code.
Copyright: GNU GPL, http://www.gnu.org/licenses/licenses.html#TOCGPL
Constructor Summary | |
Mixer(java.lang.String html)
Constructor for the Mixer object. |
Method Summary | |
void |
add(java.lang.String marker,
java.lang.String value)
Adds a marker that should be substituted by a value. |
void |
add(java.lang.String context,
java.lang.String marker,
java.lang.String value)
Adds a marker that should be substituted by a value. |
void |
addHTML(java.lang.String htmlPart,
java.lang.String context)
Adds HTML-code to a context. |
void |
clear()
Clears all entries associated with no specific context of the HTML-document. |
void |
clearAll()
Clears all enries associated with no and all HTML-document contexts Example: mixer.clearAll(); |
void |
clearContext(java.lang.String context)
Clears all entries associated with a specific context of the HTML-document. |
static java.lang.String |
getContent(java.io.File file)
Loads a HTML-file and returns the content as a string. |
static java.lang.String |
getContent(java.io.File file,
java.lang.String context)
Loads a HTML-file and returns a specific context of this HTML-file as a string. |
java.lang.String |
getMix()
Mixes the template HTML-document with the added marker-value pairs and returns the result. |
void |
remove(java.lang.String marker,
java.lang.String value)
Removes a marker-value pair associated with no specific context of the HTML-document. |
void |
remove(java.lang.String context,
java.lang.String marker,
java.lang.String value)
Removes a marker-value pair associated with a specific context of the HTML-document. |
void |
removeContext(java.lang.String context)
Removes all HTML-code from a context including the context markers. |
void |
removeHTML(java.lang.String context)
Removes all HTML-code from a context excluding the context markers. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Mixer(java.lang.String html)
Constructor for the Mixer object.
Example: Mixer mixer = new Mixer(html);
html
- The string containing the template HTML-file.Method Detail |
public void add(java.lang.String marker, java.lang.String value)
Adds a marker that should be substituted by a value. Context of replacement in the HTML-document: no specific.
Example: mixer.add("---email---", "pierre@dsv.su.se");
marker
- The marker string that will be replaced by the value string in the HTML-document.value
- The value string that will replace the marker string in the HTML-document.public void add(java.lang.String context, java.lang.String marker, java.lang.String value)
Adds a marker that should be substituted by a value. Context of replacement in the HTML-document: specific. This context can be used repeatedly and is marked in the HTML-document by two identical markers.
Example: mixer.add("---context---", "---email---", "pierre@dsv.su.se");
context
- The context string that marks a specific area in the HTML-document.marker
- The marker string that will be replaced by the value string in the HTML-document.value
- The value string that will replace the marker string in the HTML-document.public void remove(java.lang.String marker, java.lang.String value)
Removes a marker-value pair associated with no specific context of the HTML-document.
Example: mixer.remove("---email---", "pierre@dsv.su.se");
marker
- The marker string (associated with the value string parameter) that will be removed.value
- The value string (associated with the marker string parameter) that will be removed.public void remove(java.lang.String context, java.lang.String marker, java.lang.String value)
Removes a marker-value pair associated with a specific context of the HTML-document.
Example: mixer.remove("---context---", "---email---", "pierre@dsv.su.se");
context
- The context string that marks a specific area in the HTML-document.marker
- The marker string (accociated with the value string parameter) that will be removed.value
- The value string (accociated with the marker string parameter) that will be removed.public void clear()
Clears all entries associated with no specific context of the HTML-document.
Example: mixer.clear();
public void clearContext(java.lang.String context)
Clears all entries associated with a specific context of the HTML-document.
Example: mixer.clear("---context---");
context
- The context that will be cleared.public void clearAll()
Clears all enries associated with no and all HTML-document contexts
Example: mixer.clearAll();
public void removeContext(java.lang.String context)
Removes all HTML-code from a context including the context markers.
Example: mixer.removeContext("---context---");
context
- The HTML-document context that will be removed.public void addHTML(java.lang.String htmlPart, java.lang.String context)
Adds HTML-code to a context.
Example: mixer.addHTML(htmlPart, "---context---");
Note! Experimental.
htmlPart
- The string that contains the subpart HTML-code that will be included.context
- The HTML-document context where the subpart HTML-code will be inserted.public void removeHTML(java.lang.String context)
Removes all HTML-code from a context excluding the context markers.
Example: mixer.removeHTML("---context---");
Note! Experimental.
context
- The HTML-document context where the subpart HTML-code will be removed.public java.lang.String getMix()
Mixes the template HTML-document with the added marker-value pairs and returns the result.
Example: String html = mixer.getMix();
public static java.lang.String getContent(java.io.File file)
Loads a HTML-file and returns the content as a string.
Example: String html = Mixer.getContent(new File("x.html"));
Example: String html = Mixer.getContent(new File(getServletContext().getRealPath("x.html")));
file
- The template HTML-file to load.
public static java.lang.String getContent(java.io.File file, java.lang.String context)
Loads a HTML-file and returns a specific context of this HTML-file as a string.
Example: String html = Mixer.getContent(new File("x.html"), "---context---");
Example: String html = Mixer.getContent(new File(getServletContext().getRealPath("x.html")), "---context---");
file
- The template HTML-file to load.context
- The context string that marks a specific area in the HTML-document.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |