- All Implemented Interfaces:
ValidMediaFilter
,ValidMediaInput
,ValidMediaOutput
,Encoder
MediaWriter
, it automatically
adds the <script> tags and optionally a CDATA block.
The CDATA block is not added for JSON and LD_JSON, because JSON does not support comments (insert Captain Picard facepalm pic here). However, as the JSON format will only contain <, >, or & within quoted strings, and those characters are unicode escaped, this should not present a compatibility issue between HTML and XHTML.
- Author:
- AO Industries, Inc.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JavaScriptInXhtmlEncoder
Deprecated.static final JavaScriptInXhtmlEncoder
Deprecated.This singleton does not have any context so assumesEncodingContext.DEFAULT
.static final JavaScriptInXhtmlEncoder
Deprecated.This singleton does not have any context so assumesEncodingContext.DEFAULT
. -
Method Summary
Modifier and TypeMethodDescriptionappend
(char c, Appendable out) append
(CharSequence csq, int start, int end, Appendable out) append
(CharSequence csq, Appendable out) boolean
canSkipValidation
(MediaType outputType) Checks if validation may be skipped when the characters being written to this validator is already known to be valid with the given media type.static void
encodeJavascriptInXhtml
(char[] cbuf, int off, int len, Writer out) static void
encodeJavascriptInXhtml
(char[] cbuf, Writer out) static void
encodeJavascriptInXhtml
(char ch, Appendable out) static void
encodeJavascriptInXhtml
(CharSequence cs, int start, int end, Appendable out) static void
static void
encodeJavascriptInXhtml
(Object value, Appendable out) Gets the input type.Gets the output type.boolean
isValidatingMediaInputType
(MediaType inputType) Checks if this is validating the provided type, which allows one validator to be substituted in place of another.void
void
void
void
void
void
writePrefixTo
(Appendable out) void
writeSuffixTo
(Appendable out, boolean trim) Methods inherited from class com.aoapps.encoding.MediaEncoder
getInstance, writeSuffixTo
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.aoapps.lang.io.Encoder
isBuffered
-
Field Details
-
javascriptInXhtmlEncoder
Deprecated.This singleton does not have any context so assumesEncodingContext.DEFAULT
.Singleton instance intended for static import for application/javascript. -
jsonInXhtmlEncoder
Deprecated.This singleton does not have any context so assumesEncodingContext.DEFAULT
.Singleton instance intended for static import for application/json. -
ldJsonInXhtmlEncoder
Deprecated.This singleton does not have any context so assumesEncodingContext.DEFAULT
.Singleton instance intended for static import for application/ld+json.
-
-
Method Details
-
encodeJavascriptInXhtml
- Throws:
IOException
-
encodeJavascriptInXhtml
- Throws:
IOException
-
encodeJavascriptInXhtml
public static void encodeJavascriptInXhtml(char[] cbuf, int off, int len, Writer out) throws IOException - Throws:
IOException
-
encodeJavascriptInXhtml
- Throws:
IOException
-
encodeJavascriptInXhtml
public static void encodeJavascriptInXhtml(CharSequence cs, int start, int end, Appendable out) throws IOException - Throws:
IOException
-
encodeJavascriptInXhtml
- Throws:
IOException
-
getValidMediaInputType
Description copied from interface:ValidMediaInput
Gets the input type. -
isValidatingMediaInputType
Description copied from interface:ValidMediaInput
Checks if this is validating the provided type, which allows one validator to be substituted in place of another. This is acceptable when this validator is equal to, or more strict, than the giveninputType
.Please note that this validator only needs to block invalid characters for
inputType
. This validator does not need to let through all characters, just block the invalid. This is a one-way optimization.This is almost the inverse operation of
ValidMediaInput.isValidatingMediaInputType(com.aoapps.encoding.MediaType)
, with the exception of characters only invalid due to nested encodings.- Returns:
true
when this validator will throw exceptions on all invalid characters from the giveninputType
- See Also:
-
canSkipValidation
Description copied from interface:ValidMediaInput
Checks if validation may be skipped when the characters being written to this validator is already known to be valid with the given media type. This may be done when every valid character for the given media type is also valid within this validator.This is almost the inverse operation of
ValidMediaInput.isValidatingMediaInputType(com.aoapps.encoding.MediaType)
, with the exception of characters only invalid due to nested encodings.- Returns:
true
when all valid characters of the givenoutputType
are also valid on this validator- See Also:
-
getValidMediaOutputType
Description copied from interface:ValidMediaOutput
Gets the output type. -
writePrefixTo
Description copied from class:MediaEncoder
This default implementation validates media types in assertion but writes nothing.
- Specified by:
writePrefixTo
in interfaceEncoder
- Overrides:
writePrefixTo
in classMediaEncoder
- Throws:
IOException
-
write
- Specified by:
write
in interfaceEncoder
- Specified by:
write
in classMediaEncoder
- Throws:
IOException
-
write
- Specified by:
write
in interfaceEncoder
- Specified by:
write
in classMediaEncoder
- Throws:
IOException
-
write
- Specified by:
write
in interfaceEncoder
- Specified by:
write
in classMediaEncoder
- Throws:
IOException
-
write
- Specified by:
write
in interfaceEncoder
- Specified by:
write
in classMediaEncoder
- Throws:
IOException
-
write
- Specified by:
write
in interfaceEncoder
- Specified by:
write
in classMediaEncoder
- Throws:
IOException
-
append
- Specified by:
append
in interfaceEncoder
- Specified by:
append
in classMediaEncoder
- Throws:
IOException
-
append
- Specified by:
append
in interfaceEncoder
- Specified by:
append
in classMediaEncoder
- Throws:
IOException
-
append
public JavaScriptInXhtmlEncoder append(CharSequence csq, int start, int end, Appendable out) throws IOException - Specified by:
append
in interfaceEncoder
- Specified by:
append
in classMediaEncoder
- Throws:
IOException
-
writeSuffixTo
Description copied from class:MediaEncoder
This default implementation validates media types in assertion but writes nothing.
- Specified by:
writeSuffixTo
in interfaceEncoder
- Overrides:
writeSuffixTo
in classMediaEncoder
- Throws:
IOException
-
EncodingContext.DEFAULT
.