# Business Logic — KKW22301SF03DBean.typeModelData() [107 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW22301SF.KKW22301SF03DBean` |
| Layer | View / Data-Binding Layer (webview package — sits between the JSF/struts controller and the presentation model) |
| Module | `KKW22301SF` (Package: `eo.web.webview.KKW22301SF`) |

## 1. Role

### KKW22301SF03DBean.typeModelData()

This method implements a **type-routing dispatcher** for the セット割登録 (Set Discount Registration) screen's data-binding layer. Its business purpose is to resolve the **Java runtime type** of any data element referenced by a dotted key path, enabling the presentation framework to perform runtime type checks (e.g., for JSF component binding, input validation, or conditional UI rendering).

The method covers **four distinct data categories**:
- **覚え字 (Memo / Alias)** — Free-text mnemonic labels with value, enable, and state properties.
- **コードリスト (Code List)** — An array of structured code-value pairs, each backed by `X33VDataTypeStringBean`.
- **コード名リスト (Code Name List)** — An array of code name-value pairs, each backed by `X33VDataTypeStringBean`.
- **名称リスト (Name List)** — An array of name-value pairs, each backed by `X33VDataTypeStringBean`.

It implements a **routing/dispatch pattern**: the `key` parameter determines which data category is addressed, and the `subkey` refines the request to a specific property within that category. For array-backed categories, the key path also carries a **zero-based array index** (e.g., "コードリスト/2"), enabling element-level type delegation to the individual `X33VDataTypeStringBean` instance via its own `typeModelData(subkey)`.

