This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 6f309ee463 Code clean-up - formatting. No functional change.
6f309ee463 is described below
commit 6f309ee46355e347da692ea9511d5b72f11a63e7
Author: Mark Thomas <[email protected]>
AuthorDate: Tue May 13 14:50:58 2025 +0100
Code clean-up - formatting. No functional change.
---
java/org/apache/tomcat/buildutil/CheckEol.java | 42 ++++------
.../apache/tomcat/buildutil/MimeTypeMappings.java | 4 +-
.../apache/tomcat/buildutil/RepeatableArchive.java | 8 +-
java/org/apache/tomcat/buildutil/Txt2Html.java | 90 ++++++++++------------
.../buildutil/translate/BackportEnglish.java | 8 +-
.../buildutil/translate/BackportTranslations.java | 9 +--
.../apache/tomcat/buildutil/translate/Export.java | 5 +-
.../apache/tomcat/buildutil/translate/Import.java | 3 +-
.../apache/tomcat/buildutil/translate/Utils.java | 8 +-
9 files changed, 75 insertions(+), 102 deletions(-)
diff --git a/java/org/apache/tomcat/buildutil/CheckEol.java
b/java/org/apache/tomcat/buildutil/CheckEol.java
index f654586fac..727cb55488 100644
--- a/java/org/apache/tomcat/buildutil/CheckEol.java
+++ b/java/org/apache/tomcat/buildutil/CheckEol.java
@@ -31,13 +31,10 @@ import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
/**
- * Ant task that checks that all the files in the given fileset have
end-of-line
- * delimiters that are appropriate.
- *
+ * Ant task that checks that all the files in the given fileset have
end-of-line delimiters that are appropriate.
* <p>
- * The goal is to check whether we have problems with Subversion's
svn:eol-style
- * property or Git's autocrlf setting when files are committed on one OS and
then
- * checked on another one.
+ * The goal is to check whether we have problems with Subversion's
svn:eol-style property or Git's autocrlf setting when
+ * files are committed on one OS and then checked on another one.
*/
public class CheckEol extends Task {
@@ -52,8 +49,8 @@ public class CheckEol extends Task {
*
* @param fs The fileset to be checked.
*/
- public void addFileset( FileSet fs ) {
- filesets.add( fs );
+ public void addFileset(FileSet fs) {
+ filesets.add(fs);
}
/**
@@ -61,12 +58,12 @@ public class CheckEol extends Task {
*
* @param mode The line ending mode (either LF or CRLF)
*/
- public void setMode( String mode ) {
- this.mode = Mode.valueOf( mode.toUpperCase(Locale.ENGLISH) );
+ public void setMode(String mode) {
+ this.mode = Mode.valueOf(mode.toUpperCase(Locale.ENGLISH));
}
private Mode getMode() {
- if ( mode != null ) {
+ if (mode != null) {
return mode;
} else {
if ("\n".equals(System.lineSeparator())) {
@@ -82,14 +79,13 @@ public class CheckEol extends Task {
/**
* Perform the check
*
- * @throws BuildException if an error occurs during execution of
- * this task.
+ * @throws BuildException if an error occurs during execution of this task.
*/
@Override
public void execute() throws BuildException {
Mode mode = getMode();
- if ( mode == null ) {
+ if (mode == null) {
log("Line ends check skipped, because OS line ends setting is
neither LF nor CRLF.", Project.MSG_VERBOSE);
return;
}
@@ -107,25 +103,21 @@ public class CheckEol extends Task {
log("Checking line ends in " + files.length + " file(s)");
for (String filename : files) {
File file = new File(basedir, filename);
- log("Checking file '" + file + "' for correct line ends",
- Project.MSG_DEBUG);
+ log("Checking file '" + file + "' for correct line ends",
Project.MSG_DEBUG);
try {
check(file, errors, mode);
} catch (IOException e) {
- throw new BuildException("Could not check file '"
- + file.getAbsolutePath() + "'", e);
+ throw new BuildException("Could not check file '" +
file.getAbsolutePath() + "'", e);
}
count++;
}
}
}
if (count > 0) {
- log("Done line ends check in " + count + " file(s), "
- + errors.size() + " error(s) found.");
+ log("Done line ends check in " + count + " file(s), " +
errors.size() + " error(s) found.");
}
if (!errors.isEmpty()) {
- String message = "The following files have wrong line ends: "
- + errors;
+ String message = "The following files have wrong line ends: " +
errors;
// We need to explicitly write the message to the log, because
// long BuildException messages may be trimmed. E.g. I observed
// this problem with Eclipse IDE 3.7.
@@ -135,7 +127,8 @@ public class CheckEol extends Task {
}
private enum Mode {
- LF, CRLF
+ LF,
+ CRLF
}
private record CheckFailure(File file, int line, String value) {
@@ -146,8 +139,7 @@ public class CheckEol extends Task {
}
private void check(File file, List<CheckFailure> errors, Mode mode) throws
IOException {
- try (FileInputStream fis = new FileInputStream(file);
- BufferedInputStream is = new BufferedInputStream(fis)) {
+ try (FileInputStream fis = new FileInputStream(file);
BufferedInputStream is = new BufferedInputStream(fis)) {
int line = 1;
int prev = -1;
int ch;
diff --git a/java/org/apache/tomcat/buildutil/MimeTypeMappings.java
b/java/org/apache/tomcat/buildutil/MimeTypeMappings.java
index 3f467ad7d5..6b985de351 100644
--- a/java/org/apache/tomcat/buildutil/MimeTypeMappings.java
+++ b/java/org/apache/tomcat/buildutil/MimeTypeMappings.java
@@ -49,7 +49,7 @@ public class MimeTypeMappings {
digester.parse(globalWebXml);
Map<String,String> webXmlMimeMappings =
webXmlDefaultFragment.getMimeMappings();
- SortedMap<String, String> sortedWebXmlMimeMappings = new
TreeMap<>(webXmlMimeMappings);
+ SortedMap<String,String> sortedWebXmlMimeMappings = new
TreeMap<>(webXmlMimeMappings);
File f = new
File("java/org/apache/catalina/startup/MimeTypeMappings.properties");
try (FileOutputStream fos = new FileOutputStream(f);
@@ -59,7 +59,7 @@ public class MimeTypeMappings {
w.write(System.lineSeparator());
- for (Map.Entry<String, String> mapping :
sortedWebXmlMimeMappings.entrySet()) {
+ for (Map.Entry<String,String> mapping :
sortedWebXmlMimeMappings.entrySet()) {
w.write(mapping.getKey());
w.write("=");
w.write(mapping.getValue());
diff --git a/java/org/apache/tomcat/buildutil/RepeatableArchive.java
b/java/org/apache/tomcat/buildutil/RepeatableArchive.java
index 6d12217ea3..e6deb4c3a3 100644
--- a/java/org/apache/tomcat/buildutil/RepeatableArchive.java
+++ b/java/org/apache/tomcat/buildutil/RepeatableArchive.java
@@ -41,11 +41,9 @@ import org.apache.tools.ant.types.FileSet;
/**
* Ant task to assist with repeatable builds.
* <p>
- * While originally written to address an issue with Javadoc output, this task
- * takes a generic approach that could be used with any archive. The task takes
- * a set of zip (or jar, war etc) files as its input and sets the last modified
- * time of every file in the archive to be the same as the last modified time
- * of the archive.
+ * While originally written to address an issue with Javadoc output, this task
takes a generic approach that could be
+ * used with any archive. The task takes a set of zip (or jar, war etc) files
as its input and sets the last modified
+ * time of every file in the archive to be the same as the last modified time
of the archive.
*/
public class RepeatableArchive extends Task {
diff --git a/java/org/apache/tomcat/buildutil/Txt2Html.java
b/java/org/apache/tomcat/buildutil/Txt2Html.java
index 0d2438b7a8..5c6b196105 100644
--- a/java/org/apache/tomcat/buildutil/Txt2Html.java
+++ b/java/org/apache/tomcat/buildutil/Txt2Html.java
@@ -35,17 +35,15 @@ import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
/**
- * Ant task to convert a given set of files from Text to HTML.
- * Inserts an HTML header including pre tags and replaces special characters
- * with their HTML escaped equivalents.
- *
- * <p>This task is currently used by the ant script to build our examples</p>
+ * Ant task to convert a given set of files from Text to HTML. Inserts an HTML
header including pre tags and replaces
+ * special characters with their HTML escaped equivalents.
+ * <p>
+ * This task is currently used by the ant script to build our examples
+ * </p>
*
* @author Mark Roth
*/
-public class Txt2Html
- extends Task
-{
+public class Txt2Html extends Task {
/** The directory to contain the resulting files */
private File todir;
@@ -54,14 +52,13 @@ public class Txt2Html
private final List<FileSet> filesets = new ArrayList<>();
/**
- * The encoding of the source files (.java and .jsp). Once they use
- * UTF-8, this will need to be updated.
+ * The encoding of the source files (.java and .jsp). Once they use UTF-8,
this will need to be updated.
*/
private static final String SOURCE_ENCODING = "ISO-8859-1";
/**
- * Line terminator to be used for separating lines of the generated
- * HTML page, to be independent of the "line.separator" system property.
+ * Line terminator to be used for separating lines of the generated HTML
page, to be independent of the
+ * "line.separator" system property.
*/
private static final String LINE_SEPARATOR = "\r\n";
@@ -70,7 +67,7 @@ public class Txt2Html
*
* @param todir The directory
*/
- public void setTodir( File todir ) {
+ public void setTodir(File todir) {
this.todir = todir;
}
@@ -79,20 +76,17 @@ public class Txt2Html
*
* @param fs The fileset to be converted.
*/
- public void addFileset( FileSet fs ) {
- filesets.add( fs );
+ public void addFileset(FileSet fs) {
+ filesets.add(fs);
}
/**
* Perform the conversion
*
- * @throws BuildException if an error occurs during execution of
- * this task.
+ * @throws BuildException if an error occurs during execution of this task.
*/
@Override
- public void execute()
- throws BuildException
- {
+ public void execute() throws BuildException {
int count = 0;
// Step through each file and convert.
@@ -103,23 +97,21 @@ public class Txt2Html
for (String file : files) {
File from = new File(basedir, file);
File to = new File(todir, file + ".html");
- if (!to.exists() ||
- (from.lastModified() > to.lastModified())) {
- log("Converting file '" + from.getAbsolutePath() +
- "' to '" + to.getAbsolutePath(),
Project.MSG_VERBOSE);
+ if (!to.exists() || (from.lastModified() > to.lastModified()))
{
+ log("Converting file '" + from.getAbsolutePath() + "' to
'" + to.getAbsolutePath(),
+ Project.MSG_VERBOSE);
try {
convert(from, to);
} catch (IOException e) {
- throw new BuildException("Could not convert '" +
- from.getAbsolutePath() + "' to '" +
- to.getAbsolutePath() + "'", e);
+ throw new BuildException(
+ "Could not convert '" + from.getAbsolutePath()
+ "' to '" + to.getAbsolutePath() + "'",
+ e);
}
count++;
}
}
- if( count > 0 ) {
- log( "Converted " + count + " file" + (count > 1 ? "s" : "") +
- " to " + todir.getAbsolutePath() );
+ if (count > 0) {
+ log("Converted " + count + " file" + (count > 1 ? "s" : "") +
" to " + todir.getAbsolutePath());
}
}
}
@@ -128,45 +120,44 @@ public class Txt2Html
* Perform the actual copy and conversion
*
* @param from The input file
- * @param to The output file
+ * @param to The output file
+ *
* @throws IOException Thrown if an error occurs during the conversion
*/
- private void convert( File from, File to )
- throws IOException
- {
+ private void convert(File from, File to) throws IOException {
// Open files:
- try (BufferedReader in = new BufferedReader(new InputStreamReader(
- new FileInputStream(from), SOURCE_ENCODING))) {
- try (PrintWriter out = new PrintWriter(new OutputStreamWriter(
- new FileOutputStream(to), StandardCharsets.UTF_8))) {
+ try (BufferedReader in =
+ new BufferedReader(new InputStreamReader(new
FileInputStream(from), SOURCE_ENCODING))) {
+ try (PrintWriter out =
+ new PrintWriter(new OutputStreamWriter(new
FileOutputStream(to), StandardCharsets.UTF_8))) {
// Output header:
- out.print("<!DOCTYPE html><html><head><meta charset=\"UTF-8\"
/>"
- + "<title>Source Code</title></head><body><pre>" );
+ out.print("<!DOCTYPE html><html><head><meta charset=\"UTF-8\"
/>" +
+ "<title>Source Code</title></head><body><pre>");
// Convert, line-by-line:
String line;
- while( (line = in.readLine()) != null ) {
+ while ((line = in.readLine()) != null) {
StringBuilder result = new StringBuilder();
int len = line.length();
- for( int i = 0; i < len; i++ ) {
- char c = line.charAt( i );
- switch( c ) {
+ for (int i = 0; i < len; i++) {
+ char c = line.charAt(i);
+ switch (c) {
case '&':
- result.append( "&" );
+ result.append("&");
break;
case '<':
- result.append( "<" );
+ result.append("<");
break;
default:
- result.append( c );
+ result.append(c);
}
}
- out.print( result.toString() + LINE_SEPARATOR );
+ out.print(result.toString() + LINE_SEPARATOR);
}
// Output footer:
- out.print( "</pre></body></html>" );
+ out.print("</pre></body></html>");
}
}
@@ -174,4 +165,3 @@ public class Txt2Html
}
-
diff --git a/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java
b/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java
index 0354cf3311..ecfc41715b 100644
--- a/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java
+++ b/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java
@@ -21,11 +21,9 @@ import java.util.HashSet;
import java.util.Set;
/**
- * Generates a set of English property files to back-port updates to a previous
- * version. Where a key exists in the source and target versions the value is
- * copied from the source to the target, overwriting the value in the target.
- * The expectation is that the changes will be manually reviewed before
- * committing them.
+ * Generates a set of English property files to back-port updates to a
previous version. Where a key exists in the
+ * source and target versions the value is copied from the source to the
target, overwriting the value in the target.
+ * The expectation is that the changes will be manually reviewed before
committing them.
*/
public class BackportEnglish extends BackportBase {
diff --git
a/java/org/apache/tomcat/buildutil/translate/BackportTranslations.java
b/java/org/apache/tomcat/buildutil/translate/BackportTranslations.java
index df003982b0..c53746b319 100644
--- a/java/org/apache/tomcat/buildutil/translate/BackportTranslations.java
+++ b/java/org/apache/tomcat/buildutil/translate/BackportTranslations.java
@@ -20,10 +20,8 @@ import java.io.IOException;
import java.util.Properties;
/**
- * Generates a set of translated property files to back-port updates to a
- * previous version. If the source and target use the same value for the
English
- * key then any translated value for that key is copied from the source to the
- * target.
+ * Generates a set of translated property files to back-port updates to a
previous version. If the source and target use
+ * the same value for the English key then any translated value for that key
is copied from the source to the target.
*/
public class BackportTranslations extends BackportBase {
@@ -53,8 +51,7 @@ public class BackportTranslations extends BackportBase {
}
for (Object key : targetEnglish.keySet()) {
- if (sourceTranslated.containsKey(key) &&
- targetEnglish.get(key).equals(sourceEnglish.get(key)))
{
+ if (sourceTranslated.containsKey(key) &&
targetEnglish.get(key).equals(sourceEnglish.get(key))) {
targetTranslated.put(key, sourceTranslated.get(key));
}
diff --git a/java/org/apache/tomcat/buildutil/translate/Export.java
b/java/org/apache/tomcat/buildutil/translate/Export.java
index 9c137490e6..b845f1d154 100644
--- a/java/org/apache/tomcat/buildutil/translate/Export.java
+++ b/java/org/apache/tomcat/buildutil/translate/Export.java
@@ -23,8 +23,7 @@ import java.util.Map;
import java.util.Properties;
/**
- * Generates a single properties file per language for import into a
translation
- * tool.
+ * Generates a single properties file per language for import into a
translation tool.
*/
public class Export {
@@ -49,7 +48,7 @@ public class Export {
}
for (Map.Entry<String,Properties> translationEntry :
translations.entrySet()) {
- Utils.export(translationEntry.getKey(),
translationEntry.getValue(), storageDir);
+ Utils.export(translationEntry.getKey(),
translationEntry.getValue(), storageDir);
}
}
}
diff --git a/java/org/apache/tomcat/buildutil/translate/Import.java
b/java/org/apache/tomcat/buildutil/translate/Import.java
index 9991309cfa..a6998dd3cf 100644
--- a/java/org/apache/tomcat/buildutil/translate/Import.java
+++ b/java/org/apache/tomcat/buildutil/translate/Import.java
@@ -72,7 +72,8 @@ public class Import {
if (w != null) {
w.close();
}
- File outFile = new File(currentPkg.replace('.',
File.separatorChar), Constants.L10N_PREFIX + language + Constants.L10N_SUFFIX);
+ File outFile = new File(currentPkg.replace('.',
File.separatorChar),
+ Constants.L10N_PREFIX + language +
Constants.L10N_SUFFIX);
FileOutputStream fos = new FileOutputStream(outFile);
w = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
org.apache.tomcat.buildutil.Utils.insertLicense(w);
diff --git a/java/org/apache/tomcat/buildutil/translate/Utils.java
b/java/org/apache/tomcat/buildutil/translate/Utils.java
index 55094677bd..befd817c12 100644
--- a/java/org/apache/tomcat/buildutil/translate/Utils.java
+++ b/java/org/apache/tomcat/buildutil/translate/Utils.java
@@ -98,9 +98,8 @@ public class Utils {
/*
- * Values containing "[{n}]" and "'" need to have the "'" escaped as "''".
- * POEditor attempts to do this automatically but does it for any value
- * containing "{" or "}" leading to some unnecessary escaping. This method
+ * Values containing "[{n}]" and "'" need to have the "'" escaped as "''".
POEditor attempts to do this
+ * automatically but does it for any value containing "{" or "}" leading
to some unnecessary escaping. This method
* undoes the unnecessary escaping.
*/
static String fixUnnecessaryEscaping(String key, String value) {
@@ -112,8 +111,7 @@ public class Utils {
/*
- * Common formatting to convert a String for storage as a value in a
- * property file.
+ * Common formatting to convert a String for storage as a value in a
property file.
*/
static String formatValueCommon(String in) {
String result = in.replace("\n", "\\n\\\n");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]