This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/commons-xml.git
The following commit(s) were added to refs/heads/main by this push:
new b6dd91b Javadoc XPathHardener
b6dd91b is described below
commit b6dd91b3609c2421b2f9b89ab056de277b0dbe0d
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Aug 26 13:19:05 2026 -0400
Javadoc XPathHardener
---
src/main/java/org/apache/commons/xml/XPathHardener.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/main/java/org/apache/commons/xml/XPathHardener.java
b/src/main/java/org/apache/commons/xml/XPathHardener.java
index b9d8b44..7c5c578 100644
--- a/src/main/java/org/apache/commons/xml/XPathHardener.java
+++ b/src/main/java/org/apache/commons/xml/XPathHardener.java
@@ -48,6 +48,14 @@ final class XPathHardener {
*/
private static final String FEATURE_OVERRIDE_DEFAULT_PARSER =
"jdk.xml.overrideDefaultParser";
+ /**
+ * Hardens the given factory, returning a hardened wrapper if necessary.
+ *
+ * @param factory The factory to harden.
+ * @return A new hardened factory or the original factory, hardened, if it
is a known Saxon factory.
+ * @throws HardeningException Thrown if this {@link XPathFactory} or the
{@code XPath}s it creates cannot support this feature or if {@code feature} is
+ * {@code null}.
+ */
static XPathFactory harden(final XPathFactory factory) {
if (SaxonProvider.isSaxon(factory.getClass())) {
// Saxon: only a locked-down Configuration can close its
URI-fetching functions and extension-function surface.
@@ -61,6 +69,15 @@ static XPathFactory harden(final XPathFactory factory) {
return new HardeningXPathFactory(factory);
}
+ /**
+ * Sets a feature on the given factory, throwing a {@link
HardeningException} if the implementation does not recognize it.
+ *
+ * @param factory The factory to harden.
+ * @param feature The feature to set.
+ * @param value The value to set.
+ * @throws HardeningException Thrown if this {@link XPathFactory} or the
{@code XPath}s it creates cannot support this feature or if {@code feature} is
+ * {@code null}.
+ */
private static void setFeature(final XPathFactory factory, final String
feature, final boolean value) {
try {
factory.setFeature(feature, value);