This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new 9897ae6d57 Code clean-up - formatting. No functional change.
9897ae6d57 is described below
commit 9897ae6d579e167f0b3bc11c2731206fa7d89971
Author: Mark Thomas <[email protected]>
AuthorDate: Thu May 22 17:14:38 2025 +0100
Code clean-up - formatting. No functional change.
---
.../apache/tomcat/util/file/ConfigFileLoader.java | 14 ++--
.../tomcat/util/file/ConfigurationSource.java | 53 +++++++++------
java/org/apache/tomcat/util/file/Matcher.java | 75 +++++++++-------------
3 files changed, 68 insertions(+), 74 deletions(-)
diff --git a/java/org/apache/tomcat/util/file/ConfigFileLoader.java
b/java/org/apache/tomcat/util/file/ConfigFileLoader.java
index a7f6a79cd9..b48318ac07 100644
--- a/java/org/apache/tomcat/util/file/ConfigFileLoader.java
+++ b/java/org/apache/tomcat/util/file/ConfigFileLoader.java
@@ -20,17 +20,17 @@ package org.apache.tomcat.util.file;
import java.io.InputStream;
/**
- * This class is used to obtain {@link InputStream}s for configuration files
- * from a given location String. This allows greater flexibility than these
- * files having to be loaded directly from a file system.
+ * This class is used to obtain {@link InputStream}s for configuration files
from a given location String. This allows
+ * greater flexibility than these files having to be loaded directly from a
file system.
*/
public class ConfigFileLoader {
private static ConfigurationSource source;
/**
- * Get the configured configuration source. If none has been configured,
- * a default source based on the calling directory will be used.
+ * Get the configured configuration source. If none has been configured, a
default source based on the calling
+ * directory will be used.
+ *
* @return the configuration source in use
*/
public static ConfigurationSource getSource() {
@@ -41,8 +41,8 @@ public class ConfigFileLoader {
}
/**
- * Set the configuration source used by Tomcat to locate various
- * configuration resources.
+ * Set the configuration source used by Tomcat to locate various
configuration resources.
+ *
* @param source The source
*/
public static void setSource(ConfigurationSource source) {
diff --git a/java/org/apache/tomcat/util/file/ConfigurationSource.java
b/java/org/apache/tomcat/util/file/ConfigurationSource.java
index b2b3aaeb08..08261dae09 100644
--- a/java/org/apache/tomcat/util/file/ConfigurationSource.java
+++ b/java/org/apache/tomcat/util/file/ConfigurationSource.java
@@ -29,17 +29,16 @@ import java.net.URLConnection;
import org.apache.tomcat.util.buf.UriUtil;
/**
- * Abstracts configuration file storage. Allows Tomcat embedding using the
regular
- * configuration style.
- * This abstraction aims to be very simple and does not cover resource listing,
- * which is usually used for dynamic deployments that are usually not used when
- * embedding, as well as resource writing.
+ * Abstracts configuration file storage. Allows Tomcat embedding using the
regular configuration style. This abstraction
+ * aims to be very simple and does not cover resource listing, which is
usually used for dynamic deployments that are
+ * usually not used when embedding, as well as resource writing.
*/
public interface ConfigurationSource {
ConfigurationSource DEFAULT = new ConfigurationSource() {
private final File userDir = new File(System.getProperty("user.dir"));
private final URI userDirUri = userDir.toURI();
+
@Override
public Resource getResource(String name) throws IOException {
if (!UriUtil.isAbsoluteURI(name)) {
@@ -65,6 +64,7 @@ public interface ConfigurationSource {
throw new FileNotFoundException(name);
}
}
+
@Override
public URI getURI(String name) {
if (!UriUtil.isAbsoluteURI(name)) {
@@ -81,24 +81,26 @@ public interface ConfigurationSource {
};
/**
- * Represents a resource: a stream to the resource associated with
- * its URI.
+ * Represents a resource: a stream to the resource associated with its URI.
*/
class Resource implements AutoCloseable {
private final InputStream inputStream;
private final URI uri;
+
public Resource(InputStream inputStream, URI uri) {
this.inputStream = inputStream;
this.uri = uri;
}
+
public InputStream getInputStream() {
return inputStream;
}
+
public URI getURI() {
return uri;
}
- public long getLastModified()
- throws MalformedURLException, IOException {
+
+ public long getLastModified() throws MalformedURLException,
IOException {
URLConnection connection = null;
try {
connection = uri.toURL().openConnection();
@@ -109,6 +111,7 @@ public interface ConfigurationSource {
}
}
}
+
@Override
public void close() throws IOException {
if (inputStream != null) {
@@ -119,50 +122,58 @@ public interface ConfigurationSource {
/**
* Returns the contents of the main conf/server.xml file.
+ *
* @return the server.xml as an InputStream
+ *
* @throws IOException if an error occurs or if the resource does not exist
*/
- default Resource getServerXml()
- throws IOException {
+ default Resource getServerXml() throws IOException {
return getConfResource("server.xml");
}
/**
- * Returns the contents of the shared conf/web.xml file. This usually
- * contains the declaration of the default and JSP servlets.
+ * Returns the contents of the shared conf/web.xml file. This usually
contains the declaration of the default and
+ * JSP servlets.
+ *
* @return the web.xml as an InputStream
+ *
* @throws IOException if an error occurs or if the resource does not exist
*/
- default Resource getSharedWebXml()
- throws IOException {
+ default Resource getSharedWebXml() throws IOException {
return getConfResource("web.xml");
}
/**
* Get a resource, based on the conf path.
+ *
* @param name The resource name
+ *
* @return the resource as an InputStream
+ *
* @throws IOException if an error occurs or if the resource does not exist
*/
- default Resource getConfResource(String name)
- throws IOException {
+ default Resource getConfResource(String name) throws IOException {
String fullName = "conf/" + name;
return getResource(fullName);
}
/**
* Get a resource, not based on the conf path.
+ *
* @param name The resource name
+ *
* @return the resource
+ *
* @throws IOException if an error occurs or if the resource does not exist
*/
- Resource getResource(String name)
- throws IOException;
+ Resource getResource(String name) throws IOException;
/**
- * Get a URI to the given resource. Unlike getResource, this will also
- * return URIs to locations where no resource exists.
+ * Get a URI to the given resource. Unlike getResource, this will also
return URIs to locations where no resource
+ * exists.
+ *
* @param name The resource name
+ *
* @return a URI representing the resource location
*/
URI getURI(String name);
diff --git a/java/org/apache/tomcat/util/file/Matcher.java
b/java/org/apache/tomcat/util/file/Matcher.java
index d2e7864b9e..18ad846dba 100644
--- a/java/org/apache/tomcat/util/file/Matcher.java
+++ b/java/org/apache/tomcat/util/file/Matcher.java
@@ -20,32 +20,32 @@ package org.apache.tomcat.util.file;
import java.util.Set;
/**
- * <p>This is a utility class to match file globs.
- * The class has been derived from
+ * <p>
+ * This is a utility class to match file globs. The class has been derived from
* org.apache.tools.ant.types.selectors.SelectorUtils.
* </p>
- * <p>All methods are static.</p>
+ * <p>
+ * All methods are static.
+ * </p>
*/
public final class Matcher {
/**
- * Tests whether or not a given file name matches any file name pattern in
- * the given set. The match is performed case-sensitively.
+ * Tests whether or not a given file name matches any file name pattern in
the given set. The match is performed
+ * case-sensitively.
*
* @see #match(String, String, boolean)
*
- * @param patternSet The pattern set to match against. Must not be
- * <code>null</code>.
- * @param fileName The file name to match, as a String. Must not be
- * <code>null</code>. It must be just a file name, without
- * a path.
+ * @param patternSet The pattern set to match against. Must not be
<code>null</code>.
+ * @param fileName The file name to match, as a String. Must not be
<code>null</code>. It must be just a file
+ * name, without a path.
*
- * @return <code>true</code> if any pattern in the set matches against the
- * file name, or <code>false</code> otherwise.
+ * @return <code>true</code> if any pattern in the set matches against the
file name, or <code>false</code>
+ * otherwise.
*/
public static boolean matchName(Set<String> patternSet, String fileName) {
char[] fileNameArray = fileName.toCharArray();
- for (String pattern: patternSet) {
+ for (String pattern : patternSet) {
if (match(pattern, fileNameArray, true)) {
return true;
}
@@ -55,48 +55,35 @@ public final class Matcher {
/**
- * Tests whether or not a string matches against a pattern.
- * The pattern may contain two special characters:<br>
+ * Tests whether or not a string matches against a pattern. The pattern
may contain two special characters:<br>
* '*' means zero or more characters<br>
* '?' means one and only one character
*
- * @param pattern The pattern to match against.
- * Must not be <code>null</code>.
- * @param str The string which must be matched against the
- * pattern. Must not be <code>null</code>.
- * @param caseSensitive Whether or not matching should be performed
- * case sensitively.
- *
+ * @param pattern The pattern to match against. Must not be
<code>null</code>.
+ * @param str The string which must be matched against the
pattern. Must not be <code>null</code>.
+ * @param caseSensitive Whether or not matching should be performed case
sensitively.
*
- * @return <code>true</code> if the string matches against the pattern,
- * or <code>false</code> otherwise.
+ * @return <code>true</code> if the string matches against the pattern, or
<code>false</code> otherwise.
*/
- public static boolean match(String pattern, String str,
- boolean caseSensitive) {
+ public static boolean match(String pattern, String str, boolean
caseSensitive) {
return match(pattern, str.toCharArray(), caseSensitive);
}
/**
- * Tests whether or not a string matches against a pattern.
- * The pattern may contain two special characters:<br>
+ * Tests whether or not a string matches against a pattern. The pattern
may contain two special characters:<br>
* '*' means zero or more characters<br>
* '?' means one and only one character
*
- * @param pattern The pattern to match against.
- * Must not be <code>null</code>.
- * @param strArr The character array which must be matched against the
- * pattern. Must not be <code>null</code>.
- * @param caseSensitive Whether or not matching should be performed
- * case sensitively.
- *
+ * @param pattern The pattern to match against. Must not be
<code>null</code>.
+ * @param strArr The character array which must be matched against
the pattern. Must not be
+ * <code>null</code>.
+ * @param caseSensitive Whether or not matching should be performed case
sensitively.
*
- * @return <code>true</code> if the string matches against the pattern,
- * or <code>false</code> otherwise.
+ * @return <code>true</code> if the string matches against the pattern, or
<code>false</code> otherwise.
*/
- private static boolean match(String pattern, char[] strArr,
- boolean caseSensitive) {
+ private static boolean match(String pattern, char[] strArr, boolean
caseSensitive) {
char[] patArr = pattern.toCharArray();
int patIdxStart = 0;
int patIdxEnd = patArr.length - 1;
@@ -197,8 +184,7 @@ public final class Matcher {
for (int j = 0; j < patLength; j++) {
ch = patArr[patIdxStart + j + 1];
if (ch != '?') {
- if (different(caseSensitive, ch,
- strArr[strIdxStart + i + j])) {
+ if (different(caseSensitive, ch, strArr[strIdxStart +
i + j])) {
continue strLoop;
}
}
@@ -230,11 +216,8 @@ public final class Matcher {
return true;
}
- private static boolean different(
- boolean caseSensitive, char ch, char other) {
- return caseSensitive
- ? ch != other
- : Character.toUpperCase(ch) != Character.toUpperCase(other);
+ private static boolean different(boolean caseSensitive, char ch, char
other) {
+ return caseSensitive ? ch != other : Character.toUpperCase(ch) !=
Character.toUpperCase(other);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]