# Business Logic — FUW00110SF01DBean.addListDataInstance() [76 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW00110SF.FUW00110SF01DBean` |
| Layer | View / Data-Binding Bean (Controller layer — webview DTO within the X33/Futurity framework) |
| Module | `FUW00110SF` (Package: `eo.web.webview.FUW00110SF`) |

## 1. Role

### FUW00110SF01DBean.addListDataInstance()

This method is a **list-item instance factory** for the X33/Futurity web view framework. It dynamically adds new data-bound elements to repeating table regions (repeat items) on a web screen. Each repeat item column type is identified by a string key (in Japanese), and the method dispatches to the appropriate per-column instantiation logic based on the column's data type and role.

The method handles four **service types** (repeat item categories):
- **Item Count** (項目数, `list_size`) — a Long-typed field tracking the number of rows in a repeating table section.
- **Select Index** (選択値, `sel_index`) — a Long-typed field for storing the currently selected row index in a dropdown/select control.
- **True Value** (項目実値, `true_value`) — a String-typed field for the raw data value of a cell.
- **Label Value** (項目ラベル, `label_value`) — a String-typed field for display labels shown alongside true values.

The method implements a **routing/dispatch pattern** using string-equality checks on the `key` parameter. It acts as a shared utility called by all view beans that extend this class — subclasses override this method and delegate to `super.addListDataInstance(key)` to reuse the base instantiation logic before applying subclass-specific behavior.

The design pattern is a **Builder + Factory**: it ensures the target list is initialized (lazy-instantiates `X33VDataTypeList` if null), enforces a maximum element count (preventing unbounded growth of repeating table rows), and returns the zero-based index of the newly appended element. If the key is unrecognized or the parameter is null, the method returns `-1` as a sentinel.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance String key"])
    
    START --> CHECK_NULL{key equals null}
    
    CHECK_NULL -->|Yes| RET_NULL([Return -1])
    
    CHECK_NULL -->|No| CHECK_ITEM{Item key match}
    
    CHECK_ITEM -->|item count| BLOCK_SIZE[Process list_size_list]
    CHECK_ITEM -->|select index| BLOCK_SEL[Process sel_index_list]
    CHECK_ITEM -->|true value| BLOCK_TV[Process true_value_list]
    CHECK_ITEM -->|label value| BLOCK_LV[Process label_value_list]
    CHECK_ITEM -->|other| RET_UNKNOWN([Return -1])
    
    BLOCK_SIZE --> INIT_SIZE{list_size_list is null}
    INIT_SIZE -->|Yes| CREATE_SIZE[Create X33VDataTypeList with initial LongBean]
    INIT_SIZE -->|No| CHECK_MAX_SIZE{At max capacity}
    CREATE_SIZE --> CHECK_MAX_SIZE
    
    CHECK_MAX_SIZE -->|No| ADD_SIZE[Create LongBean and add to list_size_list]
    CHECK_MAX_SIZE -->|Yes| THROW_SIZE[Throw ERRS_CANNOT_ADD_REPEATITEM]
    
    ADD_SIZE --> RET_SIZE([Return list_size_list size minus 1])
    THROW_SIZE --> RET_SIZE
    
    BLOCK_SEL --> INIT_SEL{sel_index_list is null}
    INIT_SEL -->|Yes| CREATE_SEL[Create X33VDataTypeList with initial LongBean]
    INIT_SEL -->|No| CHECK_MAX_SEL{At max capacity}
    CREATE_SEL --> CHECK_MAX_SEL
    
    CHECK_MAX_SEL -->|No| ADD_SEL[Create LongBean and add to sel_index_list]
    CHECK_MAX_SEL -->|Yes| THROW_SEL[Throw ERRS_CANNOT_ADD_REPEATITEM]
    
    ADD_SEL --> RET_SEL([Return sel_index_list size minus 1])
    THROW_SEL --> RET_SEL
    
    BLOCK_TV --> INIT_TV{true_value_list is null}
    INIT_TV -->|Yes| CREATE_TV[Create new X33VDataTypeList]
    INIT_TV -->|No| CONT_TV[Continue]
    CREATE_TV --> CONT_TV
    
    CONT_TV --> ADD_TV[Create StringBean set null and add to true_value_list]
    ADD_TV --> RET_TV([Return true_value_list size minus 1])
    
    BLOCK_LV --> INIT_LV{label_value_list is null}
    INIT_LV -->|Yes| CREATE_LV[Create new X33VDataTypeList]
    INIT_LV -->|No| CONT_LV[Continue]
    CREATE_LV --> CONT_LV
    
    CONT_LV --> ADD_LV[Create StringBean set null and add to label_value_list]
    ADD_LV --> RET_LV([Return label_value_list size minus 1])
    
    RET_NULL --> END([End])
    RET_UNKNOWN --> END
    RET_SIZE --> END
    RET_SEL --> END
    RET_TV --> END
    RET_LV --> END
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The repeat item column identifier (in Japanese). It determines which repeating table field is being extended. Valid values are: `"項目数"` (Item Count — row count tracker), `"選択値"` (Select Index — dropdown selection index), `"項目実値"` (True Value — raw cell data), `"項目ラベル"` (Label Value — display label). An unrecognized value returns `-1`. |