In the larger system, this method serves as the **type introspection entry point** for the screen's detail list items. The UI layer calls it before binding form fields or rendering dynamic components, ensuring the correct data type metadata is available at runtime without hard-coding type knowledge into the view templates.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["typeModelData key, subkey"])
    NULL_CHECK{"key == null<br/>|| subkey == null?"}
    RETURN_NULL(["return null"])
    FIND_SLASH["separaterPoint = key.indexOf('/')"]

    KEY_覚え字{"key equals '覚え字'?"}
    SUBKEY_value{"subkey equals 'value'?"}
    RETURN_STRING_1(["return String.class"])
    SUBKEY_enable{"subkey equals 'enable'?"}
    RETURN_BOOLEAN(["return Boolean.class"])
    SUBKEY_state{"subkey equals 'state'?"}
    RETURN_STRING_2(["return String.class"])

    KEY_コードリスト{"key equals 'コードリスト'?"}
    CD_LIST_SLICE["key = key.substring(separaterPoint + 1)"]
    CD_LIST_STAR{"key equals '*'?"}
    CD_LIST_RETURN_INT(["return Integer.class"])
    CD_LIST_PARSE["tmpIndexInt = Integer.valueOf(key)"]
    CD_LIST_CATCH{NumberFormatException?}
    CD_LIST_CATCH_RETURN(["return null"])
    CD_LIST_RANGE{"tmpIndex valid?"}
    CD_LIST_RANGE_RETURN(["return null"])
    CD_LIST_GET["cd_div_list_list.get(tmpIndex) cast X33VDataTypeStringBean"]
    CD_LIST_CALL["typeModelData(subkey)"]

    KEY_コード名リスト{"key equals 'コード名リスト'?"}
    CD_NM_LIST_SLICE["key = key.substring(separaterPoint + 1)"]
    CD_NM_LIST_STAR{"key equals '*'?"}
    CD_NM_LIST_RETURN_INT(["return Integer.class"])
    CD_NM_LIST_PARSE["tmpIndexInt = Integer.valueOf(key)"]
    CD_NM_LIST_CATCH{NumberFormatException?}
    CD_NM_LIST_CATCH_RETURN(["return null"])
    CD_NM_LIST_RANGE{"tmpIndex valid?"}
    CD_NM_LIST_RANGE_RETURN(["return null"])
    CD_NM_LIST_GET["cd_div_nm_list_list.get(tmpIndex) cast X33VDataTypeStringBean"]
    CD_NM_LIST_CALL["typeModelData(subkey)"]

    KEY_名称リスト{"key equals '名称リスト'?"}
    NM_LIST_SLICE["key = key.substring(separaterPoint + 1)"]
    NM_LIST_STAR{"key equals '*'?"}
    NM_LIST_RETURN_INT(["return Integer.class"])
    NM_LIST_PARSE["tmpIndexInt = Integer.valueOf(key)"]
    NM_LIST_CATCH{NumberFormatException?}
    NM_LIST_CATCH_RETURN(["return null"])
    NM_LIST_RANGE{"tmpIndex valid?"}
    NM_LIST_RANGE_RETURN(["return null"])
    NM_LIST_GET["nm_list_list.get(tmpIndex) cast X33VDataTypeStringBean"]
    NM_LIST_CALL["typeModelData(subkey)"]

    DEFAULT_RETURN(["return null"])

    START --> NULL_CHECK
    NULL_CHECK -->|true| RETURN_NULL
    NULL_CHECK -->|false| FIND_SLASH
    FIND_SLASH --> KEY_覚え字
    KEY_覚え字 -->|true| SUBKEY_value
    KEY_覚え字 -->|false| KEY_コードリスト
    SUBKEY_value -->|true| RETURN_STRING_1
    SUBKEY_value -->|false| SUBKEY_enable
    SUBKEY_enable -->|true| RETURN_BOOLEAN
    SUBKEY_enable -->|false| SUBKEY_state
    SUBKEY_state -->|true| RETURN_STRING_2
    SUBKEY_state -->|false| KEY_コードリスト

    KEY_コードリスト -->|true| CD_LIST_SLICE
    KEY_コードリスト -->|false| KEY_コード名リスト
    CD_LIST_SLICE --> CD_LIST_STAR
    CD_LIST_STAR -->|true| CD_LIST_RETURN_INT
    CD_LIST_STAR -->|false| CD_LIST_PARSE
    CD_LIST_PARSE --> CD_LIST_CATCH
    CD_LIST_CATCH -->|true| CD_LIST_CATCH_RETURN
    CD_LIST_CATCH -->|false| CD_LIST_RANGE
    CD_LIST_RANGE -->|false| CD_LIST_RANGE_RETURN
    CD_LIST_RANGE -->|true| CD_LIST_GET
    CD_LIST_GET --> CD_LIST_CALL

    KEY_コード名リスト -->|true| CD_NM_LIST_SLICE
    KEY_コード名リスト -->|false| KEY_名称リスト
    CD_NM_LIST_SLICE --> CD_NM_LIST_STAR
    CD_NM_LIST_STAR -->|true| CD_NM_LIST_RETURN_INT
    CD_NM_LIST_STAR -->|false| CD_NM_LIST_PARSE
    CD_NM_LIST_PARSE --> CD_NM_LIST_CATCH
    CD_NM_LIST_CATCH -->|true| CD_NM_LIST_CATCH_RETURN
    CD_NM_LIST_CATCH -->|false| CD_NM_LIST_RANGE
    CD_NM_LIST_RANGE -->|false| CD_NM_LIST_RANGE_RETURN
    CD_NM_LIST_RANGE -->|true| CD_NM_LIST_GET
    CD_NM_LIST_GET --> CD_NM_LIST_CALL

    KEY_名称リスト -->|true| NM_LIST_SLICE
    KEY_名称リスト -->|false| DEFAULT_RETURN
    NM_LIST_SLICE --> NM_LIST_STAR
    NM_LIST_STAR -->|true| NM_LIST_RETURN_INT
    NM_LIST_STAR -->|false| NM_LIST_PARSE
    NM_LIST_PARSE --> NM_LIST_CATCH
    NM_LIST_CATCH -->|true| NM_LIST_CATCH_RETURN
    NM_LIST_CATCH -->|false| NM_LIST_RANGE
    NM_LIST_RANGE -->|false| NM_LIST_RANGE_RETURN
    NM_LIST_RANGE -->|true| NM_LIST_GET
    NM_LIST_GET --> NM_LIST_CALL
