---
title: "Business Logic — KKW00127SF02DBean.addListDataInstance() [50 LOC]"
tags: [dd, bean, list-data, instance-generation]
---

# Business Logic — KKW00127SF02DBean.addListDataInstance() [50 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00127SF.KKW00127SF02DBean` |
| Layer | Utility / Data Bean (Web tier data container managed by the X33 framework) |
| Module | `KKW00127SF` (Package: `eo.web.webview.KKW00127SF`) |

## 1. Role

### KKW00127SF02DBean.addListDataInstance()

This method is a **repeating-item instance factory** within the X33 web framework's data bean architecture. It generates and manages instances of `X33VDataTypeStringBean` objects for two specific repeating (multi-valued) list fields: **Service Contract Status List** (`svc_kei_stat_lis`) and **Referral Code List** (`intr_cd`). The method implements a **routing/dispatch pattern** — it inspects the string `key` parameter to determine which of the two list collections should receive a new element, and returns the index of the newly added element. It plays a central role in **dynamic list management** for web screens that render tabular repeating sections (e.g., a service contract status table or a referral code input table), ensuring that the underlying data structure always has capacity for one additional row and that lazy initialization is performed if the list has not yet been instantiated. If the key does not match any recognized list, or if the list has reached its maximum element count, the method either returns `-1` or throws an `X33SException` to signal that no more items can be added.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["addListDataInstance(key)"])
    KEY_NULL{"key == null"}
    KEY_STAT{"key equals
\"サービス契約ステータスリスト\""}
    KEY_INTR{"key equals
\"紹介コードリスト\""}
    INIT_STAT["Lazy init svc_kei_stat_lis_list if null"]
    CHECK_STAT["Check capacity: maxElementCnt==0 || size < maxElementCnt"]
    ADD_STAT["Add X33VDataTypeStringBean to svc_kei_stat_lis_list"]
    THROW_STAT["Throw X33SException (ERRS_CANNOT_ADD_REPEATITEM)"]
    RET_STAT["Return svc_kei_stat_lis_list.size() - 1"]
    INIT_INTR["Lazy init intr_cd_list_list if null"]
    CHECK_INTR["Check capacity: maxElementCnt==0 || size < maxElementCnt"]
    ADD_INTR["Add X33VDataTypeStringBean to intr_cd_list_list"]
    THROW_INTR["Throw X33SException (ERRS_CANNOT_ADD_REPEATITEM)"]
    RET_INTR["Return intr_cd_list_list.size() - 1"]
    RET_FALLBACK["Return -1 (no matching key)"]
    END_NODE(["End"])

    START --> KEY_NULL
    KEY_NULL -->|true| END_NODE
    KEY_NULL -->|false| KEY_STAT
    KEY_STAT -->|true| INIT_STAT
    KEY_STAT -->|false| KEY_INTR
    KEY_INTR -->|true| INIT_INTR
    KEY_INTR -->|false| RET_FALLBACK
    RET_FALLBACK --> END_NODE
    INIT_STAT --> CHECK_STAT
    CHECK_STAT -->|true| ADD_STAT
    CHECK_STAT -->|false| THROW_STAT
    THROW_STAT --> END_NODE
    ADD_STAT --> RET_STAT
    RET_STAT --> END_NODE
    INIT_INTR --> CHECK_INTR
    CHECK_INTR -->|true| ADD_INTR
    CHECK_INTR -->|false| THROW_INTR
    THROW_INTR --> END_NODE
    ADD_INTR --> RET_INTR
    RET_INTR --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The list item identifier that determines which repeating list collection should receive a new element. Accepts one of two Japanese string literals: `"サービス契約ステータスリスト"` (Service Contract Status List) for the service contract status data, or `"紹介コードリスト"` (Referral Code List) for referral code entries. If `null`, the method returns `-1` immediately. If the value does not match either known list, the method returns `-1` at the end. |
