This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-configuration.git


The following commit(s) were added to refs/heads/master by this push:
     new be60ee191 Internal refactoring
be60ee191 is described below

commit be60ee191f1214487daf63cba925f3333a064aac
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Apr 15 10:05:50 2026 -0400

    Internal refactoring
---
 .../io/AbsoluteNameLocationStrategy.java           |  5 +----
 .../io/AbstractFileLocationStrategy.java           | 24 ++++++++++++++++++++++
 .../io/BasePathLocationStrategy.java               |  5 +----
 .../io/ClasspathLocationStrategy.java              |  4 +---
 .../io/CombinedLocationStrategy.java               |  5 +----
 .../configuration2/io/FileLocatorUtils.java        | 19 +++--------------
 .../io/FileSystemLocationStrategy.java             |  4 +---
 .../io/HomeDirectoryLocationStrategy.java          | 13 +++++-------
 .../io/ProvidedURLLocationStrategy.java            |  4 +---
 9 files changed, 38 insertions(+), 45 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/configuration2/io/AbsoluteNameLocationStrategy.java
 
b/src/main/java/org/apache/commons/configuration2/io/AbsoluteNameLocationStrategy.java
index 44e86e896..7a1d145b2 100644
--- 
a/src/main/java/org/apache/commons/configuration2/io/AbsoluteNameLocationStrategy.java
+++ 
b/src/main/java/org/apache/commons/configuration2/io/AbsoluteNameLocationStrategy.java
@@ -22,10 +22,8 @@ import java.net.URL;
 import org.apache.commons.lang3.StringUtils;
 
 /**
- * <p>
  * A specialized implementation of {@code FileLocationStrategy} which checks 
whether the provided file name is already
  * an absolute file name.
- * </p>
  * <p>
  * This strategy ignores the URL and the base path stored in the passed in 
{@link FileLocator}. It is only triggered by
  * absolute names in the locator's {@code fileName} component.
@@ -33,7 +31,7 @@ import org.apache.commons.lang3.StringUtils;
  *
  * @since 2.0
  */
