このバージョンはまだ開発中であり、まだ安定しているとは見なされていません。最新の安定バージョンについては、Spring Shell 3.4.1 を使用してください! |
数値入力
数値入力コンポーネントは、ユーザーに単純な数値入力を求めます。Number.class の任意の実装を使用するように設定できます。次のリストに例を示します。
NumberInput component = new NumberInput(getTerminal(), "Enter value", 99.9, Double.class);
ResourceLoader resourceLoader = null; // getResourceLoader();
TemplateExecutor templateExecutor = null; // getTemplateExecutor();
component.setResourceLoader(resourceLoader);
component.setTemplateExecutor(templateExecutor);
NumberInputContext context = component.run(NumberInputContext.empty());
return "Got value " + context.getResultValue();The following image shows typical output from a number input component:
コンテキストオブジェクトは NumberInputContext です。次の表に、そのコンテキスト変数を示します。
| キー | 説明 |
|---|---|
| 設定されている場合のデフォルト値。それ以外の場合は null。 |
| The default number class to use, if set. Otherwise, Integer.class. |
|
|
| 親コンテキスト変数 ( TextComponentContext テンプレート変数を参照)。 |