| — | `svc_kei_stat_lis_list` | `X33VDataTypeList` | Instance field (read/write). The underlying list holding `X33VDataTypeStringBean` instances for service contract status data. Lazily initialized on first access if null. |
| — | `intr_cd_list_list` | `X33VDataTypeList` | Instance field (read/write). The underlying list holding `X33VDataTypeStringBean` instances for referral code data. Lazily initialized on first access if null. |

## 4. CRUD Operations / Called Services

This method does **not** call any external services, SC codes, or CBS codes. It operates entirely within the data bean layer, managing in-memory collection state.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | *(none)* | — | — | No external service or database calls. This method is purely an in-memory list management utility. |

## 5. Dependency Trace

No callers were found in the codebase. This method is a standard X33 framework bean utility method that is typically invoked programmatically by screen controllers or the framework itself during dynamic list rendering, but no direct call sites are present in the scanned Java files.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| — | *(no callers found)* | — | — |

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(key == null)` (L899)

> Null guard: if the key is null, return -1 immediately.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(key == null)` |
| 2 | RETURN | `return -1;` // Return -1 if key is null (keyがnullの場合、-1で返す) |

**Block 2** — [ELSE-IF] `(key.equals("サービス契約ステータスリスト"))` [Services Contract Status List] (L903)

> Service Contract Status List branch: manages the `svc_kei_stat_lis_list` repeating list for service contract status data.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(svc_kei_stat_lis_list == null)` // List is null, generate new empty instance (リストがnullの場合、新しい空のインスタンスを生成する) |
| 2 | SET | `svc_kei_stat_lis_list = new X33VDataTypeList(1);` // Create a new list with max capacity of 1 |
| 3 | FOR | `for(int i=0; i<1; i++)` |
| 4 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` // Create String-type repeating item bean |
| 5 | EXEC | `svc_kei_stat_lis_list.add(tmpBean);` |
| 6 | IF | `if(svc_kei_stat_lis_list.getMaxElementCnt() == 0 || svc_kei_stat_lis_list.size() < svc_kei_stat_lis_list.getMaxElementCnt())` // Check if MAX element count allows addition (MAX要素数以上の追加は許されない処理) |
| 7 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` // Generate X33VDataTypeStringBean instance for String-type repeating item (String型繰り返し項目には、X33VDataTypeStringBeanのインスタンスを生成する) |
| 8 | EXEC | `svc_kei_stat_lis_list.add(tmpBean);` |
| 9 | ELSE | *(else — capacity exceeded)* |
| 10 | THROW | `throw X33VViewBaseBean.createExceptionForDataType(X33VViewBaseBean.ERRS_CANNOT_ADD_REPEATITEM);` // Exception notification (異常通知) |
| 11 | RETURN | `return svc_kei_stat_lis_list.size() - 1;` // Return the index of the newly added element |

**Block 2.1** — [nested IF] `(svc_kei_stat_lis_list == null)` (L903)

> Lazy initialization: if the list is null, create it with one pre-initialized bean.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svc_kei_stat_lis_list = new X33VDataTypeList(1);` |
| 2 | FOR | `for(int i=0; i<1; i++)` |
| 3 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 4 | EXEC | `svc_kei_stat_lis_list.add(tmpBean);` |

**Block 2.2** — [nested IF] `(svc_kei_stat_lis_list.getMaxElementCnt() == 0 \|\| svc_kei_stat_lis_list.size() < svc_kei_stat_lis_list.getMaxElementCnt())` (L911)

> Capacity check: allowed if maxElementCnt is 0 (unlimited) or current size is below max.

| # | Type | Code |
|---|------|------|
| 1 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 2 | EXEC | `svc_kei_stat_lis_list.add(tmpBean);` |

**Block 2.3** — [nested ELSE] `(capacity exceeded)` (L915)

