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

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

## 1. Role

### KKW00127SF01DBean.typeModelData()

This method serves as a **type introspection router** for the web-view data binding framework (X33V). Its purpose is to resolve the Java `Class<?>` type for any given property identified by a `key` and `subkey` pair, enabling the framework to perform type-safe data access, validation, and serialization on the server side. The method implements a **dispatch/routing pattern**: it inspects the `key` to determine which logical field category is being queried, then delegates to sub-type resolvers for compound structures (array/list-backed items).

The method handles two distinct service categories:

1. **Scalar field type resolution** — for single-value fields like "加字" (Additional Characters / Extra Info), it returns `String.class` for subkeys "value" or "state".
2. **List (array) field type resolution** — for indexed list fields like "コードリスト" (Code List) and "コード名リスト" (Code Name List), it extracts an index from the composite key, validates bounds, and delegates to the element bean's own `typeModelData()` method.

Its role in the larger system is as a **shared utility method** that supports the X33V framework's data binding contract (`X33VDataTypeBeanInterface`). When the framework needs to know "what type does property X have?" before performing reads, writes, or validation, it calls this method. It is an entry point for the bean's type metadata contract, enabling dynamic form rendering and data access without hardcoding types at compile time.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["typeModelData key, subkey"])
    NULL_CHECK{"key == null or subkey == null?"}
    FIND_SEP["separaterPoint = key.indexOf('/')"]
    ADD_CHAR{"key.equals('加字')?"}
    SUB_VALUE{"subkey.equalsIgnoreCase('value')?"}
    SUB_STATE{"subkey.equalsIgnoreCase('state')?"}
    CODE_LIST{"key.equals('コードリスト')?"}
    SUBSTR_CD["key = key.substring(separaterPoint + 1)"]
    STAR_CD{"key.equals('*')?"}
    TRY_PARSE_CD
    PARSE_ERR_CD{"NumberFormatException?"}
    NULL_IDX_CD{"tmpIndexInt == null?"}
    BOUNDS_CD{"tmpIndex < 0 or tmpIndex >= cd_div_list_list.size()?"}
    DELEGATE_CD["X33VDataTypeStringBean.typeModelData(subkey)"]
    CODE_NM{"key.equals('コード名リスト')?"}
    SUBSTR_NM["key = key.substring(separaterPoint + 1)"]
    STAR_NM{"key.equals('*')?"}
    TRY_PARSE_NM
    PARSE_ERR_NM{"NumberFormatException?"}
    NULL_IDX_NM{"tmpIndexInt == null?"}
    BOUNDS_NM{"tmpIndex < 0 or tmpIndex >= cd_div_nm_list_list.size()?"}
    DELEGATE_NM["X33VDataTypeStringBean.typeModelData(subkey)"]
    DEFAULT_END(["return null"])
    RETURN_NULL(["return null"])
    RETURN_BOOL(["return Boolean.class"])

    START --> NULL_CHECK
    NULL_CHECK -->|true| RETURN_NULL
    NULL_CHECK -->|false| FIND_SEP
    FIND_SEP --> ADD_CHAR
    ADD_CHAR -->|true| SUB_VALUE
    ADD_CHAR -->|false| CODE_LIST
    SUB_VALUE -->|true| RETURN_BOOL
    SUB_VALUE -->|false| SUB_STATE
    SUB_STATE -->|true| RETURN_BOOL
    SUB_STATE -->|false| CODE_LIST
    CODE_LIST -->|true| SUBSTR_CD
    CODE_LIST -->|false| CODE_NM
    SUBSTR_CD --> STAR_CD
    STAR_CD -->|true| RETURN_BOOL
    STAR_CD -->|false| TRY_PARSE_CD
    TRY_PARSE_CD --> PARSE_ERR_CD
    PARSE_ERR_CD -->|true| RETURN_NULL
    PARSE_ERR_CD -->|false| NULL_IDX_CD
    NULL_IDX_CD -->|true| RETURN_NULL
    NULL_IDX_CD -->|false| BOUNDS_CD
    BOUNDS_CD -->|true| RETURN_NULL
    BOUNDS_CD -->|false| DELEGATE_CD
    DELEGATE_CD --> END1(["Return delegated result"])
    CODE_NM -->|true| SUBSTR_NM
    CODE_NM -->|false| DEFAULT_END
    SUBSTR_NM --> STAR_NM
    STAR_NM -->|true| RETURN_BOOL
    STAR_NM -->|false| TRY_PARSE_NM
    TRY_PARSE_NM --> PARSE_ERR_NM
    PARSE_ERR_NM -->|true| RETURN_NULL
    PARSE_ERR_NM -->|false| NULL_IDX_NM
    NULL_IDX_NM -->|true| RETURN_NULL
    NULL_IDX_NM -->|false| BOUNDS_NM
    BOUNDS_NM -->|true| RETURN_NULL
    BOUNDS_NM -->|false| DELEGATE_NM
    DELEGATE_NM --> END2(["Return delegated result"])
    RETURN_NULL --> END3(["Return null"])
    DEFAULT_END --> END3
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The property name (field identifier). It identifies which logical field is being queried. For scalar fields, it is the field name directly (e.g., "加字" / Additional Characters). For list/array fields, it is a composite string with format `"listName/index"` (e.g., "コードリスト/0" for the first element of the code list, or "コードリスト/*" for the list size). |
| 2 | `subkey` | `String` | The sub-property selector. For scalar fields, it specifies which attribute of the field is being queried (e.g., "value" for the field's actual value, "state" for the field's state/status). For list fields, it is passed through to the element bean's own `typeModelData()` to query per-element properties. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `cd_div_list_list` | `X33VDataTypeList` | The code list — a dynamically-sized list of `X33VDataTypeStringBean` elements representing coded dropdown/select options. |
| `cd_div_nm_list_list` | `X33VDataTypeList` | The code name list — a dynamically-sized list of `X33VDataTypeStringBean` elements representing human-readable names corresponding to each code. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `X33VDataTypeStringBean.typeModelData` | N/A (framework delegate) | - | Delegates to the element bean's type model resolution for a specific index in the list. |
| - | `X33VDataTypeStringBean` (via `.get(tmpIndex)`) | N/A (framework delegate) | - | Accesses a specific element from the `cd_div_list_list` or `cd_div_nm_list_list` array by index. |

