Interface Encode

All Known Subinterfaces:
JavaScript, Json, LdJson, Mysql, Psql, Sh, Style, Text, Url, Xhtml, XhtmlAttribute
All Known Implementing Classes:
JavaScriptWriter, JsonWriter, LdJsonWriter, MediaWriter, MysqlWriter, PsqlWriter, ShWriter, StyleWriter, TextWriter, UrlWriter, WhitespaceWriter, XhtmlAttributeWriter, XhtmlWriter

@ThreadSafe public interface Encode
Encodes arbitrary nested types for safe output.
Author:
AO Industries, Inc.
  • Method Details

    • encode

      default Encode encode(MediaType contentType, char ch) throws IOException
      Encodes the given nested type with proper encoding.

      Adds prefixes and suffixes by media type, such as "…".

      Returns:
      this writer
      Throws:
      IOException
    • encode

      default Encode encode(MediaType contentType, char[] cbuf) throws IOException
      Encodes the given nested type with proper encoding.

      Adds prefixes and suffixes by media type, such as "…".

      Returns:
      this writer
      Throws:
      IOException
    • encode

      default Encode encode(MediaType contentType, char[] cbuf, int offset, int len) throws IOException
      Encodes the given nested type with proper encoding.

      Adds prefixes and suffixes by media type, such as "…".

      Returns:
      this writer
      Throws:
      IOException
    • encode

      Encode encode(MediaType contentType, CharSequence csq) throws IOException
      Encodes the given nested type with proper encoding.

      Adds prefixes and suffixes by media type, such as "…".

      If the string is translated, comments will be added giving the translation lookup id to aid in translation of server-translated values.

      Returns:
      this writer
      Throws:
      IOException
    • encode

      Encode encode(MediaType contentType, CharSequence csq, int start, int end) throws IOException
      Encodes the given nested type with proper encoding.

      Adds prefixes and suffixes by media type, such as "…".

      If the string is translated, comments will be added giving the translation lookup id to aid in translation of server-translated values.

      Returns:
      this writer
      Throws:
      IOException
    • encode

      Encode encode(MediaType contentType, Object content) throws IOException
      Encodes the given nested type with proper encoding.

      Adds prefixes and suffixes by media type, such as "…".

      If the string is translated, comments will be added giving the translation lookup id to aid in translation of server-translated values.

      Returns:
      this writer
      Throws:
      IOException
    • encode

      default <Ex extends Throwable> Encode encode(MediaType contentType, IOSupplierE<?,Ex> content) throws IOException, Ex
      Encodes the given nested type with proper encoding.

      Adds prefixes and suffixes by media type, such as "…".

      If the string is translated, comments will be added giving the translation lookup id to aid in translation of server-translated values.

      Type Parameters:
      Ex - An arbitrary exception type that may be thrown
      Returns:
      this writer
      Throws:
      IOException
      Ex
    • encode

      default <Ex extends Throwable> Encode encode(MediaType contentType, MediaWritable<Ex> content) throws IOException, Ex
      Encodes the given nested type with proper encoding.

      Adds prefixes and suffixes by media type, such as "…".

      Does not perform any translation markups.

      Type Parameters:
      Ex - An arbitrary exception type that may be thrown
      Returns:
      this writer
      Throws:
      IOException
      Ex
    • encode

      MediaWriter encode(MediaType contentType) throws IOException
      Encodes the given nested type with proper encoding. This is well suited for use in a try-with-resources block.

      Adds prefixes and suffixes by media type, such as "…".

      Does not perform any translation markups.

      Returns:
      A new writer that may be used for the given content type. This writer must be closed for completed calls to MediaEncoder.writeSuffixTo(java.lang.Appendable, boolean).

      The returned writer will be of the specific subclass of MediaWriter matching contentType (see MediaType.getMediaWriterClass(). This means MediaWriter.getValidMediaInputType() will be contentType.

      Throws:
      IOException