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;
 }
Пример #2
0
 protected final List<String> splitListTrimmed(String str, String delimiter) {
   return Srl.splitListTrimmed(str, delimiter);
 }