use of org.dbflute.helper.filesystem.FileTextLineFilter in project dbflute-core by dbflute.
the class DfRefreshMan method detectEclipseProjectName.
protected String detectEclipseProjectName() {
// e.g.
// PROJECT_ROOT
// |-dbflute_maihamadb
// |-mydbflute
// |-...
// |-.project
final File projectFile = new File("../.project");
if (!projectFile.exists()) {
return null;
}
final Set<String> resultSet = new HashSet<String>();
try {
new FileTextIO().encodeAsUTF8().readFilteringLine(new FileInputStream(projectFile), new FileTextLineFilter() {
boolean _found = false;
public String filter(String line) {
if (_found || !line.contains("<name>")) {
return null;
}
ScopeInfo scopeInfo = Srl.extractScopeFirst(line, "<name>", "</name>");
if (scopeInfo == null) {
// basically no way, just in case
return null;
}
final String content = scopeInfo.getContent().trim();
resultSet.add(content);
_found = true;
return null;
}
});
} catch (FileNotFoundException ignored) {
// no way because of already checked, just in case
return null;
}
if (resultSet.isEmpty()) {
_log.info("*The .project file exists but not found project name: " + projectFile);
return null;
}
return resultSet.iterator().next();
}
use of org.dbflute.helper.filesystem.FileTextLineFilter in project dbflute-core by dbflute.
the class DfUpgradeTask method doReplaceVersionScript.
protected void doReplaceVersionScript(final String upgradeVersion, FileTextIO textIO, String scriptPath, final String versionKeyword) {
final File versionScript = new File(scriptPath);
if (versionScript.exists()) {
// basically true (just in case)
_log.info("...Replacing version script: " + scriptPath);
textIO.rewriteFilteringLine(scriptPath, new FileTextLineFilter() {
public String filter(String line) {
return filterVersionLine(upgradeVersion, line, versionKeyword);
}
});
}
}
Aggregations