Пример #1
0
 /** Create the system variable (input and output) section of the snippet. */
 private String createFieldsSection() {
   StringBuilder out = new StringBuilder();
   out.append(
       "  private val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment\n");
   if (this.m_settings != null && this.m_settings.getParameters().size() > 0) {
     out.append("  // Parsed input parameters; all parameters have been initialized\n");
     for (Parameter parameter : this.m_settings.getParameters()) {
       String scalaType = TypeToScalaType.get(parameter.getType());
       if (parameter.isOptional())
         out.append(
             String.format(
                 "  private var %s: Option[%s] = None\n", parameter.getName(), scalaType));
       else
         out.append(
             String.format(
                 "  private var %s: %s = null.asInstanceOf[%2$s]\n",
                 parameter.getName(), scalaType));
     }
   }
   return out.toString();
 }
Пример #2
0
 /** Create the system variable (input and output) section of the snippet. */
 private String createMainSection() {
   StringBuilder out = new StringBuilder();
   out.append("  def main(args: Array[String]) {\n");
   out.append("    // Generated parameter extraction\n");
   if (this.m_settings != null && this.m_settings.getParameters().size() > 0) {
     List<Parameter> parameters = this.m_settings.getParameters();
     for (int index = 0; index < parameters.size(); index++) {
       String argSelector = String.format("args(%d)", index);
       Parameter parameter = parameters.get(index);
       String parser = String.format(TypeParserPattern.get(parameter.getType()), argSelector);
       if (parameter.isOptional())
         out.append(
             String.format(
                 "    if(args.length > %d && args(%1$d) != \"\")\n      %s = Option(%s)\n",
                 index, parameter.getName(), parser));
       else out.append(String.format("    %s = %s\n", parameter.getName(), parser));
     }
   }
   out.append("    performTask\n");
   out.append("  }");
   return out.toString();
 }
Пример #3
0
 public void addParameter(final Parameter outVar) {
   this.model.addRow(new Object[] {outVar.getName(), outVar.getType(), outVar.isOptional()});
 }