test_class.file: smart-zeppelin/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java
test_class.identifier: InputTest
test_case.body: @Test
  	public void testFormSubstitution() {
  		// test form substitution without new forms
  		String script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" +
  				"CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3}";
  		Map<String, Object> params = new HashMap<>();
  		params.put("input_form", "some_input");
  		params.put("select_form", "s_op2");
  		params.put("checkbox_form", new String[]{"c_op1", "c_op3"});
  		String replaced = Input.getSimpleQuery(params, script);
  		assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1,c_op3", replaced);
  
  		// test form substitution with new forms
  		script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" +
  				"CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3}\n" +
  				"NEW_CHECKED=${checkbox( and ):new_check=nc_a|nc_c,nc_a|nc_b|nc_c}";
  		replaced = Input.getSimpleQuery(params, script);
  		assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1,c_op3\n" +
  				"NEW_CHECKED=nc_a and nc_c", replaced);
  
  		// test form substitution with obsoleted values
  		script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" +
  				"CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3_new}\n" +
  				"NEW_CHECKED=${checkbox( and ):new_check=nc_a|nc_c,nc_a|nc_b|nc_c}";
  		replaced = Input.getSimpleQuery(params, script);
  		assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1\n" +
  				"NEW_CHECKED=nc_a and nc_c", replaced);
  	}
test_case.class_method_signature: InputTest.testFormSubstitution()
test_case.full_signature: @Test public void testFormSubstitution()
test_case.identifier: testFormSubstitution
test_case.invocations: put put put getSimpleQuery assertEquals getSimpleQuery assertEquals getSimpleQuery assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFormSubstitution()
focal_class.declarator: name
focal_class.original_string: String name;
focal_class.type: String
focal_class.var_name: name
focal_class.declarator: displayName
focal_class.original_string: String displayName;
focal_class.type: String
focal_class.var_name: displayName
focal_class.declarator: type
focal_class.original_string: String type;
focal_class.type: String
focal_class.var_name: type
focal_class.declarator: argument
focal_class.original_string: String argument;
focal_class.type: String
focal_class.var_name: argument
focal_class.declarator: defaultValue
focal_class.original_string: Object defaultValue;
focal_class.type: Object
focal_class.var_name: defaultValue
focal_class.declarator: options
focal_class.original_string: ParamOption[] options;
focal_class.type: ParamOption[]
focal_class.var_name: options
focal_class.declarator: hidden
focal_class.original_string: boolean hidden;
focal_class.type: boolean
focal_class.var_name: hidden
focal_class.declarator: VAR_PTN = Pattern.compile("([_])?[$][{]([^=}]*([=][^}]*)?)[}]")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern VAR_PTN = Pattern.compile("([_])?[$][{]([^=}]*([=][^}]*)?)[}]");
focal_class.type: Pattern
focal_class.var_name: VAR_PTN
focal_class.declarator: DEFAULT_DELIMITER = ","
focal_class.modifier: private static final
focal_class.original_string: private static final String DEFAULT_DELIMITER = ",";
focal_class.type: String
focal_class.var_name: DEFAULT_DELIMITER
focal_class.file: smart-zeppelin/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java
focal_class.identifier: Input
focal_class.interfaces: implements Serializable
focal_class.class_method_signature: Input.Input(String name, Object defaultValue, String type)
focal_class.full_signature: public  Input(String name, Object defaultValue, String type)
focal_class.identifier: Input
focal_class.modifiers: public
focal_class.parameters: (String name, Object defaultValue, String type)
focal_class.signature:  Input(String name, Object defaultValue, String type)
focal_class.class_method_signature: Input.Input(String name, Object defaultValue, String type, ParamOption[] options)
focal_class.full_signature: public  Input(String name, Object defaultValue, String type, ParamOption[] options)
focal_class.identifier: Input
focal_class.modifiers: public
focal_class.parameters: (String name, Object defaultValue, String type, ParamOption[] options)
focal_class.signature:  Input(String name, Object defaultValue, String type, ParamOption[] options)
focal_class.class_method_signature: Input.Input(String name, String displayName, String type, String argument, Object defaultValue,
        ParamOption[] options, boolean hidden)
focal_class.full_signature: public  Input(String name, String displayName, String type, String argument, Object defaultValue,
        ParamOption[] options, boolean hidden)
focal_class.identifier: Input
focal_class.modifiers: public
focal_class.parameters: (String name, String displayName, String type, String argument, Object defaultValue,
        ParamOption[] options, boolean hidden)
focal_class.signature:  Input(String name, String displayName, String type, String argument, Object defaultValue,
        ParamOption[] options, boolean hidden)
