Package org.apache.catalina.storeconfig
Class XMLFormatPreserver
- java.lang.Object
-
- org.apache.catalina.storeconfig.XMLFormatPreserver
-
public final class XMLFormatPreserver extends java.lang.ObjectBest-effort preservation of the original layout (comments, blank lines and attribute order) ofserver.xmland context configuration files when StoreConfig rewrites them.The freshly generated XML is always the source of truth for the content. Both the previous version and the freshly generated version are parsed, the elements of both documents are matched and the freshly generated document is re-serialized using the layout of the previous version.
The preservation is best-effort. Whenever the previous version is missing, cannot be parsed, or the result cannot be verified, the freshly generated XML is returned unchanged.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringpreserve(java.io.File originalFile, java.lang.String newXml, java.lang.String encoding)Preserves the layout of the previous version of a configuration file for the freshly generated XML.static java.lang.Stringpreserve(java.lang.String originalXml, java.lang.String newXml, java.lang.String encoding)Preserves the layout of the previous version of an XML document for the freshly generated XML.
-
-
-
Method Detail
-
preserve
public static java.lang.String preserve(java.io.File originalFile, java.lang.String newXml, java.lang.String encoding)Preserves the layout of the previous version of a configuration file for the freshly generated XML.- Parameters:
originalFile- The previous version of the configuration file, may benullnewXml- The freshly generated XMLencoding- The character encoding of the configuration file- Returns:
- The freshly generated XML, re-laid-out using the previous version when possible, otherwise the freshly generated XML unchanged
-
preserve
public static java.lang.String preserve(java.lang.String originalXml, java.lang.String newXml, java.lang.String encoding)Preserves the layout of the previous version of an XML document for the freshly generated XML.- Parameters:
originalXml- The previous version of the XML document, may benullnewXml- The freshly generated XMLencoding- The character encoding used in the XML declaration of the result- Returns:
- The freshly generated XML, re-laid-out using the previous version when possible, otherwise the freshly generated XML unchanged
-
-