use of org.dbflute.logic.generate.language.grammar.DfLanguageGrammar in project dbflute-core by dbflute.
the class DfPmbMetaData method getPropertyOptionClassificationFixedElementValueExp.
public String getPropertyOptionClassificationFixedElementValueExp(String propertyName) {
if (!isPropertyOptionClassificationFixedElement(propertyName)) {
// no way
return null;
}
final String classificationName = getPropertyOptionSpecifiedClassificationName(propertyName);
if (isPropertyTypeList(propertyName)) {
final List<String> elementList = DfCollectionUtil.newArrayList();
if (isPropertyOptionClassificationFixedElementList(propertyName)) {
final List<String> fixedElementList = getPropertyOptionClassificationFixedElementList(propertyName);
for (String fixedElement : fixedElementList) {
final String valueExp = buildPropertyOptionClassificationElementValueExp(propertyName, classificationName, fixedElement);
elementList.add(valueExp);
}
} else {
// property is list but specified one
final String fixedElement = getPropertyOptionClassificationFixedElement(propertyName);
final String valueExp = buildPropertyOptionClassificationElementValueExp(propertyName, classificationName, fixedElement);
elementList.add(valueExp);
}
final DfLanguageGrammar grammar = getLanguageGrammar();
return grammar.buildOneLinerListNewBackStage(elementList);
} else {
if (isPropertyOptionClassificationFixedElementList(propertyName)) {
final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
br.addNotice("Not list property but classification fixed element list.");
br.addItem("ParameterBean");
br.addElement(getClassName());
br.addItem("Property");
br.addElement(getPropertyType(propertyName) + " " + propertyName);
br.addItem("Classification");
br.addElement(classificationName);
final List<String> fixedElementList = getPropertyOptionClassificationFixedElementList(propertyName);
br.addItem("Element List");
br.addElement(fixedElementList);
final String msg = br.buildExceptionMessage();
throw new IllegalStateException(msg);
}
final String fixedElement = getPropertyOptionClassificationFixedElement(propertyName);
return buildPropertyOptionClassificationElementValueExp(propertyName, classificationName, fixedElement);
}
}
use of org.dbflute.logic.generate.language.grammar.DfLanguageGrammar in project dbflute-core by dbflute.
the class DfParameterAutoDetectAssist method doDerivePropertyTypeFromTestValue.
protected String doDerivePropertyTypeFromTestValue(String testValue) {
// test point
if (testValue == null) {
String msg = "The argument 'testValue' should be not null.";
throw new IllegalArgumentException(msg);
}
final DfLanguageGrammar grammar = getLanguageGrammar();
final String plainTypeName;
if (Srl.startsWithIgnoreCase(testValue, "date '", "date'")) {
plainTypeName = "Date";
} else if (Srl.startsWithIgnoreCase(testValue, "timestamp '", "timestamp'")) {
plainTypeName = "Timestamp";
} else if (Srl.startsWithIgnoreCase(testValue, "time '", "time'")) {
plainTypeName = "Time";
} else {
if (Srl.isQuotedSingle(testValue)) {
final String unquoted = Srl.unquoteSingle(testValue);
Timestamp timestamp = null;
Time time = null;
try {
timestamp = DfTypeUtil.toTimestamp(unquoted);
} catch (ParseTimestampException ignored) {
try {
time = DfTypeUtil.toTime(unquoted);
} catch (ParseTimeException andIgnored) {
}
}
if (timestamp != null) {
final String timeParts = DfTypeUtil.toString(timestamp, "HH:mm:ss.SSS");
if (timeParts.equals("00:00:00.000")) {
plainTypeName = "Date";
} else {
plainTypeName = "Timestamp";
}
} else if (time != null) {
plainTypeName = "Time";
} else {
plainTypeName = "String";
}
} else if (Srl.isQuotedAnything(testValue, "(", ")")) {
final String unquoted = Srl.unquoteAnything(testValue, "(", ")");
final List<String> elementList = Srl.splitListTrimmed(unquoted, ",");
if (elementList.size() > 0) {
final String firstElement = elementList.get(0);
// InScope for Date is unsupported at this analyzing
if (Srl.isQuotedSingle(firstElement)) {
plainTypeName = "List" + grammar.buildGenericOneClassHint("String");
} else {
final String elementType = doDeriveNonQuotedLiteralTypeFromTestValue(firstElement);
plainTypeName = "List" + grammar.buildGenericOneClassHint(elementType);
}
} else {
plainTypeName = "List" + grammar.buildGenericOneClassHint("String");
}
} else {
plainTypeName = doDeriveNonQuotedLiteralTypeFromTestValue(testValue);
}
}
return plainTypeName;
}
use of org.dbflute.logic.generate.language.grammar.DfLanguageGrammar in project dbflute-core by dbflute.
the class DfDocumentTextResolver method doResolveJavaDocContent.
protected String doResolveJavaDocContent(String comment, String indent, boolean directIndent, boolean preText) {
if (comment == null || comment.trim().length() == 0) {
return null;
}
String work = comment;
final DfBasicProperties basicProp = getBasicProperties();
final DfLanguageGrammar grammar = basicProp.getLanguageDependency().getLanguageGrammar();
work = grammar.escapeJavaDocString(work);
work = removeCR(work);
final String sourceCodeLineSeparator = basicProp.getSourceCodeLineSeparator();
final String javaDocLineSeparator;
if (directIndent) {
javaDocLineSeparator = grammar.buildJavaDocLineAndIndentDirectly(sourceCodeLineSeparator, indent);
// #for_now jflute directIndent with preText is unsupported for now (2021/08/15)
} else {
if (preText) {
javaDocLineSeparator = grammar.buildJavaDocLineAndIndentPre(sourceCodeLineSeparator, indent);
} else {
javaDocLineSeparator = grammar.buildJavaDocLineAndIndent(sourceCodeLineSeparator, indent);
}
}
if (work.contains(BASIC_LINE_SEPARATOR)) {
work = work.replaceAll(BASIC_LINE_SEPARATOR, javaDocLineSeparator);
}
if (work.contains(SPECIAL_LINE_SEPARATOR)) {
work = work.replaceAll(SPECIAL_LINE_SEPARATOR, javaDocLineSeparator);
}
return work;
}
use of org.dbflute.logic.generate.language.grammar.DfLanguageGrammar in project dbflute-core by dbflute.
the class DfDocumentProperties method doResolveTextForJavaDoc.
protected String doResolveTextForJavaDoc(String comment, String indent, boolean directIndent) {
if (comment == null || comment.trim().length() == 0) {
return null;
}
String work = comment;
final DfLanguageGrammar grammar = getBasicProperties().getLanguageDependency().getLanguageGrammar();
work = grammar.escapeJavaDocString(work);
work = removeCR(work);
final String sourceCodeLineSeparator = getBasicProperties().getSourceCodeLineSeparator();
final String javaDocLineSeparator;
if (directIndent) {
javaDocLineSeparator = grammar.buildJavaDocLineAndIndentDirectly(sourceCodeLineSeparator, indent);
} else {
javaDocLineSeparator = grammar.buildJavaDocLineAndIndent(sourceCodeLineSeparator, indent);
}
if (work.contains(BASIC_LINE_SEPARATOR)) {
work = work.replaceAll(BASIC_LINE_SEPARATOR, javaDocLineSeparator);
}
if (work.contains(SPECIAL_LINE_SEPARATOR)) {
work = work.replaceAll(SPECIAL_LINE_SEPARATOR, javaDocLineSeparator);
}
return work;
}
use of org.dbflute.logic.generate.language.grammar.DfLanguageGrammar in project dbflute-core by dbflute.
the class Table method getLoadableCustomizePrimaryKeySettingExpressionList.
public List<String> getLoadableCustomizePrimaryKeySettingExpressionList() {
final Table domain = getLoadableCustomizeDomain();
if (domain == null) {
return DfCollectionUtil.emptyList();
}
final List<Column> primaryKeyList = getPrimaryKey();
final List<String> settingList = DfCollectionUtil.newArrayList();
// true if all PKs have related columns
final boolean hasRelatedColumn;
{
boolean notFoundExists = false;
for (Column pk : primaryKeyList) {
if (!pk.hasSql2EntityRelatedColumn()) {
// for example, PostgreSQL
notFoundExists = true;
break;
}
}
hasRelatedColumn = !notFoundExists;
}
int index = 0;
for (Column pk : primaryKeyList) {
final Column relatedColumn;
if (hasRelatedColumn) {
relatedColumn = pk.getSql2EntityRelatedColumn();
} else {
// if there are not related columns, it uses a key order
relatedColumn = domain.getPrimaryKey().get(index);
}
final DfLanguageGrammar grammar = getBasicProperties().getLanguageDependency().getLanguageGrammar();
settingList.add(grammar.buildEntityPropertyGetSet(pk, relatedColumn));
++index;
}
return settingList;
}
Aggregations