Class LogUtil

java.lang.Object
org.jpos.util.LogUtil

public class LogUtil extends Object
Helpers for emitting strings that may contain XML-reserved characters inside log payloads, optionally wrapping them in CDATA blocks.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Pattern
    Regex matching XML-reserved characters that force CDATA escaping.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Utility class; instances carry no state.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    dump(PrintStream p, String indent, String s)
    Writes s to p, wrapping it in <![CDATA[...]]> when the string contains XML-reserved characters.
    static boolean
    Indicates whether s contains any XML-reserved characters and therefore needs CDATA escaping when embedded in XML output.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • xmlReservedPattern

      public static final Pattern xmlReservedPattern
      Regex matching XML-reserved characters that force CDATA escaping.
  • Constructor Details

    • LogUtil

      public LogUtil()
      Utility class; instances carry no state.
  • Method Details

    • dump

      public static void dump(PrintStream p, String indent, String s)
      Writes s to p, wrapping it in <![CDATA[...]]> when the string contains XML-reserved characters.
      Parameters:
      p - destination stream
      indent - prefix used when the value is dumped on a single line
      s - value to emit
    • needsCDATA

      public static boolean needsCDATA(String s)
      Indicates whether s contains any XML-reserved characters and therefore needs CDATA escaping when embedded in XML output.
      Parameters:
      s - value to inspect
      Returns:
      true if any of &, <, or > is present