focal_class.class_method_signature: Input.equals(Object o)
focal_class.full_signature: @Override public boolean equals(Object o)
focal_class.identifier: equals
focal_class.modifiers: @Override public
focal_class.parameters: (Object o)
focal_class.return: boolean
focal_class.signature: boolean equals(Object o)
focal_class.class_method_signature: Input.getName()
focal_class.full_signature: public String getName()
focal_class.identifier: getName
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getName()
focal_class.class_method_signature: Input.setName(String name)
focal_class.full_signature: public void setName(String name)
focal_class.identifier: setName
focal_class.modifiers: public
focal_class.parameters: (String name)
focal_class.return: void
focal_class.signature: void setName(String name)
focal_class.class_method_signature: Input.getDisplayName()
focal_class.full_signature: public String getDisplayName()
focal_class.identifier: getDisplayName
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getDisplayName()
focal_class.class_method_signature: Input.setDisplayName(String displayName)
focal_class.full_signature: public void setDisplayName(String displayName)
focal_class.identifier: setDisplayName
focal_class.modifiers: public
focal_class.parameters: (String displayName)
focal_class.return: void
focal_class.signature: void setDisplayName(String displayName)
focal_class.class_method_signature: Input.getType()
focal_class.full_signature: public String getType()
focal_class.identifier: getType
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getType()
focal_class.class_method_signature: Input.setType(String type)
focal_class.full_signature: public void setType(String type)
focal_class.identifier: setType
focal_class.modifiers: public
focal_class.parameters: (String type)
focal_class.return: void
focal_class.signature: void setType(String type)
focal_class.class_method_signature: Input.getDefaultValue()
focal_class.full_signature: public Object getDefaultValue()
focal_class.identifier: getDefaultValue
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Object
focal_class.signature: Object getDefaultValue()
focal_class.class_method_signature: Input.setDefaultValue(Object defaultValue)
focal_class.full_signature: public void setDefaultValue(Object defaultValue)
focal_class.identifier: setDefaultValue
focal_class.modifiers: public
focal_class.parameters: (Object defaultValue)
focal_class.return: void
focal_class.signature: void setDefaultValue(Object defaultValue)
focal_class.class_method_signature: Input.getOptions()
focal_class.full_signature: public ParamOption[] getOptions()
focal_class.identifier: getOptions
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: ParamOption[]
focal_class.signature: ParamOption[] getOptions()
focal_class.class_method_signature: Input.setOptions(ParamOption[] options)
focal_class.full_signature: public void setOptions(ParamOption[] options)
focal_class.identifier: setOptions
focal_class.modifiers: public
focal_class.parameters: (ParamOption[] options)
focal_class.return: void
focal_class.signature: void setOptions(ParamOption[] options)
focal_class.class_method_signature: Input.isHidden()
focal_class.full_signature: public boolean isHidden()
focal_class.identifier: isHidden
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isHidden()
focal_class.class_method_signature: Input.getNameAndDisplayName(String str)
focal_class.full_signature: private static String[] getNameAndDisplayName(String str)
focal_class.identifier: getNameAndDisplayName
focal_class.modifiers: private static
focal_class.parameters: (String str)
focal_class.return: String[]
focal_class.signature: String[] getNameAndDisplayName(String str)
focal_class.class_method_signature: Input.getType(String str)
focal_class.full_signature: private static String[] getType(String str)
focal_class.identifier: getType
focal_class.modifiers: private static
focal_class.parameters: (String str)
focal_class.return: String[]
focal_class.signature: String[] getType(String str)
focal_class.class_method_signature: Input.getInputForm(Matcher match)
focal_class.full_signature: private static Input getInputForm(Matcher match)
focal_class.identifier: getInputForm
focal_class.modifiers: private static
focal_class.parameters: (Matcher match)
focal_class.return: Input
focal_class.signature: Input getInputForm(Matcher match)
focal_class.class_method_signature: Input.extractSimpleQueryForm(String script)
focal_class.full_signature: public static LinkedHashMap<String, Input> extractSimpleQueryForm(String script)
focal_class.identifier: extractSimpleQueryForm
focal_class.modifiers: public static
focal_class.parameters: (String script)
focal_class.return: LinkedHashMap<String, Input>
focal_class.signature: LinkedHashMap<String, Input> extractSimpleQueryForm(String script)
focal_class.class_method_signature: Input.getSimpleQuery(Map<String, Object> params, String script)
focal_class.full_signature: public static String getSimpleQuery(Map<String, Object> params, String script)
focal_class.identifier: getSimpleQuery
focal_class.modifiers: public static
focal_class.parameters: (Map<String, Object> params, String script)
focal_class.return: String
focal_class.signature: String getSimpleQuery(Map<String, Object> params, String script)
focal_class.class_method_signature: Input.split(String str)
focal_class.full_signature: public static String[] split(String str)
focal_class.identifier: split
focal_class.modifiers: public static
focal_class.parameters: (String str)
focal_class.return: String[]
focal_class.signature: String[] split(String str)
focal_class.class_method_signature: Input.splitPipe(String str)
focal_class.full_signature: public static String[] splitPipe(String str)
focal_class.identifier: splitPipe
focal_class.modifiers: public static
focal_class.parameters: (String str)
focal_class.return: String[]
focal_class.signature: String[] splitPipe(String str)
focal_class.class_method_signature: Input.split(String str, char split)
focal_class.full_signature: public static String[] split(String str, char split)
focal_class.identifier: split
focal_class.modifiers: public static
focal_class.parameters: (String str, char split)
focal_class.return: String[]
focal_class.signature: String[] split(String str, char split)
focal_class.class_method_signature: Input.split(String str, String[] splitters, boolean includeSplitter)
focal_class.full_signature: public static String[] split(String str, String[] splitters, boolean includeSplitter)
focal_class.identifier: split
focal_class.modifiers: public static
focal_class.parameters: (String str, String[] splitters, boolean includeSplitter)
focal_class.return: String[]
focal_class.signature: String[] split(String str, String[] splitters, boolean includeSplitter)
focal_class.class_method_signature: Input.split(String str, String escapeSeq, char escapeChar, String[] blockStart,
        String[] blockEnd, String[] splitters, boolean includeSplitter)