**Instance fields read:**

| No | Field Name | Type | Business Description |
|----|-----------|------|---------------------|
| 1 | `list_size_list` | `X33VDataTypeList` | List of Long beans tracking the number of rows per repeat-item section. Lazily initialized. |
| 2 | `sel_index_list` | `X33VDataTypeList` | List of Long beans storing the currently selected row index for dropdown/select controls within repeat items. |
| 3 | `true_value_list` | `X33VDataTypeList` | List of String beans holding the raw data values of cells in repeating table rows. |
| 4 | `label_value_list` | `X33VDataTypeList` | List of String beans holding display labels associated with cells in repeating table rows. |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `X33VDataTypeList.add` | JDKStructuredMap (framework) | - | Appends a new typed bean (Long or String) to the repeat-item data list. |
| U | `X33VDataTypeLongBean.setValue` | JDKStructuredMap (framework) | - | Sets the initial value `"0"` on newly created Long beans during lazy initialization. |
| U | `X33VDataTypeStringBean.setValue` | JDKStructuredMap (framework) | - | Sets the initial value `"null"` (literal string) on newly created String beans. |
| U | `X33VDataTypeList.getMaxElementCnt` | JDKStructuredMap (framework) | - | Queries the maximum allowed element count for the list to enforce capacity limits. |
| U | `X33VDataTypeList.size` | JDKStructuredMap (framework) | - | Queries the current element count for comparison against the maximum. |
| E | `X33VViewBaseBean.createExceptionForDataType` | Framework exception factory | - | Throws `ERRS_CANNOT_ADD_REPEATITEM` when a repeat-item list exceeds its maximum element count. |

**CRUD Classification:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `X33VDataTypeList.add(X33VDataTypeBeanInterface)` | Framework (X33) | - | Adds a new typed data bean instance to the in-memory list backing a repeating table column. |
| U | `X33VDataTypeLongBean.setValue(String)` | Framework (X33) | - | Assigns an initial value to a newly created Long-type data bean during lazy initialization. |
| U | `X33VDataTypeStringBean.setValue(String)` | Framework (X33) | - | Assigns the literal string `"null"` as the initial value to a newly created String-type data bean. |
| R | `X33VDataTypeList.getMaxElementCnt()` | Framework (X33) | - | Reads the configured maximum number of elements allowed in the repeat-item list. |
| R | `X33VDataTypeList.size()` | Framework (X33) | - | Reads the current number of elements in the repeat-item list for capacity-checking. |
| E | `X33VViewBaseBean.createExceptionForDataType(int)` | Framework (X33) | - | Factory method that creates a typed view exception (`ERRS_CANNOT_ADD_REPEATITEM`) when the maximum element count is exceeded. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:FUW00901 | `FUW00901SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 2 | Screen:FUW00907 | `FUW00907SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 3 | Screen:FUW00914 | `FUW00914SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 4 | Screen:FUW00916 | `FUW00916SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 5 | Screen:FUW00917 | `FUW00917SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 6 | Screen:FUW00919 | `FUW00919SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 7 | Screen:FUW00926 | `FUW00926SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 8 | Screen:FUW00927 | `FUW00927SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 9 | Screen:FUW00931 | `FUW00931SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 10 | Screen:FUW00946 | `FUW00946SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 11 | Screen:FUW00947 | `FUW00947SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 12 | Screen:FUW00957 | `FUW00957SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 13 | Screen:FUW00959 | `FUW00959SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 14 | Screen:FUW00961 | `FUW00961SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |
| 15 | Screen:FUW00964 | `FUW00964SFBean.addListDataInstance(key)` -> `super.addListDataInstance(key)` -> `FUW00110SF01DBean.addListDataInstance` | Framework X33V list operations |