**Notes:**
- This method does **not** perform any direct Create/Read/Update/Delete (CRUD) operations on databases or external services. It is a pure type-introspection utility.
- The only "service" call is the delegation to `X33VDataTypeStringBean.typeModelData(subkey)` on list elements, which is part of the X33V framework's data binding contract and does not touch any database or CBS.
- The method reads from instance fields (`cd_div_list_list`, `cd_div_nm_list_list`) which are populated elsewhere in the bean's lifecycle (e.g., by data initialization methods or the framework itself).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Bean:KKW00127SF01DBean | `KKW00127SF01DBean.typeModelData` | — (self-reference only; no external terminal) |

**Notes:**
- This method is part of the X33V data bean contract (`X33VDataTypeBeanInterface`). The framework itself calls this method during type introspection — it is not invoked directly by business screen code in the application layer.
- The pre-computed code graph indicates only self-reference (the method is a data bean utility that the framework invokes, not a screen-level method).
- Terminal column is empty because this method performs no CRUD operations against databases or external services.

## 6. Per-Branch Detail Blocks

### Block 1 — IF (null check) (L342)

> Guard clause: if either `key` or `subkey` is null, return null immediately. This prevents NullPointerException during all subsequent string operations.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (key == null || subkey == null)` |
| 2 | RETURN | `return null;` // Returns null if key or subkey is null (key, subkeyがnullの場合、nullを返す) |

### Block 2 — SET (separaterPoint extraction) (L347)

> Computes the position of the first "/" separator in the key. Used later to extract the index portion of composite keys like "コードリスト/0".

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

### Block 3 — IF/ELSE-IF (key dispatch) (L351)

> Primary dispatch: branches on the `key` value to determine which logical field category is being queried. Three categories: "加字" (scalar), "コードリスト" (list), "コード名リスト" (list).

#### Block 3.1 — IF (key equals "加字") [ADD_CHAR="加字"] (L351)

> Scalar field branch for "Additional Characters" (加字 / 項目ID: index). This field holds extra information as a string value with associated state metadata.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (key.equals("加字"))` // Check if the field is "Additional Characters" |
| 2 | IF | `if (subkey.equalsIgnoreCase("value"))` // Check if querying the actual value |
| 3 | RETURN | `return String.class;` // Additional Characters value is a String |
| 4 | ELSE-IF | `else if (subkey.equalsIgnoreCase("state"))` // subkeyが"state"の場合、ステータスを返す (If subkey is "state", return status) |
| 5 | RETURN | `return String.class;` // Additional Characters state is a String |

#### Block 3.2 — ELSE-IF (key equals "コードリスト") [CD_DIV_LIST="コードリスト"] (L364)

> List field branch for the Code List ("コードリスト" / Item ID: `cd_div_list`). Each element is a `X33VDataTypeStringBean` representing a coded option value. The key format is "コードリスト/index" where index is a 0-based position or "*" for the list size.