```

### Processing Overview

1. **Null guard**: If either `key` or `subkey` is `null`, return `null` immediately. (If null/empty fields are not entered, return null.)
2. **Slash detection**: Compute the position of the first `/` in `key` to support indexed access for array-backed categories.
3. **Category dispatch** via if/else-if chain on `key`:

   - **覚え字 (Memo/Alias)**: Match subkey to "value" (→ `String.class`), "enable" (→ `Boolean.class`), or "state" (→ `String.class`).
   - **コードリスト (Code List)**: Slice the key after `/` to extract the array index. If the index is `"*"`, return `Integer.class` (to report list size). Otherwise, parse as integer, validate range, cast the list element to `X33VDataTypeStringBean`, and delegate to its `typeModelData(subkey)`.
   - **コード名リスト (Code Name List)**: Identical logic to Code List, but operates on `cd_div_nm_list_list`.
   - **名称リスト (Name List)**: Identical logic, but operates on `nm_list_list`.
4. **Default return**: If no key matches, return `null`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The business field identifier (項目名). Acts as a routing key that determines which data category is queried. Values: `"覚え字"` (memo/alias), `"コードリスト"` (code list), `"コード名リスト"` (code name list), `"名称リスト"` (name list). For list categories, the key includes a `/` separator followed by either `"*"` (request list size), a zero-based array index (e.g., `"0"`, `"1"`), or an invalid value (returns null). |
| 2 | `subkey` | `String` | A sub-property specifier within the resolved category. For `覚え字`: `"value"`, `"enable"`, or `"state"`. For list categories: forwarded verbatim to the individual list element's `typeModelData(subkey)` to determine the property type of the nested `X33VDataTypeStringBean` instance. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `cd_div_list_list` | `X33VDataTypeList` | The code list data array (item ID: `cd_div_list`). Each element is a code-value pair wrapped in `X33VDataTypeStringBean`. |
| `cd_div_nm_list_list` | `X33VDataTypeList` | The code name list data array (item ID: `cd_div_nm_list`). Each element is a code name-value pair. |
| `nm_list_list` | `X33VDataTypeList` | The name list data array (item ID: `nm_list`). Each element is a name-value pair. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `KKW22301SF03DBean.typeModelData` | KKW22301SF03DBean | - | Recursive call into `typeModelData` on individual `X33VDataTypeStringBean` list elements |

### Detailed Method-Call Analysis

This method performs **no database or SC-level operations**. It is a pure **type introspection/routing** method. All operations are in-memory:

| # | Called Method | Category | Business Description |
|---|--------------|----------|---------------------|
| 1 | `String.equals()` | Java API | String equality check to route by field name (`key`) and property (`subkey`) |
| 2 | `String.indexOf()` | Java API | Find the first `/` separator in the key path for array-indexed categories |
| 3 | `String.substring()` | Java API | Extract the portion of `key` after the first `/` to obtain the index or `"*"` marker |
| 4 | `Integer.valueOf()` | Java API | Parse the extracted key portion as an integer (list index or `"*"` check) |
| 5 | `X33VDataTypeList.size()` | Instance field access | Boundary check against the current size of the list array |
| 6 | `X33VDataTypeList.get(int)` | Instance field access | Retrieve the element at the specified index from the list |
| 7 | `X33VDataTypeStringBean.typeModelData(String)` | Self-delegation | Recursively resolve the type of a sub-property within the individual list element |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Internal — KKW22301SF03DBean | Self-reference within `KKW22301SF03DBean` | N/A (pure type routing, no SC/CRUD) |

### Self-Recursive Calls (within this method)

| # | Caller | Target |
|---|--------|--------|
| 1 | `KKW22301SF03DBean.typeModelData(key, subkey)` — list branches | `X33VDataTypeStringBean.typeModelData(subkey)` on individual list element |

**Note**: The only callers of this method are internal — both direct calls from within `KKW22301SF03DBean` itself (for array-element type resolution) and callers from the enclosing screen framework. No external CBS, SC, or batch entry points invoke this method directly.

## 6. Per-Branch Detail Blocks

### Block 1 — IF (null guard) (L426)

Null check for parameters. If either is null, return null immediately.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (key == null || subkey == null)` // If null/empty fields are not entered, return null (nullの場合、nullを返す) |
| 2 | RETURN | `return null;` |

