use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfLanguagePropertyPackageResolver method processListType.
protected String processListType(String typeName, boolean exceptUtil, String listPkg, String listName) {
final String listBegin = listName + "<";
final String listEnd = ">";
if (typeName.startsWith(listBegin) && typeName.endsWith(listEnd)) {
final ScopeInfo scope = Srl.extractScopeWide(typeName, listBegin, listEnd);
final String content = scope.getContent();
final String resolvedContent = doResolvePackageName(content, exceptUtil);
return listPkg + "." + listBegin + resolvedContent + listEnd;
} else {
return null;
}
}
use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfMailFluteTableLoader method verifyFormat.
// *very similar logic also exists on MailFlute
// ===================================================================================
// Verify Format
// =============
protected void verifyFormat(String bodyFile, String plainText, String delimiter) {
final String meta = Srl.substringFirstFront(plainText, delimiter);
if (!meta.endsWith(LF)) {
// also CRLF checked
throwBodyMetaNoIndependentDelimiterException(bodyFile, plainText);
}
final int rearIndex = plainText.indexOf(delimiter) + delimiter.length();
if (plainText.length() > rearIndex) {
// just in case (empty mail possible?)
final String rearFirstStr = plainText.substring(rearIndex, rearIndex + 1);
if (!Srl.equalsPlain(rearFirstStr, LF, CR)) {
// e.g. >>> Hello, ...
throwBodyMetaNoIndependentDelimiterException(bodyFile, plainText);
}
}
if (!meta.startsWith(COMMENT_BEGIN)) {
// also leading spaces not allowed
throwBodyMetaNotStartWithHeaderCommentException(bodyFile, plainText, meta);
}
if (!meta.contains(COMMENT_END)) {
throwBodyMetaHeaderCommentEndMarkNotFoundException(bodyFile, plainText, meta);
}
final String headerComment = Srl.extractScopeFirst(plainText, COMMENT_BEGIN, COMMENT_END).getContent();
final ScopeInfo titleScope = Srl.extractScopeFirst(headerComment, TITLE_BEGIN, TITLE_END);
if (titleScope == null) {
throwBodyMetaTitleCommentNotFoundException(bodyFile, plainText);
}
final String desc = Srl.substringFirstRear(headerComment, TITLE_END);
if (desc.isEmpty()) {
throwBodyMetaDescriptionCommentNotFoundException(bodyFile, plainText);
}
final String rearMeta = Srl.substringFirstRear(meta, COMMENT_END);
// no way because of already checked
// if (!rearMeta.contains(LF)) {
// }
final List<String> splitList = Srl.splitList(rearMeta, LF);
if (!splitList.get(0).trim().isEmpty()) {
// after '*/'
throwBodyMetaHeaderCommentEndMarkNoIndependentException(bodyFile, plainText);
}
if (!splitList.get(1).startsWith(SUBJECT_LABEL)) {
// also leading spaces not allowed
throwBodyMetaSubjectNotFoundException(bodyFile, plainText);
}
final int nextIndex = 2;
if (splitList.size() > nextIndex) {
// after subject
final List<String> nextList = splitList.subList(nextIndex, splitList.size());
final int nextSize = nextList.size();
int index = 0;
for (String line : nextList) {
if (index == nextSize - 1) {
// last loop
if (line.isEmpty()) {
// empty line only allowed in last loop
break;
}
}
if (!allowedPrefixList.stream().anyMatch(prefix -> line.startsWith(prefix))) {
throwBodyMetaUnknownLineException(bodyFile, plainText, line);
}
// option check is not here because it can be added in MailFlute
// if (line.startsWith(OPTION_LABEL)) {
// final String options = Srl.substringFirstRear(line, OPTION_LABEL);
// final List<String> optionList = Srl.splitListTrimmed(options, ".");
// for (String option : optionList) {
// if (!optionSet.contains(option)) {
// throwBodyMetaUnknownOptionException(bodyFile, plainText, option);
// }
// }
// }
++index;
}
}
}
use of org.dbflute.util.Srl.ScopeInfo 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.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class JavaPropertiesReader method reflectToVariableList.
protected void reflectToVariableList(String key, List<ScopeInfo> variableScopeList, List<Integer> variableNumberList, List<String> variableStringList) {
for (ScopeInfo scopeInfo : variableScopeList) {
final String content = scopeInfo.getContent();
final Integer variableNumber = valueOfVariableNumber(key, content);
if (variableNumber != null) {
// for non-number option
variableNumberList.add(variableNumber);
}
// contains all elements
variableStringList.add(content);
}
}
use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class SubQueryIndentProcessor method moveSubQueryEndToRear.
// should be checked before calling if on last line
public static String moveSubQueryEndToRear(String exp) {
final String sqend = END_MARK_PREFIX;
final String idterm = IDENTITY_TERMINAL;
final ScopeInfo lastScope = Srl.extractScopeLast(exp, sqend, idterm);
final String scopeStr = lastScope.getScope();
final String front = exp.substring(0, lastScope.getBeginIndex());
final String rear = exp.substring(lastScope.getEndIndex());
return front + rear + scopeStr;
}
Aggregations