Class Utils

java.lang.Object
net.thauvin.erik.httpstatus.Utils

public final class Utils extends Object
A collection of utility methods used throughout the project. This class is not intended to be instantiated.

Provides helpers for XML escaping and safe writer output.

Since:
1.0.0
Author:
Erik C. Thauvin
  • Method Details

    • escapeXml

      public static String escapeXml(String value)
      Converts the characters <, >, &, ', and " to their corresponding XML entity codes.

      Returns the original value when null or empty. Only the predefined XML entities are escaped; all other characters are preserved as-is.

    • outWrite

      public static void outWrite(@NonNull Writer out, String value, String defaultValue, boolean xml) throws IOException
      Writes a string value to the given writer, optionally escaping XML characters. When the value is null, the provided default value is used instead. If both are null, nothing is written.

      The writer must not be null. XML escaping is performed using escapeXml(String).

      Throws:
      IOException - If an I/O error occurs while writing
      NullPointerException - If the writer is null