focal_class.full_signature: public static String[] split(String str, String escapeSeq, char escapeChar, String[] blockStart,
        String[] blockEnd, String[] splitters, boolean includeSplitter)
focal_class.identifier: split
focal_class.modifiers: public static
focal_class.parameters: (String str, String escapeSeq, char escapeChar, String[] blockStart,
        String[] blockEnd, String[] splitters, boolean includeSplitter)
focal_class.return: String[]
focal_class.signature: String[] split(String str, String escapeSeq, char escapeChar, String[] blockStart,
        String[] blockEnd, String[] splitters, boolean includeSplitter)
focal_class.class_method_signature: Input.getBlockStr(String blockDef)
focal_class.full_signature: private static String getBlockStr(String blockDef)
focal_class.identifier: getBlockStr
focal_class.modifiers: private static
focal_class.parameters: (String blockDef)
focal_class.return: String
focal_class.signature: String getBlockStr(String blockDef)
focal_class.class_method_signature: Input.isNestedBlock(String blockDef)
focal_class.full_signature: private static boolean isNestedBlock(String blockDef)
focal_class.identifier: isNestedBlock
focal_class.modifiers: private static
focal_class.parameters: (String blockDef)
focal_class.return: boolean
focal_class.signature: boolean isNestedBlock(String blockDef)
focal_method.body: public static String getSimpleQuery(Map<String, Object> params, String script) {
      String replaced = script;
  
      Matcher match = VAR_PTN.matcher(replaced);
      while (match.find()) {
        Input input = getInputForm(match);
        Object value;
        if (params.containsKey(input.name)) {
          value = params.get(input.name);
        } else {
          value = input.defaultValue;
        }
  
        String expanded;
        if (value instanceof Object[] || value instanceof Collection) {  // multi-selection
          String delimiter = input.argument;
          if (delimiter == null) {
            delimiter = DEFAULT_DELIMITER;
          }
          Collection<Object> checked = value instanceof Collection ? (Collection<Object>) value
                  : Arrays.asList((Object[]) value);
          List<Object> validChecked = new LinkedList<>();
          for (Object o : checked) {  // filter out obsolete checked values
            for (ParamOption option : input.getOptions()) {
              if (option.getValue().equals(o)) {
                validChecked.add(o);
                break;
              }
            }
          }
          params.put(input.name, validChecked);
          expanded = StringUtils.join(validChecked, delimiter);
        } else {  // single-selection
          expanded = value.toString();
        }
        replaced = match.replaceFirst(expanded);
        match = VAR_PTN.matcher(replaced);
      }
  
      return replaced;
    }
focal_method.class_method_signature: Input.getSimpleQuery(Map<String, Object> params, String script)
focal_method.full_signature: public static String getSimpleQuery(Map<String, Object> params, String script)
focal_method.identifier: getSimpleQuery
focal_method.invocations: matcher find getInputForm containsKey get asList getOptions equals getValue add put join toString replaceFirst matcher
focal_method.modifiers: public static
focal_method.parameters: (Map<String, Object> params, String script)
focal_method.return: String
focal_method.signature: String getSimpleQuery(Map<String, Object> params, String script)