### Block 2 — SET (slash position) (L431)

Compute the separator position for array-indexed categories.

| # | Type | Code |
|---|------|------|
| 1 | SET | `int separaterPoint = key.indexOf("/");` // Find first slash in key |

### Block 3 — IF/ELSE-IF (Category Dispatch — 覚え字 / Memo-Alias) (L434)

The "覚え字" (Memo/Alias) field branch. This handles the simplest case: a flat key with subkey-based property resolution.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (key.equals("覚え字"))` // For each field, insert processing (項目ごとに入れる) — data type is String for "memo/alias" field, item ID: index (データの型がStringの項目"覚え字"（項目ID:index）) |
| 2 | IF | `if (subkey.equalsIgnoreCase("value"))` |
| 3 | RETURN | `return String.class;` |
| 4 | ELSE-IF | `else if (subkey.equalsIgnoreCase("enable"))` |
| 5 | RETURN | `return Boolean.class;` |
| 6 | ELSE-IF | `else if (subkey.equalsIgnoreCase("state"))` // Return state when subkey is "state" (subkeyが"state"の場合、ステータスを返す) |
| 7 | RETURN | `return String.class;` |

### Block 4 — ELSE-IF (Category Dispatch — コードリスト / Code List) (L442)

The "コードリスト" (Code List) branch — an array-backed data category with index-based element access.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `else if (key.equals("コードリスト"))` // Array item "Code List" (配列項目"コードリスト") — String type, item ID: cd_div_list |
| 2 | SET | `key = key.substring(separaterPoint + 1);` // Get next element of key (keyの次の要素を取得) — extracts portion after first `/` |
| 3 | IF | `if (key.equals("*"))` // If "*" is specified for index value, return list element count (インデックス値の代わりに"*"が指定されていたら、リストの要素数を返す) |
| 4 | RETURN | `return Integer.class;` |
| 5 | SET | `Integer tmpIndexInt = null;` |
| 6 | TRY | `tmpIndexInt = Integer.valueOf(key);` // Parse index |
| 7 | CATCH | `catch (NumberFormatException e)` // If index value is not a numeric string, return null here (インデックス値が数値文字列でない場合は、ここでnullを返す) |
| 8 | RETURN | `return null;` |
| 9 | IF | `if (tmpIndexInt == null)` |
| 10 | RETURN | `return null;` |
| 11 | SET | `int tmpIndex = tmpIndexInt.intValue();` |
| 12 | IF | `if (tmpIndex < 0 || tmpIndex >= cd_div_list_list.size())` // If index exceeds list count - 1, return null (インデックス値がリスト個数-1を超えると、ここでnullを返す) |
| 13 | RETURN | `return null;` |
| 14 | RETURN | `return ((X33VDataTypeStringBean) cd_div_list_list.get(tmpIndex)).typeModelData(subkey);` // Delegate to list element |

### Block 5 — ELSE-IF (Category Dispatch — コード名リスト / Code Name List) (L474)

The "コード名リスト" (Code Name List) branch — structurally identical to Code List but operates on `cd_div_nm_list_list`.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `else if (key.equals("コード名リスト"))` // Array item "Code Name List" (配列項目"コード名リスト") — String type, item ID: cd_div_nm_list |
| 2 | SET | `key = key.substring(separaterPoint + 1);` // Get next element of key |
| 3 | IF | `if (key.equals("*"))` // If "*" is specified, return list element count |
| 4 | RETURN | `return Integer.class;` |
| 5 | SET | `Integer tmpIndexInt = null;` |
| 6 | TRY | `tmpIndexInt = Integer.valueOf(key);` |
| 7 | CATCH | `catch (NumberFormatException e)` |
| 8 | RETURN | `return null;` |
| 9 | IF | `if (tmpIndexInt == null)` |
| 10 | RETURN | `return null;` |
| 11 | SET | `int tmpIndex = tmpIndexInt.intValue();` |
| 12 | IF | `if (tmpIndex < 0 || tmpIndex >= cd_div_nm_list_list.size())` |
| 13 | RETURN | `return null;` |
| 14 | RETURN | `return ((X33VDataTypeStringBean) cd_div_nm_list_list.get(tmpIndex)).typeModelData(subkey);` |

### Block 6 — ELSE-IF (Category Dispatch — 名称リスト / Name List) (L506)

The "名称リスト" (Name List) branch — structurally identical to Code List but operates on `nm_list_list`.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `else if (key.equals("名称リスト"))` // Array item "Name List" (配列項目"名称リスト") — String type, item ID: nm_list |
| 2 | SET | `key = key.substring(separaterPoint + 1);` // Get next element of key |
| 3 | IF | `if (key.equals("*"))` // If "*" is specified, return list element count |
| 4 | RETURN | `return Integer.class;` |
| 5 | SET | `Integer tmpIndexInt = null;` |
| 6 | TRY | `tmpIndexInt = Integer.valueOf(key);` |
| 7 | CATCH | `catch (NumberFormatException e)` |
| 8 | RETURN | `return null;` |
| 9 | IF | `if (tmpIndexInt == null)` |
| 10 | RETURN | `return null;` |
| 11 | SET | `int tmpIndex = tmpIndexInt.intValue();` |
| 12 | IF | `if (tmpIndex < 0 || tmpIndex >= nm_list_list.size())` |
| 13 | RETURN | `return null;` |
| 14 | RETURN | `return ((X33VDataTypeStringBean) nm_list_list.get(tmpIndex)).typeModelData(subkey);` |

### Block 7 — ELSE-IF/DEFAULT (No Match) (L537)

If no condition matches the provided `key`, return null.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF (implicit) | If none of the if/else-if branches matched |
| 2 | RETURN | `return null;` // Return null if no matching property exists (条件に一致するプロパティが存在しない場合は、nullを返す) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `key` | Field | Item name (項目名) — the primary field identifier used to route the type lookup to the correct data category |
| `subkey` | Field | Sub-key (サブキー) — a secondary identifier that refines the lookup to a specific property within the resolved category |
| `覚え字` | Field | Memo / Alias — a free-text mnemonic label field with value, enable, and state properties |
| `コードリスト` | Field | Code List — an array of structured code-value pairs (item ID: `cd_div_list`). Each element carries a code identifier and its display value. |
| `コード名リスト` | Field | Code Name List — an array of code name-value pairs (item ID: `cd_div_nm_list`). Each element carries a code name and its associated name. |
| `名称リスト` | Field | Name List — an array of name-value pairs (item ID: `nm_list`). Used for display labels and selectable name values. |
| `cd_div_list_list` | Instance Field | The code list data array. A list of `X33VDataTypeList` containing `X33VDataTypeStringBean` elements representing individual code entries. |
| `cd_div_nm_list_list` | Instance Field | The code name list data array. Same structure as `cd_div_list_list` but for code name entries. |
| `nm_list_list` | Instance Field | The name list data array. Same structure, but for name entries. |
| `X33VDataTypeStringBean` | Class | A typed data container for list elements. Each instance wraps a string-typed data value and provides its own `typeModelData(subkey)` for property-level type introspection. |
| `X33VDataTypeList` | Class | A typed list container that holds `X33VDataTypeBean` (or subclass) elements. Provides indexed access (`get(int)`) and size querying. |
| セット割登録 | Business term | Set Discount Registration — the screen (KKW22301) that this bean supports. Users register discount sets for service contracts. |
| KKW22301SF | Module | Screen Framework module for the Set Discount Registration functionality. "SF" denotes "Screen Framework." |
| KKW22301SF03DBean | Class | The view-data bean (DBean) for the detail section of screen KKW22301. Holds presentation model state for the detail list. |
| typeModelData | Method | Type model data resolution — determines the Java class type of a named property for UI binding. |
