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 25df71d  Refactor magic strings.
25df71d is described below

commit 25df71d126c365bace2271da1fee26c62d86df39
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jun 27 19:04:45 2026 +0000

    Refactor magic strings.
---
 .../java/org/apache/commons/xml/JaxpSetters.java   | 36 ++++++++++++----------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/src/main/java/org/apache/commons/xml/JaxpSetters.java 
b/src/main/java/org/apache/commons/xml/JaxpSetters.java
index 0f5bce0..81b27f3 100644
--- a/src/main/java/org/apache/commons/xml/JaxpSetters.java
+++ b/src/main/java/org/apache/commons/xml/JaxpSetters.java
@@ -37,6 +37,10 @@
  */
 final class JaxpSetters {
 
+    private static final String KIND_PROPERTY = "property";
+    private static final String KIND_FEATURE = "feature";
+    private static final String KIND_ATTRIBUTE = "attribute";
+
     /** Action that may throw any exception; used to share a single try/catch 
around every JAXP setter. */
     @FunctionalInterface
     private interface ThrowingAction {
@@ -52,7 +56,7 @@ private static void apply(final Object factory, final String 
kind, final String
     }
 
     static void setAttribute(final DocumentBuilderFactory factory, final 
String attribute, final Object value) {
-        apply(factory, "attribute", attribute, () -> 
factory.setAttribute(attribute, value));
+        apply(factory, KIND_ATTRIBUTE, attribute, () -> 
factory.setAttribute(attribute, value));
     }
 
     /**
@@ -78,11 +82,11 @@ static void setOptionalAttribute(final 
DocumentBuilderFactory factory, final Str
     }
 
     static void setAttribute(final TransformerFactory factory, final String 
attribute, final Object value) {
-        apply(factory, "attribute", attribute, () -> 
factory.setAttribute(attribute, value));
+        apply(factory, KIND_ATTRIBUTE, attribute, () -> 
factory.setAttribute(attribute, value));
     }
 
     static void setFeature(final DocumentBuilderFactory factory, final String 
feature, final boolean value) {
-        apply(factory, "feature", feature, () -> factory.setFeature(feature, 
value));
+        apply(factory, KIND_FEATURE, feature, () -> 
factory.setFeature(feature, value));
     }
 
     static void setOptionalFeature(final DocumentBuilderFactory factory, final 
String feature, final boolean value) {
@@ -94,55 +98,55 @@ static void setOptionalFeature(final DocumentBuilderFactory 
factory, final Strin
     }
 
     static void setFeature(final SAXParserFactory factory, final String 
feature, final boolean value) {
-        apply(factory, "feature", feature, () -> factory.setFeature(feature, 
value));
+        apply(factory, KIND_FEATURE, feature, () -> 
factory.setFeature(feature, value));
     }
 
     static void setFeature(final TransformerFactory factory, final String 
feature, final boolean value) {
-        apply(factory, "feature", feature, () -> factory.setFeature(feature, 
value));
+        apply(factory, KIND_FEATURE, feature, () -> 
factory.setFeature(feature, value));
     }
 
     static void setFeature(final XPathFactory factory, final String feature, 
final boolean value) {
-        apply(factory, "feature", feature, () -> factory.setFeature(feature, 
value));
+        apply(factory, KIND_FEATURE, feature, () -> 
factory.setFeature(feature, value));
     }
 
     static void setFeature(final SchemaFactory factory, final String feature, 
final boolean value) {
-        apply(factory, "feature", feature, () -> factory.setFeature(feature, 
value));
+        apply(factory, KIND_FEATURE, feature, () -> 
factory.setFeature(feature, value));
     }
 
     static void setFeature(final Validator validator, final String feature, 
final boolean value) {
-        apply(validator, "feature", feature, () -> 
validator.setFeature(feature, value));
+        apply(validator, KIND_FEATURE, feature, () -> 
validator.setFeature(feature, value));
     }
 
     static void setFeature(final ValidatorHandler handler, final String 
feature, final boolean value) {
-        apply(handler, "feature", feature, () -> handler.setFeature(feature, 
value));
+        apply(handler, KIND_FEATURE, feature, () -> 
handler.setFeature(feature, value));
     }
 
     static void setFeature(final XMLReader reader, final String feature, final 
boolean value) {
-        apply(reader, "feature", feature, () -> reader.setFeature(feature, 
value));
+        apply(reader, KIND_FEATURE, feature, () -> reader.setFeature(feature, 
value));
     }
 
     static void setProperty(final XMLInputFactory factory, final String 
property, final Object value) {
-        apply(factory, "property", property, () -> 
factory.setProperty(property, value));
+        apply(factory, KIND_PROPERTY, property, () -> 
factory.setProperty(property, value));
     }
 
     static void setProperty(final SAXParser parser, final String property, 
final Object value) {
-        apply(parser, "property", property, () -> parser.setProperty(property, 
value));
+        apply(parser, KIND_PROPERTY, property, () -> 
parser.setProperty(property, value));
     }
 
     static void setProperty(final XMLReader reader, final String property, 
final Object value) {
-        apply(reader, "property", property, () -> reader.setProperty(property, 
value));
+        apply(reader, KIND_PROPERTY, property, () -> 
reader.setProperty(property, value));
     }
 
     static void setProperty(final SchemaFactory factory, final String 
property, final Object value) {
-        apply(factory, "property", property, () -> 
factory.setProperty(property, value));
+        apply(factory, KIND_PROPERTY, property, () -> 
factory.setProperty(property, value));
     }
 
     static void setProperty(final Validator validator, final String property, 
final Object value) {
-        apply(validator, "property", property, () -> 
validator.setProperty(property, value));
+        apply(validator, KIND_PROPERTY, property, () -> 
validator.setProperty(property, value));
     }
 
     static void setProperty(final ValidatorHandler handler, final String 
property, final Object value) {
-        apply(handler, "property", property, () -> 
handler.setProperty(property, value));
+        apply(handler, KIND_PROPERTY, property, () -> 
handler.setProperty(property, value));
     }
 
     private JaxpSetters() {

Reply via email to