Example #1
0
 // ===================================================================================
 //                                                                         Line Helper
 //                                                                         ===========
 protected String filterAsLine(String text, FileTextLineFilter filter) {
   final String cr = "\r";
   final String lf = "\n";
   final StringBuilder sb = new StringBuilder();
   final List<String> lineList = Srl.splitList(text, lf);
   final int lineCount = lineList.size();
   int index = 0;
   for (String line : lineList) {
     final String pureLine;
     final boolean hasCR;
     if (line.endsWith(cr)) {
       pureLine = Srl.substringLastFront(line, cr);
       hasCR = true;
     } else {
       pureLine = line;
       hasCR = false;
     }
     final String filteredLine = filter.filter(pureLine);
     if (filteredLine != null) {
       sb.append(filteredLine);
       if (index + 1 < lineCount) { // not last line
         sb.append(hasCR ? cr : "").append(lf);
       }
     }
     ++index;
   }
   return sb.toString();
 }
 protected void setupDbType(Map<String, DfColumnMeta> metaMap, String columnName, Column column) {
   final DfColumnMeta columnMeta = metaMap.get(columnName);
   final String dbTypeName;
   final String plainName = columnMeta.getDbTypeName();
   if (Srl.contains(plainName, ".")) { // basically for ARRAY and STRUCT type
     final String catalogSchema = Srl.substringLastFront(plainName, ".");
     final UnifiedSchema unifiedSchema = UnifiedSchema.createAsDynamicSchema(catalogSchema);
     if (unifiedSchema.isMainSchema()) {
       dbTypeName = Srl.substringLastRear(plainName, ".");
     } else {
       dbTypeName = plainName;
     }
   } else {
     dbTypeName = plainName;
   }
   column.setDbType(dbTypeName);
 }
 protected void doProcessAlternateBooleanMethodIfNode(String sql, IfNode ifNode) {
   final String expression = ifNode.getExpression().trim(); // trim it just in case
   if (Srl.containsAny(expression, getIfCommentConnectors())
       || Srl.containsAny(expression, getIfCommentOperands())) {
     return; // unknown (type)
   }
   if (isPmCommentNestedProperty(expression) || !isPmCommentMethodCall(expression)) {
     return; // e.g. pmb.foo.bar
   }
   if (!isPmCommentStartsWithPmb(substringBooleanNotRear(expression))) {
     return; // e.g. #current.isFoo()
   }
   // pmb.foo() or !pmb.foo() here
   String methodName = substringPmCommentPmbRear(expression); // -> foo()
   methodName = Srl.substringLastFront(methodName, "()"); // -> foo
   _alternateBooleanMethodNameSet.add(methodName); // filter later
 }