| # | Type | Code |
|---|------|------|
| 1 | SET | `key = key.substring(separaterPoint + 1);` // Extract the portion after the first "/" — e.g., from "コードリスト/0" get "0" |
| 2 | IF | `if (key.equals("*"))` // Check if requesting the list size (インデックス値の代わりに"*"が指定されていたら、リストの要素数を返す) |
| 3 | RETURN | `return Integer.class;` // List size is returned as Integer |
| 4 | SET | `Integer tmpIndexInt = null;` // Prepare to parse the index string |
| 5 | TRY | `tmpIndexInt = Integer.valueOf(key);` // Convert key to integer index |
| 6 | CATCH | `catch (NumberFormatException e)` // インデックス値が数値文字列でない場合は、ここでnullを返す (If index value is not a numeric string, return null here) |
| 7 | RETURN | `return null;` // Invalid index format — return null |
| 8 | IF | `if (tmpIndexInt == null)` // Fallback null check (should not be reached but defensive) |
| 9 | RETURN | `return null;` // Null index — return null |
| 10 | SET | `int tmpIndex = tmpIndexInt.intValue();` // Unbox Integer to primitive int |
| 11 | IF | `if (tmpIndex < 0 || tmpIndex >= cd_div_list_list.size())` // インデックス値がリスト個数-1を超えると、ここでnullを返す (If index exceeds list size minus one, return null here) |
| 12 | RETURN | `return null;` // Out of bounds — return null |
| 13 | RETURN | `return ((X33VDataTypeStringBean)cd_div_list_list.get(tmpIndex)).typeModelData(subkey);` // Delegate to element bean's typeModelData |

#### Block 3.3 — ELSE-IF (key equals "コード名リスト") [CD_DIV_NM_LIST="コード名リスト"] (L395)

> List field branch for the Code Name List ("コード名リスト" / Item ID: `cd_div_nm_list`). Mirrors the Code List branch but operates on a separate list of human-readable name beans. Each element is also a `X33VDataTypeStringBean`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `key = key.substring(separaterPoint + 1);` // Extract the portion after the first "/" — e.g., from "コード名リスト/0" get "0" |
| 2 | IF | `if (key.equals("*"))` // Check if requesting the list size |
| 3 | RETURN | `return Integer.class;` // List size is returned as Integer |
| 4 | SET | `Integer tmpIndexInt = null;` // Prepare to parse the index string |
| 5 | TRY | `tmpIndexInt = Integer.valueOf(key);` // Convert key to integer index |
| 6 | CATCH | `catch (NumberFormatException e)` // インデックス値が数値文字列でない場合は、ここでnullを返す (If index value is not a numeric string, return null here) |
| 7 | RETURN | `return null;` // Invalid index format — return null |
| 8 | IF | `if (tmpIndexInt == null)` // Fallback null check |
| 9 | RETURN | `return null;` // Null index — return null |
| 10 | SET | `int tmpIndex = tmpIndexInt.intValue();` // Unbox Integer to primitive int |
| 11 | IF | `if (tmpIndex < 0 || tmpIndex >= cd_div_nm_list_list.size())` // インデックス値がリスト個数-1を超えると、ここでnullを返す (If index exceeds list size minus one, return null here) |
| 12 | RETURN | `return null;` // Out of bounds — return null |
| 13 | RETURN | `return ((X33VDataTypeStringBean)cd_div_nm_list_list.get(tmpIndex)).typeModelData(subkey);` // Delegate to element bean's typeModelData |

### Block 4 — RETURN (default/fallback) (L412)

> If none of the above conditions match, return null. No matching property type is known.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // 条件に合致するプロパティが存在しない場合は、nullを返す (If no matching property exists, return null) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `key` | Parameter | Property name — the identifier for a field being queried. Can be a scalar name (e.g., "加字") or a composite "listName/index" string. |
| `subkey` | Parameter | Sub-property selector — specifies which attribute to query within a field (e.g., "value" for data, "state" for status). |
| `加字` | Field | Additional Characters / Extra Info — a single-value string field holding supplementary data. Item ID: `index`. |
| `コードリスト` | Field | Code List — a list/array of coded option values (e.g., dropdown values). Item ID: `cd_div_list`. Each element is a `X33VDataTypeStringBean`. |
| `コード名リスト` | Field | Code Name List — a list/array of human-readable names corresponding to each code value. Item ID: `cd_div_nm_list`. Each element is a `X33VDataTypeStringBean`. |
| `cd_div_list_list` | Instance field | The backing data structure for the Code List — an `X33VDataTypeList` of `X33VDataTypeStringBean` elements. |
| `cd_div_nm_list_list` | Instance field | The backing data structure for the Code Name List — an `X33VDataTypeList` of `X33VDataTypeStringBean` elements. |
| `separaterPoint` | Local variable | Index of the first "/" character in the composite key, used to split list field names from their index values. |
| `X33VDataTypeBeanInterface` | Interface | X33V framework interface that `typeModelData()` implements. Defines the contract for type introspection of bean properties. |
| `X33VDataTypeList` | Framework class | A dynamic list container from the X33V framework, used to hold typed list elements within the data bean. |
| `X33VDataTypeStringBean` | Framework class | A string-type data element wrapper in the X33V framework. Each list element is wrapped in this class. |
| `X33VListedBeanInterface` | Interface | X33V framework interface for beans that hold list data. Enables iteration and indexed access. |
| "value" | Subkey | Requests the actual data value of a scalar field. |
| "state" | Subkey | Requests the status/state metadata of a scalar field. |
| "*" | Special key | In list contexts, represents a request for the list's element count (size) rather than an indexed element. |
| NumberFormatException | Exception | Thrown when the key portion of a list composite key cannot be parsed as an integer (e.g., "コードリスト/abc"). |