**Note:** No code in this codebase directly calls `FUW00110SF01DBean.addListDataInstance(key)` from a non-subclass. The method is defined as the canonical base implementation in `FUW00110SF01DBean`, and is invoked via polymorphism — subclasses override `addListDataInstance` and delegate to `super.addListDataInstance(key)` to reuse the base instantiation logic before applying screen-specific repeat-item extensions.

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(key == null)` (L572)

> Null guard: if the key parameter is null, return immediately with `-1`. No state is modified.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // Return negative one when key is null — no item to process |

**Block 2** — ELSE-IF `(key.equals("項目数"))` `(list_size)` (L576)

> Handles the "Item Count" repeat-item column. This Long-typed field tracks the number of rows in a repeating table section. The method ensures the list is initialized and enforces a maximum element count.

| # | Type | Code |
|---|------|------|
| 1 | SET | `list_size_list = new X33VDataTypeList(1);` // Create the list if null — item count list initialization |
| 2 | SET | `tmpBean = new X33VDataTypeLongBean();` // Create a new Long-type bean |
| 3 | SET | `tmpBean.setValue("0");` // Set initial value to "0" — per data-type bean definition, generate initial-value setter processing [-> "0"] |
| 4 | CALL | `list_size_list.add(tmpBean);` // Add the initialized bean to the list |
| 5 | CALL | `list_size_list.getMaxElementCnt()` // Read maximum allowed element count |
| 6 | CALL | `list_size_list.size()` // Read current element count |
| 7 | SET | `tmpBean = new X33VDataTypeLongBean();` // Create a Long-type instance for the repeat item |
| 8 | CALL | `list_size_list.add(tmpBean);` // Append the new bean to the list |
| 9 | EXEC | `throw X33VViewBaseBean.createExceptionForDataType(X33VViewBaseBean.ERRS_CANNOT_ADD_REPEATITEM);` // Throw exception when max element count exceeded —異常通知 |
| 10 | RETURN | `return list_size_list.size() - 1;` // Return zero-based index of the newly added element |

**Block 2.1** — NESTED IF `(list_size_list == null)` (L578)

> Lazy initialization: if the list has not been created yet, create a new `X33VDataTypeList` with capacity 1 and populate it with one initial Long bean set to `"0"`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `list_size_list = new X33VDataTypeList(1);` // Create new empty instance if list is null — リストがnullの場合、新しい空のインスタンスを生成 |
| 2 | SET | `tmpBean = new X33VDataTypeLongBean();` // Instantiate a new Long bean |
| 3 | SET | `tmpBean.setValue("0");` // Set initial value — データ型項目定義ビューで初期値の指定がある場合は、初期値設定処理を生成 |
| 4 | CALL | `list_size_list.add(tmpBean);` // Add to the list |

**Block 2.2** — NESTED IF `(list_size_list.getMaxElementCnt() == 0 \|\| list_size_list.size() < list_size_list.getMaxElementCnt())` (L587)

> Capacity check: allow the addition if max capacity is unlimited (0) or the current size is below the max. Otherwise, throw an exception.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpBean = new X33VDataTypeLongBean();` // Create a new Long-type bean for the repeat item — 型繰り返し項目には、LongBeanのインスタンスを生成 |
| 2 | CALL | `list_size_list.add(tmpBean);` // Append the new instance |
| 3 | EXEC | `throw X33VViewBaseBean.createExceptionForDataType(X33VViewBaseBean.ERRS_CANNOT_ADD_REPEATITEM);` // Exception notification — 異常通知 |
| 4 | RETURN | `return list_size_list.size() - 1;` // Return the index of the added element |

