提交 31cf6d3f authored 作者: Thomas Mueller's avatar Thomas Mueller

Rename constants.

上级 53549619
......@@ -29,10 +29,13 @@ public class CheckTextFiles {
"layout", "res", "win", "jar", "task", "svg", "MF", "mf", "sh", "DS_Store", "prop" };
private static final String[] SUFFIX_CRLF = { "bat" };
private static final boolean ALLOW_TAB = false;
private static final boolean ALLOW_CR = true;
private static final boolean ALLOW_TRAILING_SPACES = false;
private static final int SPACES_PER_TAB = 4;
private static final boolean AUTO_FIX = true;
private boolean failOnError;
private static final boolean allowTab = false, allowCR = true, allowTrailingSpaces = false;
private static final int spacesPerTab = 4;
private static final boolean autoFix = true;
private boolean useCRLF;
private final String[] suffixIgnoreLicense = {
"bat", "nsi", "txt", "properties", "xml",
......@@ -111,7 +114,7 @@ public class CheckTextFiles {
}
}
if (check) {
checkOrFixFile(file, autoFix, checkLicense);
checkOrFixFile(file, AUTO_FIX, checkLicense);
}
}
}
......@@ -163,7 +166,7 @@ public class CheckTextFiles {
return;
} else if (ch < 32) {
if (ch == '\n') {
if (lastWasWhitespace && !allowTrailingSpaces) {
if (lastWasWhitespace && !ALLOW_TRAILING_SPACES) {
fail(file, "contains trailing white space", line);
return;
}
......@@ -176,11 +179,11 @@ public class CheckTextFiles {
lastWasWhitespace = false;
line++;
} else if (ch == '\r') {
if (!allowCR) {
if (!ALLOW_CR) {
fail(file, "contains CR", line);
return;
}
if (lastWasWhitespace && !allowTrailingSpaces) {
if (lastWasWhitespace && !ALLOW_TRAILING_SPACES) {
fail(file, "contains trailing white space", line);
return;
}
......@@ -188,11 +191,11 @@ public class CheckTextFiles {
// ok
} else if (ch == '\t') {
if (fix) {
for (int j = 0; j < spacesPerTab; j++) {
for (int j = 0; j < SPACES_PER_TAB; j++) {
out.write(' ');
}
} else {
if (!allowTab) {
if (!ALLOW_TAB) {
fail(file, "contains TAB", line);
return;
}
......@@ -230,7 +233,7 @@ public class CheckTextFiles {
lastWasWhitespace = false;
}
}
if (lastWasWhitespace && !allowTrailingSpaces) {
if (lastWasWhitespace && !ALLOW_TRAILING_SPACES) {
fail(file, "contains trailing white space at the very end", line);
return;
}
......
......@@ -32,8 +32,8 @@ import org.h2.util.StringUtils;
*/
public class GenerateDoc {
private static final String IN_HELP = "src/docsrc/help/help.csv";
private String inDir = "src/docsrc/html";
private static final String inHelp = "src/docsrc/help/help.csv";
private String outDir = "docs/html";
private Connection conn;
private final HashMap<String, Object> session = new HashMap<String, Object>();
......@@ -68,7 +68,7 @@ public class GenerateDoc {
session.put("stableVersion", Constants.getVersionStable());
session.put("stableVersionDate", Constants.BUILD_DATE_STABLE);
// String help = "SELECT * FROM INFORMATION_SCHEMA.HELP WHERE SECTION";
String help = "SELECT ROWNUM ID, * FROM CSVREAD('" + inHelp + "', NULL, 'lineComment=#') WHERE SECTION ";
String help = "SELECT ROWNUM ID, * FROM CSVREAD('" + IN_HELP + "', NULL, 'lineComment=#') WHERE SECTION ";
map("commands", help + "LIKE 'Commands%' ORDER BY ID", true);
map("commandsDML", help + "= 'Commands (DML)' ORDER BY ID", false);
map("commandsDDL", help + "= 'Commands (DDL)' ORDER BY ID", false);
......
......@@ -20,7 +20,7 @@ import org.h2.util.StringUtils;
*/
public class MergeDocs {
private static final String baseDir = "docs/html";
private static final String BASE_DIR = "docs/html";
/**
* This method is called when executing this application from the command
......@@ -29,10 +29,6 @@ public class MergeDocs {
* @param args the command line parameters
*/
public static void main(String... args) throws Exception {
new MergeDocs().run();
}
private void run() throws Exception {
// the order of pages is important here
String[] pages = { "quickstart.html", "installation.html", "tutorial.html", "features.html",
"performance.html", "advanced.html", "grammar.html", "functions.html", "datatypes.html", "build.html",
......@@ -48,7 +44,7 @@ public class MergeDocs {
buff.append(text);
}
String finalText = buff.toString();
File output = new File(baseDir, "onePage.html");
File output = new File(BASE_DIR, "onePage.html");
PrintWriter writer = new PrintWriter(new FileWriter(output));
writer.println("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" /><title>");
writer.println("H2 Documentation");
......@@ -85,8 +81,8 @@ public class MergeDocs {
return text;
}
private String getContent(String fileName) throws Exception {
File file = new File(baseDir, fileName);
private static String getContent(String fileName) throws Exception {
File file = new File(BASE_DIR, fileName);
int length = (int) file.length();
char[] data = new char[length];
FileReader reader = new FileReader(file);
......
......@@ -34,8 +34,8 @@ public class WebSite {
private static final String TRANSLATE_START = "<!-- translate";
private static final String TRANSLATE_END = "translate -->";
private static final String sourceDir = "docs";
private static final String webDir = "../h2web";
private static final String SOURCE_DIR = "docs";
private static final String WEB_DIR = "../h2web";
private final HashMap<String, String> fragments = new HashMap<String, String>();
/**
......@@ -50,17 +50,17 @@ public class WebSite {
private void run() throws Exception {
// create the web site
deleteRecursive(new File(webDir));
deleteRecursive(new File(WEB_DIR));
loadFragments();
copy(new File(sourceDir), new File(webDir), true, true);
Newsfeed.main(webDir + "/html");
copy(new File(SOURCE_DIR), new File(WEB_DIR), true, true);
Newsfeed.main(WEB_DIR + "/html");
// create the internal documentation
copy(new File(sourceDir), new File(sourceDir), true, false);
copy(new File(SOURCE_DIR), new File(SOURCE_DIR), true, false);
}
private void loadFragments() throws IOException {
File dir = new File(sourceDir, "html");
File dir = new File(SOURCE_DIR, "html");
for (File f : dir.listFiles()) {
if (f.getName().startsWith("fragments")) {
FileInputStream in = new FileInputStream(f);
......
......@@ -65,10 +65,11 @@ public class FtpServer extends Tool implements Service {
static final String TASK_SUFFIX = ".task";
private static final int MAX_CONNECTION_COUNT = 100;
private ServerSocket serverSocket;
private int port = DEFAULT_PORT;
private int openConnectionCount;
private static final int maxConnectionCount = 100;
private final SimpleDateFormat dateFormatNew = new SimpleDateFormat("MMM dd HH:mm", Locale.ENGLISH);
private final SimpleDateFormat dateFormatOld = new SimpleDateFormat("MMM dd yyyy", Locale.ENGLISH);
......@@ -190,7 +191,7 @@ public class FtpServer extends Tool implements Service {
boolean stop;
synchronized (this) {
openConnectionCount++;
stop = openConnectionCount > maxConnectionCount;
stop = openConnectionCount > MAX_CONNECTION_COUNT;
}
FtpControl c = new FtpControl(s, this, stop);
c.start();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论