Ejemplo n.º 1
0
  private void appendColumnOptions(BaseColumn column) {
    StringBuilder options = new StringBuilder();
    addCommonOptions(options, column);

    if (!column.getDatatype().isBuiltin()) {
      addOption(
          options,
          UDT,
          column.getDatatype().getName()
              + "("
              + column.getLength()
              + ", "
              + column.getPrecision()
              + ", "
              + column.getScale()
              + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    }

    if (column.getDatatype().getRadix() != 0
        && column.getRadix() != column.getDatatype().getRadix()) {
      addOption(options, RADIX, column.getRadix());
    }

    buildColumnOptions(column, options);

    if (options.length() != 0) {
      append(SPACE).append(OPTIONS).append(SPACE).append(LPAREN).append(options).append(RPAREN);
    }
  }
Ejemplo n.º 2
0
  private String buildFunctionOptions(FunctionMethod function) {
    StringBuilder options = new StringBuilder();
    addCommonOptions(options, function);

    if (function.getCategory() != null) {
      addOption(options, CATEGORY, function.getCategory());
    }

    if (!function.getDeterminism().equals(Determinism.DETERMINISTIC)) {
      addOption(options, DETERMINISM, function.getDeterminism().name());
    }

    if (function.getInvocationClass() != null) {
      addOption(options, JAVA_CLASS, function.getInvocationClass());
    }

    if (function.getInvocationMethod() != null) {
      addOption(options, JAVA_METHOD, function.getInvocationMethod());
    }

    if (!function.getProperties().isEmpty()) {
      for (String key : function.getProperties().keySet()) {
        addOption(options, key, function.getProperty(key, false));
      }
    }

    return options.toString();
  }
Ejemplo n.º 3
0
  private String buildTableOptions(Table table) {
    StringBuilder options = new StringBuilder();
    addCommonOptions(options, table);

    if (table.isMaterialized()) {
      addOption(options, MATERIALIZED, table.isMaterialized());
      if (table.getMaterializedTable() != null) {
        addOption(options, MATERIALIZED_TABLE, table.getMaterializedTable().getName());
      }
    }
    if (table.supportsUpdate()) {
      addOption(options, UPDATABLE, table.supportsUpdate());
    }
    if (table.getCardinality() != -1) {
      if (table.getCardinality() != table.getCardinalityAsFloat()) {
        addOption(options, CARDINALITY, (long) table.getCardinalityAsFloat());
      } else {
        addOption(options, CARDINALITY, table.getCardinality());
      }
    }
    if (!table.getProperties().isEmpty()) {
      for (String key : table.getProperties().keySet()) {
        addOption(options, key, table.getProperty(key, false));
      }
    }
    return options.toString();
  }
Ejemplo n.º 4
0
 private void appendOptions(AbstractMetadataRecord record) {
   StringBuilder options = new StringBuilder();
   addCommonOptions(options, record);
   buildOptions(record, options);
   if (options.length() != 0) {
     append(SPACE).append(OPTIONS).append(SPACE).append(LPAREN).append(options).append(RPAREN);
   }
 }
Ejemplo n.º 5
0
 @Override
 public String toString() {
   if (this.prefixMap != null) {
     StringBuilder sb = new StringBuilder();
     for (Map.Entry<String, String> entry : this.prefixMap.entrySet()) {
       sb.append("SET NAMESPACE '")
           .append(StringUtil.replaceAll(entry.getKey(), "'", "''"))
           .append('\'') // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
           .append(" AS ")
           .append(SQLStringVisitor.escapeSinglePart(entry.getValue()))
           .append(";\n"); // $NON-NLS-1$  //$NON-NLS-2$
     }
     return sb.append("\n").toString() + buffer.toString(); // $NON-NLS-1$
   }
   return buffer.toString();
 }
Ejemplo n.º 6
0
  private String buildProcedureOptions(Procedure procedure) {
    StringBuilder options = new StringBuilder();
    addCommonOptions(options, procedure);

    if (procedure.getUpdateCount() != Procedure.AUTO_UPDATECOUNT) {
      addOption(options, UPDATECOUNT, procedure.getUpdateCount());
    }

    if (!procedure.getProperties().isEmpty()) {
      for (String key : procedure.getProperties().keySet()) {
        addOption(options, key, procedure.getProperty(key, false));
      }
    }

    return options.toString();
  }
Ejemplo n.º 7
0
 private void addOption(StringBuilder sb, String key, Object value) {
   if (sb.length() != 0) {
     sb.append(COMMA).append(SPACE);
   }
   if (value != null) {
     value = new Constant(value);
   } else {
     value = Constant.NULL_CONSTANT;
   }
   if (key != null && key.length() > 2 && key.charAt(0) == '{') {
     String origKey = key;
     int index = key.indexOf('}');
     if (index > 1) {
       String uri = key.substring(1, index);
       key = key.substring(index + 1, key.length());
       String prefix = BUILTIN_PREFIXES.get(uri);
       if ((prefix == null && usePrefixes) || createNS) {
         if (prefixMap == null) {
           prefixMap = new LinkedHashMap<String, String>();
         } else {
           prefix = this.prefixMap.get(uri);
         }
         if (prefix == null) {
           prefix = "n" + this.prefixMap.size(); // $NON-NLS-1$					
         }
         this.prefixMap.put(uri, prefix);
       }
       if (prefix != null) {
         key = prefix + ":" + key; // $NON-NLS-1$
       } else {
         key = origKey;
       }
     }
   }
   sb.append(SQLStringVisitor.escapeSinglePart(key)).append(SPACE).append(value);
 }
Ejemplo n.º 8
0
 protected DDLStringVisitor append(Object o) {
   buffer.append(o);
   return this;
 }