**Block 3** — ELSE-IF `(key.equals("選択値"))` `(sel_index)` (L597)

> Handles the "Select Index" repeat-item column. This Long-typed field stores the currently selected row index within dropdown/select controls in a repeating table. Processing is structurally identical to Block 2 (Item Count) but operates on `sel_index_list`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sel_index_list = new X33VDataTypeList(1);` // Create the list if null |
| 2 | SET | `tmpBean = new X33VDataTypeLongBean();` |
| 3 | SET | `tmpBean.setValue("0");` // Set initial value |
| 4 | CALL | `sel_index_list.add(tmpBean);` |
| 5 | SET | `tmpBean = new X33VDataTypeLongBean();` // Create Long bean for the repeat item |
| 6 | CALL | `sel_index_list.add(tmpBean);` // Append to list |
| 7 | EXEC | `throw X33VViewBaseBean.createExceptionForDataType(X33VViewBaseBean.ERRS_CANNOT_ADD_REPEATITEM);` // Exception on capacity exceeded |
| 8 | RETURN | `return sel_index_list.size() - 1;` // Return zero-based index |

**Block 3.1** — NESTED IF `(sel_index_list == null)` (L599)

> Lazy initialization for the select index list — identical logic to Block 2.1.

| # | Type | Code |
|---|------|------|
| 1 | SET | `sel_index_list = new X33VDataTypeList(1);` // New empty instance if null — 新しい空のインスタンスを生成 |
| 2 | SET | `tmpBean = new X33VDataTypeLongBean();` |
| 3 | SET | `tmpBean.setValue("0");` // Initial value setup |
| 4 | CALL | `sel_index_list.add(tmpBean);` |

**Block 3.2** — NESTED IF `(sel_index_list.getMaxElementCnt() == 0 \|\| sel_index_list.size() < sel_index_list.getMaxElementCnt())` (L608)

> Capacity check identical to Block 2.2 — same business logic for the select index list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpBean = new X33VDataTypeLongBean();` // Create new Long bean |
| 2 | CALL | `sel_index_list.add(tmpBean);` // Add to list |
| 3 | EXEC | `throw X33VViewBaseBean.createExceptionForDataType(X33VViewBaseBean.ERRS_CANNOT_ADD_REPEATITEM);` // Exception on max |
| 4 | RETURN | `return sel_index_list.size() - 1;` // Return index |

**Block 4** — ELSE-IF `(key.equals("項目実値"))` `(true_value)` (L616)

> Handles the "True Value" repeat-item column. This String-typed field holds the raw data value of a cell in a repeating table. Unlike the Long-typed columns (Block 2 and 3), the True Value column does NOT enforce a maximum element count — it simply creates a new `X33VDataTypeList()` on first access and always allows new elements.

| # | Type | Code |
|---|------|------|
| 1 | SET | `true_value_list = new X33VDataTypeList();` // Create the list if null — リストがnullの場合、新しい空のインスタンスを生成 |
| 2 | SET | `tmpBean = new X33VDataTypeStringBean();` // Instantiate a String bean per data-type bean view — データ型ビューで指定したデータ型ビューンのインスタンスを生成 |
| 3 | SET | `tmpBean.setValue("null");` // Set literal string "null" as initial value — データ型項目定義ビューで初期値の指定がある場合は、初期値設定処理を生成 |
| 4 | CALL | `true_value_list.add(tmpBean);` // Append the new String bean |
| 5 | RETURN | `return true_value_list.size() - 1;` // Return zero-based index |

**Block 4.1** — NESTED IF `(true_value_list == null)` (L618)

> Lazy initialization for the true value list. Creates a new `X33VDataTypeList()` with default constructor (no initial capacity argument).

| # | Type | Code |
|---|------|------|
| 1 | SET | `true_value_list = new X33VDataTypeList();` // Create new empty instance — 新しい空のインスタンスを生成 |