-public class AbsoluteNameLocationStrategy implements FileLocationStrategy {
+public class AbsoluteNameLocationStrategy extends AbstractFileLocationStrategy 
{
 
     /**
      * A singleton instance of this strategy.
@@ -59,7 +57,6 @@ public class AbsoluteNameLocationStrategy implements 
FileLocationStrategy {
                 return FileLocatorUtils.convertFileToURL(file);
             }
         }
-
         return null;
     }
 }
diff --git 
a/src/main/java/org/apache/commons/configuration2/io/AbstractFileLocationStrategy.java
 
b/src/main/java/org/apache/commons/configuration2/io/AbstractFileLocationStrategy.java
new file mode 100644
index 000000000..53cbe45ba
--- /dev/null
+++ 
b/src/main/java/org/apache/commons/configuration2/io/AbstractFileLocationStrategy.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.configuration2.io;
+
+/**
+ * Abstracts services for {@link FileLocationStrategy} implementations.
+ */
+abstract class AbstractFileLocationStrategy implements FileLocationStrategy {
+
+}
diff --git 
a/src/main/java/org/apache/commons/configuration2/io/BasePathLocationStrategy.java
 
b/src/main/java/org/apache/commons/configuration2/io/BasePathLocationStrategy.java
index f0b39c90e..22edc02d3 100644
--- 
a/src/main/java/org/apache/commons/configuration2/io/BasePathLocationStrategy.java
+++ 
b/src/main/java/org/apache/commons/configuration2/io/BasePathLocationStrategy.java
@@ -22,10 +22,8 @@ import java.net.URL;
 import org.apache.commons.lang3.StringUtils;
 
 /**
- * <p>
  * A specialized implementation of {@code FileLocationStrategy} which tries to 
construct a file path from the locator's
  * base path and file name.
- * </p>
  * <p>
  * This strategies ignores the URL stored in the passed in {@link 
FileLocator}. It generates a path by concatenating the
  * base path (if present) and the file name. If the resulting path points to a 
valid file, the corresponding URL is
@@ -34,7 +32,7 @@ import org.apache.commons.lang3.StringUtils;
  *
  * @since 2.0
  */
-public class BasePathLocationStrategy implements FileLocationStrategy {
+public class BasePathLocationStrategy extends AbstractFileLocationStrategy {
 
     /**
      * A singleton instance of this strategy.
@@ -60,7 +58,6 @@ public class BasePathLocationStrategy implements 
FileLocationStrategy {
                 return FileLocatorUtils.convertFileToURL(file);
             }
         }
-
         return null;
     }
 }
diff --git 
a/src/main/java/org/apache/commons/configuration2/io/ClasspathLocationStrategy.java
 
b/src/main/java/org/apache/commons/configuration2/io/ClasspathLocationStrategy.java
index 45a672a6e..f0f588f18 100644
--- 
a/src/main/java/org/apache/commons/configuration2/io/ClasspathLocationStrategy.java
+++ 
b/src/main/java/org/apache/commons/configuration2/io/ClasspathLocationStrategy.java
@@ -21,9 +21,7 @@ import java.net.URL;
 import org.apache.commons.lang3.StringUtils;
 
 /**
- * <p>
  * A specialized {@code FileLocationStrategy} implementation which searches 
for files on the class path.
- * </p>
  * <p>
  * This strategy implementation ignores the URL and the base path components 
of the passed in {@link FileLocator}. It
  * tries to look up the file name on both the class path and the system class 
path.
@@ -31,7 +29,7 @@ import org.apache.commons.lang3.StringUtils;
  *
  * @since 2.0
  */
-public class ClasspathLocationStrategy implements FileLocationStrategy {
+public class ClasspathLocationStrategy extends AbstractFileLocationStrategy {
 
     /**
      * A singleton instance of this strategy.
diff --git 
a/src/main/java/org/apache/commons/configuration2/io/CombinedLocationStrategy.java
 
b/src/main/java/org/apache/commons/configuration2/io/CombinedLocationStrategy.java
index cdf2aafc7..8838bc835 100644
--- 
a/src/main/java/org/apache/commons/configuration2/io/CombinedLocationStrategy.java
+++ 
b/src/main/java/org/apache/commons/configuration2/io/CombinedLocationStrategy.java
@@ -22,10 +22,8 @@ import java.util.Collection;
 import java.util.Collections;
 
 /**
- * <p>
  * A specialized implementation of a {@code FileLocationStrategy} which 
encapsulates an arbitrary number of
  * {@code FileLocationStrategy} objects.
- * </p>
  * <p>
  * A collection with the wrapped {@code FileLocationStrategy} objects is 
passed at construction time. During a
  * [{@code locate()} operation the wrapped strategies are called one after the 
other until one returns a non <strong>null</strong>
@@ -42,7 +40,7 @@ import java.util.Collections;
  *
  * @since 2.0
  */
-public class CombinedLocationStrategy implements FileLocationStrategy {
+public class CombinedLocationStrategy extends AbstractFileLocationStrategy {
 
     /** A collection with all sub strategies managed by this object. */
     private final Collection<FileLocationStrategy> subStrategies;
@@ -84,7 +82,6 @@ public class CombinedLocationStrategy implements 
FileLocationStrategy {
                 return url;
             }
         }
-
         return null;
     }
 }
diff --git 
a/src/main/java/org/apache/commons/configuration2/io/FileLocatorUtils.java 
b/src/main/java/org/apache/commons/configuration2/io/FileLocatorUtils.java
index df869dd3a..46bd4a2ee 100644
--- a/src/main/java/org/apache/commons/configuration2/io/FileLocatorUtils.java
+++ b/src/main/java/org/apache/commons/configuration2/io/FileLocatorUtils.java
@@ -110,12 +110,10 @@ public final class FileLocatorUtils {
     static String appendPath(final String path, final String ext) {
         final StringBuilder fName = new StringBuilder();
         fName.append(path);
-
         // My best friend. Paranoia.
         if (!path.endsWith(File.separator)) {
             fName.append(File.separator);
         }
-
         //
         // We have a relative path, and we have
         // two possible forms here. If we have the
@@ -140,14 +138,12 @@ public final class FileLocatorUtils {
      */
     static File constructFile(final String basePath, final String fileName) {
         final File file;
-
         final File absolute = new File(fileName);
         if (StringUtils.isEmpty(basePath) || absolute.isAbsolute()) {
             file = absolute;
         } else {
             file = new File(appendPath(basePath, fileName));
         }
-
         return file;
     }
 
@@ -281,7 +277,6 @@ public final class FileLocatorUtils {
             // already fully initialized
             return locator;
         }
-
         final URL url = locate(locator);
         return url != null ? createFullyInitializedLocatorFromURL(locator, 
url) : null;
     }
@@ -296,12 +291,11 @@ public final class FileLocatorUtils {
         if (url == null) {
             return null;
         }
-
         String s = url.toString();
-        if (s.startsWith(FILE_SCHEME) && !s.startsWith("file://")) {
-            s = "file://" + s.substring(FILE_SCHEME.length());
+        final String schemeHierPrefix = FILE_SCHEME + "//";
+        if (s.startsWith(FILE_SCHEME) && !s.startsWith(schemeHierPrefix)) {
+            s = schemeHierPrefix + s.substring(FILE_SCHEME.length());
         }
-
         if (s.endsWith("/") || StringUtils.isEmpty(url.getPath())) {
             return s;
         }
@@ -325,7 +319,6 @@ public final class FileLocatorUtils {
                 LOG.debug("Loading configuration from the context classpath (" 
+ resourceName + ")");
             }
         }
-
         // attempt to load from the system classpath
         if (url == null) {
             url = ClassLoader.getSystemResource(resourceName);
@@ -364,7 +357,6 @@ public final class FileLocatorUtils {
         if (f.isAbsolute()) {
             return f;
         }
-
         // Check if URLs are involved
         URL url;
         try {
@@ -376,11 +368,9 @@ public final class FileLocatorUtils {
                 url = null;
             }
         }
-
         if (url != null) {
             return fileFromURL(url);
         }
-
         return constructFile(basePath, fileName);
     }
 
@@ -394,9 +384,7 @@ public final class FileLocatorUtils {
         if (url == null) {
             return null;
         }
-
         final String path = url.getPath();
-
         if (path.endsWith("/") || StringUtils.isEmpty(path)) {
             return null;
         }
@@ -525,7 +513,6 @@ public final class FileLocatorUtils {
         if (map == null) {
             throw new IllegalArgumentException("Map must not be null.");
         }
-
         if (locator != null) {
             map.put(PROP_BASE_PATH, locator.getBasePath());
             map.put(PROP_ENCODING, locator.getEncoding());
diff --git 
a/src/main/java/org/apache/commons/configuration2/io/FileSystemLocationStrategy.java
 
b/src/main/java/org/apache/commons/configuration2/io/FileSystemLocationStrategy.java
index 40856c3fa..09a3cb503 100644
--- 
a/src/main/java/org/apache/commons/configuration2/io/FileSystemLocationStrategy.java
+++ 
b/src/main/java/org/apache/commons/configuration2/io/FileSystemLocationStrategy.java
@@ -19,10 +19,8 @@ package org.apache.commons.configuration2.io;
 import java.net.URL;
 
 /**
- * <p>
  * A specialized implementation of {@code FileLocationStrategy} which uses the 
passed in {@link FileSystem} to locate a
  * file.
- * </p>
  * <p>
  * This strategy implementation ignores the URL of the passed in {@link 
FileLocator} and operates on its base path and
  * file name. These properties are passed to the {@code locateFromURL()} 
method of {@code FileSystem}. So the burden of
@@ -31,7 +29,7 @@ import java.net.URL;
  *
  * @since 2.0
  */
-public class FileSystemLocationStrategy implements FileLocationStrategy {
+public class FileSystemLocationStrategy extends AbstractFileLocationStrategy {
 
     /**
      * A singleton instance of this strategy.
diff --git 
a/src/main/java/org/apache/commons/configuration2/io/HomeDirectoryLocationStrategy.java
 
b/src/main/java/org/apache/commons/configuration2/io/HomeDirectoryLocationStrategy.java
index cd3d8b9e5..868357693 100644
--- 
a/src/main/java/org/apache/commons/configuration2/io/HomeDirectoryLocationStrategy.java
+++ 
b/src/main/java/org/apache/commons/configuration2/io/HomeDirectoryLocationStrategy.java
@@ -23,10 +23,8 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.SystemProperties;
 
 /**
- * <p>
  * A specialized implementation of {@code FileLocationStrategy} which searches 
for files in the user's home directory or
  * another special configurable directory.
- * </p>
  * <p>
  * This strategy implementation ignores the URL stored in the passed in {@link 
FileLocator}. It constructs a file path
  * from the configured home directory (which is the user's home directory per 
default, but can be changed to another
@@ -40,7 +38,7 @@ import org.apache.commons.lang3.SystemProperties;
  * always ignored, and only the file name is evaluated.
  * </p>
  */
-public class HomeDirectoryLocationStrategy implements FileLocationStrategy {
+public class HomeDirectoryLocationStrategy extends 
AbstractFileLocationStrategy {
 
     /**
      * Obtains the home directory to be used by a new instance. If a directory 
name is provided, it is used. Otherwise, the
@@ -49,7 +47,7 @@ public class HomeDirectoryLocationStrategy implements 
FileLocationStrategy {
      * @param homeDir the passed in home directory
      * @return the directory to be used
      */
-    private static String fetchHomeDirectory(final String homeDir) {
+    private static String getHomeDirectory(final String homeDir) {
         return homeDir != null ? homeDir : SystemProperties.getUserHome();
     }
 
@@ -84,7 +82,7 @@ public class HomeDirectoryLocationStrategy implements 
FileLocationStrategy {
      * @param withBasePath a flag whether the base path should be evaluated
      */
     public HomeDirectoryLocationStrategy(final String homeDir, final boolean 
withBasePath) {
-        homeDirectory = fetchHomeDirectory(homeDir);
+        homeDirectory = getHomeDirectory(homeDir);
         evaluateBasePath = withBasePath;
     }
 
@@ -94,7 +92,7 @@ public class HomeDirectoryLocationStrategy implements 
FileLocationStrategy {
      * @param locator the {@code FileLocator}
      * @return the base path to be used
      */
-    private String fetchBasePath(final FileLocator locator) {
+    private String getBasePath(final FileLocator locator) {
         if (isEvaluateBasePath() && 
StringUtils.isNotEmpty(locator.getBasePath())) {
             return FileLocatorUtils.appendPath(getHomeDirectory(), 
locator.getBasePath());
         }
@@ -127,13 +125,12 @@ public class HomeDirectoryLocationStrategy implements 
FileLocationStrategy {
     @Override
     public URL locate(final FileSystem fileSystem, final FileLocator locator) {
         if (StringUtils.isNotEmpty(locator.getFileName())) {
-            final String basePath = fetchBasePath(locator);
+            final String basePath = getBasePath(locator);
             final File file = FileLocatorUtils.constructFile(basePath, 
locator.getFileName());
             if (file.isFile()) {
                 return FileLocatorUtils.convertFileToURL(file);
             }
         }
-
         return null;
     }
 }
diff --git 
a/src/main/java/org/apache/commons/configuration2/io/ProvidedURLLocationStrategy.java
 
b/src/main/java/org/apache/commons/configuration2/io/ProvidedURLLocationStrategy.java
index c59e50ef9..694215c43 100644
--- 
a/src/main/java/org/apache/commons/configuration2/io/ProvidedURLLocationStrategy.java
+++ 
b/src/main/java/org/apache/commons/configuration2/io/ProvidedURLLocationStrategy.java
@@ -19,10 +19,8 @@ package org.apache.commons.configuration2.io;
 import java.net.URL;
 
 /**
- * <p>
  * A specialized implementation of {@code FileLocationStrategy} which checks 
whether a passed in {@link FileLocator}
  * already has a defined URL.
- * </p>
  * <p>
  * {@code FileLocator} objects that have a URL already reference a file in an 
unambiguous way. Therefore, this strategy
  * just returns the URL of the passed in {@code FileLocator}. It can be used 
as a first step of the file resolving
@@ -31,7 +29,7 @@ import java.net.URL;
  *
  * @since 2.0
  */
-public class ProvidedURLLocationStrategy implements FileLocationStrategy {
+public class ProvidedURLLocationStrategy extends AbstractFileLocationStrategy {
 
     /**
      * A singleton instance of this strategy.

Reply via email to