Package net.thauvin.erik.httpstatus
Class Utils
java.lang.Object
net.thauvin.erik.httpstatus.Utils
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 Summary
Modifier and TypeMethodDescriptionstatic StringConverts the characters<,>,&,', and"to their corresponding XML entity codes.static voidWrites a string value to the given writer, optionally escaping XML characters.
-
Method Details
-
escapeXml
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 writingNullPointerException- If the writer is null
-