**Block 5** — ELSE-IF `(key.equals("項目ラベル"))` `(label_value)` (L625)

> Handles the "Label Value" repeat-item column. This String-typed field holds display labels shown alongside true values in a repeating table. Processing is structurally identical to Block 4 (True Value) but operates on `label_value_list`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `label_value_list = new X33VDataTypeList();` // Create the list if null |
| 2 | SET | `tmpBean = new X33VDataTypeStringBean();` // Create String bean |
| 3 | SET | `tmpBean.setValue("null");` // Set literal "null" initial value |
| 4 | CALL | `label_value_list.add(tmpBean);` // Append to list |
| 5 | RETURN | `return label_value_list.size() - 1;` // Return zero-based index |

**Block 5.1** — NESTED IF `(label_value_list == null)` (L627)

> Lazy initialization for the label value list — identical to Block 4.1.

| # | Type | Code |
|---|------|------|
| 1 | SET | `label_value_list = new X33VDataTypeList();` // Create new empty instance — 新しい空のインスタンスを生成 |

**Block 6** — ELSE (L633)

> Fallback: no matching key was found. Return `-1` as an unrecognized-key indicator.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // Return -1 when no matching item exists — 該当する項目がない場合、-1を返す |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `list_size_list` | Field | Item count list — in-memory list of Long beans tracking the number of rows in each repeating table section. |
| `sel_index_list` | Field | Select index list — in-memory list of Long beans storing the currently selected row index for dropdown/select controls. |
| `true_value_list` | Field | True value list — in-memory list of String beans holding the raw data values of cells in repeating table rows. |
| `label_value_list` | Field | Label value list — in-memory list of String beans holding display labels associated with cells. |
| 項目数 | Field (Japanese) | Item Count — the number of rows in a repeating table section. Also known as `list_size`. |
| 選択値 | Field (Japanese) | Select Index / Selected Value — the currently selected row index in a dropdown or select control within a repeating table. |
| 項目実値 | Field (Japanese) | True Value — the raw, unformatted data value of a cell in a repeating table row. |
| 項目ラベル | Field (Japanese) | Label Value — the human-readable display label associated with a cell, as opposed to its raw data value. |
| X33 | Acronym | Fujitsu Futurity X33 — the enterprise web application framework providing the view bean infrastructure. |
| Futurity | Acronym | Fujitsu's enterprise Java web application platform (parent product line of X33). |
| X33VDataTypeList | Class | Framework list wrapper that manages a typed collection of view data beans (Long, String, Boolean). Used for repeating table columns. |
| X33VDataTypeLongBean | Class | Framework data bean wrapping a Long-type value. Used for item count and select index columns. |
| X33VDataTypeStringBean | Class | Framework data bean wrapping a String-type value. Used for true value and label value columns. |
| X33VViewBaseBean | Class | Base view bean class in the X33 framework. Provides utility methods like `createExceptionForDataType` for generating typed view exceptions. |
| X33SException | Class | X33 framework checked exception type. This method declares `throws X33SException`. |
| ERRS_CANNOT_ADD_REPEATITEM | Constant | Framework error code constant indicating that a repeating table column has exceeded its maximum allowed element count. |
| MaxElementCnt | Concept | Maximum element count — a configurable upper bound on the number of rows in a repeating table column. `0` indicates no limit. |
| X33VListedBeanInterface | Interface | X33 framework interface marking a bean as supporting listed (repeating table) data binding. |
| X33VDataTypeBeanInterface | Interface | X33 framework interface marking a bean as a typed data value holder. |
| Repeat Item | Business term | A repeating table region on a web screen. Data for each column within a repeat item is stored in a separate `X33VDataTypeList`. |
| SC | Acronym | Service Component — a service-layer class that encapsulates business logic and database operations. |
| CBS | Acronym | Common Business Service — a shared service component used across multiple screens or modules. |
| DBean | Acronym | Data Bean — a view-layer DTO (Data Transfer Object) that binds data between the web UI and backend services. |
| FUW | Acronym | Front-End Web — module naming prefix for web-facing screen definition classes. |
