|
GWT 2.4.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.safehtml.shared.SafeHtmlHostedModeUtils
public class SafeHtmlHostedModeUtils
SafeHtml utilities whose implementation differs between Development and Production Mode.
This class has a super-source peer that provides the Production Mode implementation.
Field Summary | |
---|---|
static java.lang.String |
FORCE_CHECK_COMPLETE_HTML
If true, perform checks in server-side code. |
Constructor Summary | |
---|---|
SafeHtmlHostedModeUtils()
|
Method Summary | |
---|---|
static void |
maybeCheckCompleteHtml(java.lang.String html)
Checks if the provided HTML string is complete (ends in "inner HTML" context). |
static void |
setForceCheckCompleteHtml(boolean check)
Sets a global flag that controls whether or not maybeCheckCompleteHtml(String) should perform its check in a
server-side environment. |
static void |
setForceCheckCompleteHtmlFromProperty()
Sets a global flag that controls whether or not maybeCheckCompleteHtml(String) should perform its check in a
server-side environment from the value of the "com.google.gwt.safehtml.ForceCheckCompleteHtml" property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String FORCE_CHECK_COMPLETE_HTML
Constructor Detail |
---|
public SafeHtmlHostedModeUtils()
Method Detail |
---|
public static void maybeCheckCompleteHtml(java.lang.String html)
This method parses the provided string as HTML and determines the HTML
context at the end of the string. If the context is not "inner HTML text",
an IllegalArgumentException
or AssertionError
is thrown.
For example, this check will pass for the following strings:
<foo>blah
baz<em>foo</em> <x a="b">hello
The check will fail for the following strings:
baz<em>foo</em> <x
baz<em>foo</em> <x a="b
baz<em>foo</em> <x a="b"
Note that the parser is lenient and this check will pass for HTML that is not well-formed, or contains invalid tags, as long as the parser can determine the HTML context at the end of the string.
This check is intended to assert a convention-of-use constraint of SafeHtmlBuilder.appendHtmlConstant(String)
.
Since the check is somewhat expensive, it is intended to run only in the
context of unit-tests or test environments, and not in production
environments. Hence this check will only execute under the following
conditions, and will be short-circuited otherwise:
com.google.gwt.safehtml.ForceCheckCompleteHtml
is set.setForceCheckCompleteHtml(boolean)
has
been called with a true
argument.
html
- the HTML to checkpublic static void setForceCheckCompleteHtml(boolean check)
maybeCheckCompleteHtml(String)
should perform its check in a
server-side environment.
check
- if true, perform server-side checks.public static void setForceCheckCompleteHtmlFromProperty()
maybeCheckCompleteHtml(String)
should perform its check in a
server-side environment from the value of the "com.google.gwt.safehtml.ForceCheckCompleteHtml" property.
|
GWT 2.4.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |