# Business Logic — KKW00127SF01DBean.loadModelData() [77 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00127SF.KKW00127SF01DBean` |
| Layer | Web (View Data Bean — `eo.web.webview` package) |
| Module | `KKW00127SF` (Package: `eo.web.webview.KKW00127SF`) |

## 1. Role

### KKW00127SF01DBean.loadModelData()

This method serves as a **unified data access dispatcher** for the web view data model of the KKW00127SF screen module. It implements a key-subkey routing pattern where the `key` parameter determines which data domain is being queried, and the `subkey` parameter identifies the specific data point within that domain.

Three business data domains are supported:

1. **Index Data** — When `key` is "替え字" (Replacement Character), the method delegates to `getIndex_value()` or `getIndex_state()` to retrieve the index value or state. This is used to track replacement character index information on the screen.

2. **Code List** — When `key` is "コードリスト" (Code List), the method accesses elements from the `cd_div_list_list` collection (a list of `X33VDataTypeStringBean` objects). It supports wildcard access via "*" (returns list size) or numeric index access (returns data from the specified list element). The item ID for this list is `cd_div_list`.

3. **Code Name List** — When `key` is "コード名リスト" (Code Name List), the method accesses elements from the `cd_div_nm_list_list` collection (a list of `X33VDataTypeStringBean` objects). It follows the same wildcard/numeric index pattern. The item ID for this list is `cd_div_nm`.

The method acts as a **shared utility within the DBean** — it is overloaded with a no-argument version and is also called internally by other DBeans within the KKW00127SF screen module (e.g., `KKW00127SFBean` calls similar `loadModelData` on list element beans to retrieve item values). Its role in the larger system is to provide a consistent, type-safe key-value data retrieval mechanism that the JSP view layer can use to extract model data without directly accessing internal collections.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["loadModelData"])
    START --> CNULL["key/subkey is null?"]
    CNULL -- Yes --> RNULL1["Return null"]
    CNULL -- No --> FINDSEP["sepIdx = key.indexOf('/')"]
    FINDSEP --> C1["key equals 替え字?"]
    C1 -- Yes --> C1S["subkey equals value?"]
    C1S -- Yes --> RVAL["Return getIndex_value()"]
    C1S -- No --> C1T["subkey equals state?"]
    C1T -- Yes --> RSTATE["Return getIndex_state()"]
    C1T -- No --> C2["key equals コードリスト?"]
    C1 -- No --> C2
    C2 -- Yes --> SPLIT1["key = key.substring(sepIdx + 1)"]
    SPLIT1 --> CSTAR1["key equals *?"]
    CSTAR1 -- Yes --> RCOUNT1["Return cd_div_list_list.size()"]
    CSTAR1 -- No --> TRY1["tmpIndexInt = Integer.valueOf(key)"]
    TRY1 --> ERR1{NumberFormatException?}
    ERR1 -- Yes --> RNULL2["Return null"]
    ERR1 -- No --> C2B["tmpIndexInt == null"]
    C2B -- Yes --> RNULL3["Return null"]
    C2B -- No --> R1B["tmpIndex = tmpIndexInt.intValue()"]
    R1B --> C2C["index out of bounds?"]
    C2C -- Yes --> RNULL4["Return null"]
    C2C -- No --> G1["Get X33VDataTypeStringBean from cd_div_list_list"]
    G1 --> CALL1["Call loadModelData(subkey)"]
    CALL1 --> RD1["Return result"]
    C2 -- No --> C3["key equals コード名リスト?"]
    C3 -- Yes --> SPLIT2["key = key.substring(sepIdx + 1)"]
    SPLIT2 --> CSTAR2["key equals *?"]
    CSTAR2 -- Yes --> RCOUNT2["Return cd_div_nm_list_list.size()"]
    CSTAR2 -- No --> TRY2["tmpIndexInt = Integer.valueOf(key)"]
    TRY2 --> ERR2{NumberFormatException?}
    ERR2 -- Yes --> RNULL5["Return null"]
    ERR2 -- No --> C3B["tmpIndexInt == null"]
    C3B -- Yes --> RNULL6["Return null"]
    C3B -- No --> R2B["tmpIndex = tmpIndexInt.intValue()"]
    R2B --> C3C["index out of bounds?"]
    C3C -- Yes --> RNULL7["Return null"]
    C3C -- No --> G2["Get X33VDataTypeStringBean from cd_div_nm_list_list"]
    G2 --> CALL2["Call loadModelData(subkey)"]
    CALL2 --> RD2["Return result"]
    C3 -- No --> RNULL8["Return null - no match"]
    RNULL1 --> END(["End"])
    RVAL --> END
    RSTATE --> END
    RNULL2 --> END
    RNULL3 --> END
    RNULL4 --> END
    RD1 --> END
    RCOUNT1 --> END
    RNULL5 --> END
    RNULL6 --> END
    RNULL7 --> END
    RD2 --> END
    RCOUNT2 --> END
    RNULL8 --> END
```

**Processing flow summary:**

1. **Null check** (L148–150): If either `key` or `subkey` is null, return `null` immediately.
2. **Separator detection** (L152): Search for `/` in `key` to locate the delimiter for sub-key routing (used by list-type keys).
3. **Branch 1 — Index Data** (L155–163): If `key` equals "替え字" (Replacement Character), branch on `subkey`:
   - "value" → delegate to `getIndex_value()` (L157–158)
   - "state" → delegate to `getIndex_state()` (L161–162)
4. **Branch 2 — Code List** (L165–197): If `key` equals "コードリスト" (Code List):
   - Extract sub-key by removing prefix up to `/` (L167)
   - If sub-key is "*", return list size (L169–170)
   - Parse sub-key as integer index with `NumberFormatException` handling (L173–180)
   - Validate index bounds against `cd_div_list_list` (L185–187)
   - Retrieve `X33VDataTypeStringBean` at the index and delegate `loadModelData(subkey)` (L191–192)
5. **Branch 3 — Code Name List** (L195–216): If `key` equals "コード名リスト" (Code Name List):
   - Same pattern as Branch 2 but operates on `cd_div_nm_list_list` (L197–216)
6. **Fallback** (L213–214): If no branch matches, return `null`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The business data domain identifier. Determines which data source is queried. Can be "替え字" (Replacement Character — index data), "コードリスト" (Code List — item ID `cd_div_list`), or "コード名リスト" (Code Name List — item ID `cd_div_nm`). For list-type keys, a `/` delimiter separates the domain name from the sub-key (e.g., "コードリスト/0"). |
| 2 | `subkey` | `String` | The specific data point within the selected domain. For index data, it is "value" or "state". For list types, it is either "*" (requesting list element count) or a numeric index string (e.g., "0", "1") referencing an element in the list collection. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `cd_div_list_list` | `List` | Collection of code list data beans — each element is an `X33VDataTypeStringBean` representing a code entry with item ID `cd_div_list`. |
| `cd_div_nm_list_list` | `List` | Collection of code name list data beans — each element is an `X33VDataTypeStringBean` representing a code name entry with item ID `cd_div_nm`. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `KKW00127SF01DBean.getIndex_value` | KKW00127SF01DBean | - | Reads index value data via `getIndex_value()` in the same DBean |
| R | `KKW00127SF01DBean.getIndex_state` | KKW00127SF01DBean | - | Reads index state data via `getIndex_state()` in the same DBean |
| R | `KKW00127SF01DBean.loadModelData` | KKW00127SF01DBean | - | Recursively delegates to `loadModelData(subkey)` on child `X33VDataTypeStringBean` elements (list access) |
| - | `String.indexOf` | java.lang | - | Searches for `/` delimiter in `key` |
| - | `String.substring` | java.lang | - | Extracts sub-key portion after the `/` delimiter |
| - | `String.equalsIgnoreCase` | java.lang | - | Case-insensitive comparison of `subkey` against "value" or "state" |
| - | `String.equals` | java.lang | - | Exact string comparison of `key` against domain identifiers |
| - | `Integer.valueOf` | java.lang | - | Parses sub-key string to integer index |
| - | `List.size` | java.util | - | Retrieves the size of `cd_div_list_list` or `cd_div_nm_list_list` |
| - | `List.get` | java.util | - | Retrieves an `X33VDataTypeStringBean` at a specific list index |

**Classification rationale:**

This method is a **pure read accessor** — it performs zero create/update/delete operations. It reads from:
- Local instance fields (`cd_div_list_list`, `cd_div_nm_list_list`)
- Delegate methods within the same DBean (`getIndex_value()`, `getIndex_state()`)
- Child bean's `loadModelData()` for nested data access in list elements

There are no Service Component (SC) or CBS calls — this method operates entirely at the **web view data bean layer**, providing data retrieval for the presentation layer without touching business logic or the database.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Internal DBean: KKW00127SF01DBean | `KKW00127SF01DBean.loadModelData()` (no-arg overload) -> `KKW00127SF01DBean.loadModelData(String key, String subkey)` | `getIndex_value() [R]` · `getIndex_state() [R]` · `X33VDataTypeStringBean.loadModelData(subkey) [R]` |
| 2 | Screen: KKW00127SF (KKW00127SFBean) | `KKW00127SFBean` -> (loop over list beans) -> `(X33VDataTypeStringBean).loadModelData(subkey)` (delegated to list elements) | `getXxx(value) [R]` per list element |
| 3 | Screen: KKW00127SF (KKW00127SFBean) | `KKW00127SFBean` -> `payway_hktgi_list_list[i].loadModelData("支払方法引継リスト", "value")` | `X33VDataTypeBeanInterface.loadModelData [R]` |
| 4 | Screen: KKW00127SF (KKW00127SFBean) | `KKW00127SFBean` -> `svc_naiyo_hktgi_list_list[i].loadModelData("サービス内容引継リスト", "value")` | `X33VDataTypeBeanInterface.loadModelData [R]` |
| 5 | Screen: KKW00127SF (KKW00127SFBean) | `KKW00127SFBean` -> `dsl_shorui_sohu_list_list[i].loadModelData("解約書類の送付リスト", "value")` | `X33VDataTypeBeanInterface.loadModelData [R]` |
| 6 | Screen: KKW00127SF (KKW00127SFBean) | `KKW00127SFBean` -> `jimu_commision_list_list[i].loadModelData("事務手数料（追加金）リスト", "value")` | `X33VDataTypeBeanInterface.loadModelData [R]` |
| 7 | Screen: KKW00127SF (KKW00127SFBean) | `KKW00127SFBean` -> `stdard_koji_hi_lsit_list[i].loadModelData("標準工事費リスト", "value")` | `X33VDataTypeBeanInterface.loadModelData [R]` |
| 8 | Screen: KKW00127SF (KKW00127SFBean) | `KKW00127SFBean` -> `bundle_info_lsit_list[i].loadModelData("バンドル情報リスト", "value")` | `X33VDataTypeBeanInterface.loadModelData [R]` |

**Note:** The pre-computed caller table indicates that the no-argument overload `loadModelData()` within `KKW00127SF01DBean` calls this two-argument version. The `KKW00127SFBean` (screen bean) also calls similar `loadModelData` on individual list element beans to extract item values — these are delegations through the same `X33VDataTypeBeanInterface` pattern.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF-NULL CHECK] `(key == null || subkey == null)` (L148–150)

> Null guard: if either parameter is null, return null immediately. Prevents null pointer exceptions on subsequent string operations.

| # | Type | Code |
|---|------|------|
| 1 | SET | `separaterPoint = key.indexOf("/")` |
| 2 | RETURN | `return null` // key or subkey is null (key, subkey がnullの場合、nullを返す) |

**Block 2** — [IF] `key.equals("替え字")` (L155–163)

> The "Replacement Character" (替え字) data domain. Retrieves index-related data. The comment indicates: 項目ごとに処理を入れる (Insert processing for each item).

**Block 2.1** — [IF-ELSE-IF] `subkey.equalsIgnoreCase("value")` (L157–158)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `getIndex_value()` // Return the index value ( getIndex_value を呼び出し) |
| 2 | RETURN | `return getIndex_value()` |

**Block 2.2** — [ELSE-IF] `subkey.equalsIgnoreCase("state")` (L161–162)

> When subkey is "state", return the state information.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `getIndex_state()` // subkey が"state"の場合、ステータスを返す (If subkey is "state", return status) |
| 2 | RETURN | `return getIndex_state()` |

**Block 3** — [ELSE-IF] `key.equals("コードリスト")` (L165–192)

> The "Code List" (コードリスト) data domain. This is a list-type item with item ID `cd_div_list`. Each element is an `X33VDataTypeStringBean`. The key format for indexed access is `"コードリスト/<index>"` or `"コードリスト/*"` for size.

**Block 3.1** — [SET] Extract sub-key from key (L167)

| # | Type | Code |
|---|------|------|
| 1 | SET | `key = key.substring(separaterPoint + 1)` // keyの次の要素を取得 (Get the next element of key) |

**Block 3.2** — [IF] `key.equals("*")` (L169–170)

> When "*" is specified as the index value, return the number of list elements.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cd_div_list_list.size()` // リストの要素数を返す (Return the number of list elements) |
| 2 | SET | `Integer.valueOf(cd_div_list_list.size())` |
| 3 | RETURN | `return Integer.valueOf(cd_div_list_list.size())` |

**Block 3.3** — [TRY-CATCH] Parse index as integer (L173–180)

> Attempt to parse the sub-key as an integer index. If parsing fails, return null.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpIndexInt = Integer.valueOf(key)` // リスト中のインデックスを見る (See the index in the list) |
| 2 | CATCH | `NumberFormatException e` // インデックス値が数値文字列でない場合はnullを返す (If index is not a numeric string, return null) |
| 3 | RETURN | `return null` |

**Block 3.4** — [IF] `tmpIndexInt == null` (L182–184)

> Additional null check after the try-catch block.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null` |

**Block 3.5** — [IF] `tmpIndex < 0 || tmpIndex >= cd_div_list_list.size()` (L185–187)

> Boundary check: if the index exceeds the list element count minus 1, return null.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpIndex = tmpIndexInt.intValue()` |
| 2 | RETURN | `return null` // インデックス値がリスト個数-1を超えた場合 (If index exceeds list count - 1) |

**Block 3.6** — [RETURN] Retrieve and delegate to child bean (L191–192)

> Get the X33VDataTypeStringBean at the specified index from `cd_div_list_list` and call its `loadModelData(subkey)` method to retrieve the requested data point.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cd_div_list_list.get(tmpIndex)` // Get bean at index |
| 2 | CAST | `(X33VDataTypeStringBean)` |
| 3 | CALL | `((X33VDataTypeStringBean)cd_div_list_list.get(tmpIndex)).loadModelData(subkey)` // Delegate subkey lookup to list element |
| 4 | RETURN | `return ...` |

**Block 4** — [ELSE-IF] `key.equals("コード名リスト")` (L195–216)

> The "Code Name List" (コード名リスト) data domain. This is a list-type item with item ID `cd_div_nm`. Each element is an `X33VDataTypeStringBean`. Uses the exact same pattern as Block 3 but operates on `cd_div_nm_list_list`.

**Block 4.1** — [SET] Extract sub-key from key (L197)

| # | Type | Code |
|---|------|------|
| 1 | SET | `key = key.substring(separaterPoint + 1)` // keyの次の要素を取得 (Get the next element of key) |

**Block 4.2** — [IF] `key.equals("*")` (L199–200)

> Return the number of elements in the code name list.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cd_div_nm_list_list.size()` |
| 2 | SET | `Integer.valueOf(cd_div_nm_list_list.size())` |
| 3 | RETURN | `return Integer.valueOf(cd_div_nm_list_list.size())` |

**Block 4.3** — [TRY-CATCH] Parse index as integer (L203–210)

> Same pattern as Block 3.3.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpIndexInt = Integer.valueOf(key)` |
| 2 | CATCH | `NumberFormatException e` |
| 3 | RETURN | `return null` |

**Block 4.4** — [IF] `tmpIndexInt == null` (L212–214)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null` |

**Block 4.5** — [IF] `tmpIndex < 0 || tmpIndex >= cd_div_nm_list_list.size()` (L215–217)

> Boundary check for code name list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tmpIndex = tmpIndexInt.intValue()` |
| 2 | RETURN | `return null` |

**Block 4.6** — [RETURN] Retrieve and delegate to child bean (L219–220)

> Get the `X33VDataTypeStringBean` at the specified index from `cd_div_nm_list_list` and call its `loadModelData(subkey)` method.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `cd_div_nm_list_list.get(tmpIndex)` |
| 2 | CAST | `(X33VDataTypeStringBean)` |
| 3 | CALL | `((X33VDataTypeStringBean)cd_div_nm_list_list.get(tmpIndex)).loadModelData(subkey)` |
| 4 | RETURN | `return ...` |

**Block 5** — [FALLBACK RETURN] (L213–214)

> If no branch matches the key, return null. The comment states: 条件に合致するプロパティが存在しない場合はnullを返す (If no property matching the condition exists, return null).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `key` | Parameter | Item name — the business data domain identifier used to route data retrieval requests |
| `subkey` | Parameter | Sub-key — the specific data point within a domain (e.g., "value", "state", "*" for count, or a numeric index) |
| 替え字 (Kaeeji) | Field | Replacement Character — a screen field for replacement character index data, tracking which character replacement is being referenced |
| コードリスト (Koodo Risuto) | Field | Code List — a collection of code entries with item ID `cd_div_list`, each represented as an `X33VDataTypeStringBean` |
| コード名リスト (Koodo Me Risuto) | Field | Code Name List — a collection of code name entries with item ID `cd_div_nm`, each represented as an `X33VDataTypeStringBean` |
| `cd_div_list` | Field | Code division list — the item ID for the code list data type |
| `cd_div_nm_list` | Field | Code division name list — the item ID for the code name list data type |
| `getIndex_value()` | Method | Returns the index value for the replacement character domain |
| `getIndex_state()` | Method | Returns the index state/status for the replacement character domain |
| X33VDataTypeStringBean | Class | A view data type bean representing a string-valued data element in a list collection. Each element supports its own `loadModelData(subkey)` for nested key-value data access |
| X33VDataTypeBeanInterface | Interface | The common interface implemented by view data type beans, enabling polymorphic list iteration and data retrieval |
| DBean | Pattern | Data Bean — a web view data container that holds data for a JSP screen, typically extending `X31CBaseBean`. This method is a data access dispatcher within a DBean |
| Screen Bean | Pattern | The main screen controller data bean (e.g., `KKW00127SFBean`) that aggregates multiple DBean lists and delegates data retrieval to list element beans |
| "*" (wildcard) | Convention | Special sub-key value that requests the size/count of a list collection rather than a specific indexed element |