> Error handling: throw an exception when the repeating list has reached its maximum element count.

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw X33VViewBaseBean.createExceptionForDataType(X33VViewBaseBean.ERRS_CANNOT_ADD_REPEATITEM);` // Exception notification (異常通知) |

**Block 3** — [ELSE-IF] `(key.equals("紹介コードリスト"))` [Referral Code List] (L921)

> Referral Code List branch: manages the `intr_cd_list_list` repeating list for referral code data. Structurally identical to Block 2 but operates on a different list field.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(intr_cd_list_list == null)` // List is null, generate new empty instance (リストがnullの場合、新しい空のインスタンスを生成する) |
| 2 | SET | `intr_cd_list_list = new X33VDataTypeList(1);` |
| 3 | FOR | `for(int i=0; i<1; i++)` |
| 4 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 5 | EXEC | `intr_cd_list_list.add(tmpBean);` |
| 6 | IF | `if(intr_cd_list_list.getMaxElementCnt() == 0 || intr_cd_list_list.size() < intr_cd_list_list.getMaxElementCnt())` // Check if MAX element count allows addition (MAX要素数以上の追加は許されない処理) |
| 7 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` // Generate X33VDataTypeStringBean instance for String-type repeating item |
| 8 | EXEC | `intr_cd_list_list.add(tmpBean);` |
| 9 | ELSE | *(else — capacity exceeded)* |
| 10 | THROW | `throw X33VViewBaseBean.createExceptionForDataType(X33VViewBaseBean.ERRS_CANNOT_ADD_REPEATITEM);` // Exception notification (異常通知) |
| 11 | RETURN | `return intr_cd_list_list.size() - 1;` // Return the index of the newly added element |

**Block 3.1** — [nested IF] `(intr_cd_list_list == null)` (L921)

> Lazy initialization for referral code list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `intr_cd_list_list = new X33VDataTypeList(1);` |
| 2 | FOR | `for(int i=0; i<1; i++)` |
| 3 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 4 | EXEC | `intr_cd_list_list.add(tmpBean);` |

**Block 3.2** — [nested IF] `(intr_cd_list_list.getMaxElementCnt() == 0 \|\| intr_cd_list_list.size() < intr_cd_list_list.getMaxElementCnt())` (L929)

> Capacity check for referral code list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();` |
| 2 | EXEC | `intr_cd_list_list.add(tmpBean);` |

**Block 3.3** — [nested ELSE] `(capacity exceeded)` (L933)

> Error handling for referral code list.

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw X33VViewBaseBean.createExceptionForDataType(X33VViewBaseBean.ERRS_CANNOT_ADD_REPEATITEM);` // Exception notification (異常通知) |

**Block 4** — [FALLBACK RETURN] (L938)

> No matching key: returns -1 indicating no recognized list was found.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return -1;` // No matching key, return -1 (該当する項目がない場合、-1を返す) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_stat_lis_list` | Field | Service Contract Status List — repeating list of service contract status data items stored as String-type bean instances |
| `intr_cd_list_list` | Field | Referral Code List — repeating list of referral code data items stored as String-type bean instances |
| X33VDataTypeList | Class | X33 Framework list data type — a framework-managed collection of typed bean instances |
| X33VDataTypeStringBean | Class | X33 Framework String data type bean — a value holder for a single String-type repeating item |
| X33VViewBaseBean | Class | X33 Framework view base bean — base class providing utility methods for view-layer data type management |
| X33SException | Class | X33 Framework service exception — checked exception used to signal processing errors |
| ERRS_CANNOT_ADD_REPEATITEM | Constant | Error code constant indicating that a repeating item cannot be added (list is at maximum capacity) |
| `サービス契約ステータスリスト` | Japanese key | "Service Contract Status List" — the key identifying the service contract status repeating list |
| `紹介コードリスト` | Japanese key | "Referral Code List" — the key identifying the referral code repeating list |
| `リスト項目のインスタンスを生成します` | Japanese javadoc | "Generates an instance of a list item" |
| `繰り返し項目` | Japanese comment | "Repeating item" — a multi-valued field in the X33 framework that can hold multiple rows |
| `固定要素数指定` | Japanese comment | "Fixed element count specification" — the process of managing lists with a defined maximum number of elements |
| `異常通知` | Japanese comment | "Exception notification" — signaling an error condition to the caller |
| MAX要素数 | Japanese comment | "Maximum element count" — the upper limit on the number of elements in a repeating list |
| `該当する項目がない場合` | Japanese comment | "If no matching item exists" — fallback condition when the key does not match any known list |
