# Business Logic — KKW00401SF01DBean.typeModelData() [119 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00401SF.KKW00401SF01DBean` |
| Layer | Controller / UI Bean (Web Client Data Bean) |
| Module | `KKW00401SF` (Package: `eo.web.webview.KKW00401SF`) |

## 1. Role

### KKW00401SF01DBean.typeModelData()

This method serves as the **type introspection dispatcher** for the X33 web framework's view-data binding system. The X33 framework (Fujitsu Futurity) requires each Data Bean to report the Java type of every field it exposes, so that the UI rendering layer can perform proper type coercion, validation, and widget selection. `typeModelData` implements this contract by mapping **item keys** and **subkey names** to their corresponding `Class<?>` types.

The method handles **six business item categories**: (1) Code Type Code — a dropdown code value selector (item ID `cd_div_cd`), (2) Code Type Name — a human-readable code label selector (item ID `cd_div_nm`), (3) Selected Index — the currently selected dropdown index (item ID `select_index`), (4) Initial Setting Code — a default/fallback code value (item ID `default_cd`), (5) Code Type Code Value List — an array of code value objects (item ID `cd_div_cd_list`), and (6) Code Type Name List — an array of code name objects (item ID `cd_div_nm_list`).

It implements the **routing/dispatch design pattern**: a cascading series of string equality checks routes each call to the appropriate branch. For scalar fields it returns the static type (`String.class` or `Boolean.class`). For list-based fields it extracts an index from the key (e.g., `"CODE_TYPE_CODE_VALUE_LIST/2"` → index `2`), validates bounds, and **delegates** to the `typeModelData` method of the element's `X33VDataTypeStringBean` instance.

This method is a **core framework hook** called by the X33 view-data binding machinery — it is not invoked directly by screen code. Its role in the larger system is to enable the X33 framework's generic data-binding, form rendering, and UI state management capabilities for the code-type configuration items used throughout the KKW00401SF screen module.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["typeModelData"])
    START --> CHECK_NULL{key or subkey null}
    CHECK_NULL -->|Yes| RET_NULL["Return null"]
    CHECK_NULL -->|No| FIND_SEP["Find '/' in key"]
    FIND_SEP --> B1{"key equals 'Code Type Code'"}

    B1 -->|Yes| B1A{subkey 'value'}
    B1A -->|Yes| R1["Return String.class"]
    B1A -->|No| B1B{subkey 'enable'}
    B1B -->|Yes| R2["Return Boolean.class"]
    B1B -->|No| B1C{subkey 'state'}
    B1C -->|Yes| R3["Return String.class"]

    B1 -->|No| B2{"key equals 'Code Type Name'"}
    B2 -->|Yes| B2A{subkey 'value'}
    B2A -->|Yes| R4["Return String.class"]
    B2A -->|No| B2B{subkey 'enable'}
    B2B -->|Yes| R5["Return Boolean.class"]
    B2B -->|No| B2C{subkey 'state'}
    B2C -->|Yes| R6["Return String.class"]

    B2 -->|No| B3{"key equals 'Selected Index'"}
    B3 -->|Yes| B3A{subkey 'value'}
    B3A -->|Yes| R7["Return String.class"]
    B3A -->|No| B3B{subkey 'enable'}
    B3B -->|Yes| R8["Return Boolean.class"]
    B3B -->|No| B3C{subkey 'state'}
    B3C -->|Yes| R9["Return String.class"]

    B3 -->|No| B4{"key equals 'Initial Setting Code'"}
    B4 -->|Yes| B4A{subkey 'value'}
    B4A -->|Yes| R10["Return String.class"]
    B4A -->|No| B4B{subkey 'enable'}
    B4B -->|Yes| R11["Return Boolean.class"]
    B4B -->|No| B4C{subkey 'state'}
    B4C -->|Yes| R12["Return String.class"]

    B4 -->|No| B5{"key equals 'Code Type Code Value List'"}
    B5 -->|Yes| EX1["Extract key after '/'"]
    EX1 --> S1{key equals '*'}
    S1 -->|Yes| R13["Return Integer.class"]
    S1 -->|No| P1["Parse key as Integer"]
    P1 --> E1{NumberFormatException}
    E1 -->|Yes| RN1["Return null"]
    E1 -->|No| BL1{index valid}
    BL1 -->|No| RN2["Return null"]
    BL1 -->|Yes| DG1["Delegate X33VDataTypeStringBean.typeModelData"]

    B5 -->|No| B6{"key equals 'Code Type Name List'"}
    B6 -->|Yes| EX2["Extract key after '/'"]
    EX2 --> S2{key equals '*'}
    S2 -->|Yes| R14["Return Integer.class"]
    S2 -->|No| P2["Parse key as Integer"]
    P2 --> E2{NumberFormatException}
    E2 -->|Yes| RN3["Return null"]
    E2 -->|No| BL2{index valid}
    BL2 -->|No| RN4["Return null"]
    BL2 -->|Yes| DG2["Delegate X33VDataTypeStringBean.typeModelData"]

    B6 -->|No| RN5["Return null"]

    R1 --> END(["End"])
    R2 --> END
    R3 --> END
    R4 --> END
    R5 --> END
    R6 --> END
    R7 --> END
    R8 --> END
    R9 --> END
    R10 --> END
    R11 --> END
    R12 --> END
    R13 --> END
    R14 --> END
    RN1 --> END
    RN2 --> END
    RN3 --> END
    RN4 --> END
    RN5 --> END
    RET_NULL --> END
    DG1 --> END
    DG2 --> END
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The item name (field identifier) within the X33 Data Bean. It determines which business property's type is being queried. Possible values: scalar item names (`"コードタイプコード"`, `"コードタイプ名称"`, `"選択インデックス"`, `"初期設定コード"`) or array item names with an index suffix (`"コードタイプコード値リスト/0"`, `"コードタイプ名称リスト/*"`). The presence of `'/'` in the key signals a list-based item that requires index resolution. |
| 2 | `subkey` | `String` | The property name within the item. For scalar fields, valid values are `"value"` (the data value), `"enable"` (editability flag), and `"state"` (UI state string). For list items, `subkey` is passed through to the delegated `X33VDataTypeStringBean.typeModelData(subkey)` call to resolve the type of the property within each list element. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `cd_div_cd_list_list` | `X33VDataTypeList` | List of `X33VDataTypeStringBean` instances representing code type code value entries (item ID `cd_div_cd_list`). Used for list-based delegation. |
| `cd_div_nm_list_list` | `X33VDataTypeList` | List of `X33VDataTypeStringBean` instances representing code type name entries (item ID `cd_div_nm_list`). Used for list-based delegation. |

## 4. CRUD Operations / Called Services

This method is a **pure read/introspection utility** — it does not perform any Create, Read (from DB), Update, or Delete operations on persistent data. All its calls are internal framework delegations and string operations on parameters.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `String.indexOf` | - | - | Gets the position of `'/'` in the key for list index extraction |
| - | `String.equals` | - | - | Compares the key against known item name literals |
| - | `String.equalsIgnoreCase` | - | - | Case-insensitive comparison of subkey against `"value"`, `"enable"`, `"state"` |
| - | `String.substring` | - | - | Extracts the index portion of the key after `'/'` (e.g., `"0"` from `"リスト/0"`) |
| - | `Integer.valueOf` | - | - | Parses the extracted key portion as an integer for list index resolution |
| - | `Integer.intValue` | - | - | Converts `Integer` wrapper to primitive `int` for array bounds check |
| - | `X33VDataTypeList.get` | - | - | Retrieves the `X33VDataTypeStringBean` at the validated index |
| - | `X33VDataTypeList.size` | - | - | Retrieves the list size for index bounds validation |
| - | `X33VDataTypeStringBean.typeModelData` | X33 Framework | - | Delegates type introspection to the element bean — reads the element's type model |

**Classification rationale:** No database access, no SC (Service Component) calls, no CBS (Common Business Service) invocations. All operations are in-memory type resolution and delegation to the X33 framework bean infrastructure.

## 5. Dependency Trace

The pre-computed evidence shows this method is called exclusively by itself (self-referential — internal delegation for list elements).

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Framework: X33 Data Binder | `X33VDataTypeBeanInterface.typeModelData(key, subkey)` → `KKW00401SF01DBean.typeModelData` | Internal delegation → `X33VDataTypeStringBean.typeModelData` [R list element] |

**Explanation:**
- `KKW00401SF01DBean` implements `X33VDataTypeBeanInterface`, which declares `typeModelData(String, String)`. The X33 framework calls this method through the interface during view-data binding initialization and rendering.
- The only internal caller is self-referential: when handling list-type keys (`"コードタイプコード値リスト"` or `"コードタイプ名称リスト"`), the method casts the list element to `X33VDataTypeStringBean` and calls its `typeModelData(subkey)` method to resolve the sub-property type within that element.
- No external screens (KKSV*) or CBS components directly call this method — it is a pure framework hook.

## 6. Per-Branch Detail Blocks

**Block 1** — IF (null check) `(key == null || subkey == null)` (L536)

> If either parameter is null, return null immediately. This is the defensive guard.

| # | Type | Code |
|---|------|------|
| 1 | SET | `separaterPoint = key.indexOf("/")` |

**Block 2** — IF `[キー: コードタイプコード]` ("Code Type Code") (L543)

> Handles the "Code Type Code" scalar field (item ID: `cd_div_cd`). This is a dropdown code value selector.
> Subkey `"value"` → String (the code value), `"enable"` → Boolean (editability), `"state"` → String (UI state).

| # | Type | Code |
|---|------|------|
| 1 | SET | `separaterPoint = key.indexOf("/")` // Extracts position of '/' for potential list access |
| 2 | IF | `key.equals("コードタイプコード")` // [KEY: コードタイプコード = "コードタイプコード"] Code Type Code field |
| 2.1 | IF-ELSE-IF | `subkey.equalsIgnoreCase("value")` // Sub-property: data value |
| 2.1.1 | RETURN | `return String.class` // The value is a String |
| 2.2 | IF-ELSE-IF | `subkey.equalsIgnoreCase("enable")` // Sub-property: editability flag |
| 2.2.1 | RETURN | `return Boolean.class` // Enable/disable is a Boolean |
| 2.3 | IF-ELSE-IF | `subkey.equalsIgnoreCase("state")` // Sub-property: state string |
| 2.3.1 | RETURN | `return String.class` // [COMMENT: stateの場合、ステータスを返す - Returns status when subkey is "state"] |

**Block 3** — ELSE-IF `[キー: コードタイプ名称]` ("Code Type Name") (L556)

> Handles the "Code Type Name" scalar field (item ID: `cd_div_nm`). This is a human-readable code label selector.
> Same subkey pattern as Block 2: value→String, enable→Boolean, state→String.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `key.equals("コードタイプ名称")` // [KEY: コードタイプ名称 = "コードタイプ名称"] Code Type Name field |
| 1.1 | IF-ELSE-IF | `subkey.equalsIgnoreCase("value")` // Sub-property: data value |
| 1.1.1 | RETURN | `return String.class` |
| 1.2 | IF-ELSE-IF | `subkey.equalsIgnoreCase("enable")` // Sub-property: editability flag |
| 1.2.1 | RETURN | `return Boolean.class` |
| 1.3 | IF-ELSE-IF | `subkey.equalsIgnoreCase("state")` // Sub-property: state string |
| 1.3.1 | RETURN | `return String.class` |

**Block 4** — ELSE-IF `[キー: 選択インデックス]` ("Selected Index") (L569)

> Handles the "Selected Index" scalar field (item ID: `select_index`). This holds the currently selected dropdown index value.
> Same subkey pattern: value→String, enable→Boolean, state→String.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `key.equals("選択インデックス")` // [KEY: 選択インデックス = "選択インデックス"] Selected Index field |
| 1.1 | IF-ELSE-IF | `subkey.equalsIgnoreCase("value")` |
| 1.1.1 | RETURN | `return String.class` |
| 1.2 | IF-ELSE-IF | `subkey.equalsIgnoreCase("enable")` |
| 1.2.1 | RETURN | `return Boolean.class` |
| 1.3 | IF-ELSE-IF | `subkey.equalsIgnoreCase("state")` |
| 1.3.1 | RETURN | `return String.class` |

**Block 5** — ELSE-IF `[キー: 初期設定コード]` ("Initial Setting Code") (L582)

> Handles the "Initial Setting Code" scalar field (item ID: `default_cd`). This holds a default/fallback code value.
> Same subkey pattern: value→String, enable→Boolean, state→String.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `key.equals("初期設定コード")` // [KEY: 初期設定コード = "初期設定コード"] Initial Setting Code field |
| 1.1 | IF-ELSE-IF | `subkey.equalsIgnoreCase("value")` |
| 1.1.1 | RETURN | `return String.class` |
| 1.2 | IF-ELSE-IF | `subkey.equalsIgnoreCase("enable")` |
| 1.2.1 | RETURN | `return Boolean.class` |
| 1.3 | IF-ELSE-IF | `subkey.equalsIgnoreCase("state")` |
| 1.3.1 | RETURN | `return String.class` |

**Block 6** — ELSE-IF `[キー: コードタイプコード値リスト]` ("Code Type Code Value List") (L595)

> Handles the "Code Type Code Value List" array field (item ID: `cd_div_cd_list`).
> The key contains an index after `'/'` (e.g., `"リスト/0"`). Extracts it and resolves the type.
> If the index is `"*"`, returns `Integer.class` (reporting list size). Otherwise, parses the index, validates bounds, and delegates to the element bean.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `key.equals("コードタイプコード値リスト")` // [KEY: コードタイプコード値リスト = "コードタイプコード値リスト"] Code Type Code Value List |
| 1.1 | EXEC | `key = key.substring(separaterPoint + 1)` // [COMMENT: keyの次の要素を取得 - Extract next element after '/'] Gets index string |
| 1.2 | IF | `key.equals("*")` // Wildcard: request list size |
| 1.2.1 | RETURN | `return Integer.class` // [COMMENT: インデックス値の代わりに"*"が指定されていたら、リストの要素数を返す - Returns list element count when "*" is specified] |
| 1.3 | SET | `tmpIndexInt = null` |
| 1.4 | TRY | `tmpIndexInt = Integer.valueOf(key)` // Parse index string to Integer |
| 1.4.1 | CATCH | `NumberFormatException e` // [COMMENT: インデックス値が数値文字列でない場合は、ここでnullを返す - Returns null if index is not a numeric string] |
| 1.4.1.1 | RETURN | `return null` |
| 1.5 | IF | `tmpIndexInt == null` // Guard against parsing failure |
| 1.5.1 | RETURN | `return null` |
| 1.6 | SET | `tmpIndex = tmpIndexInt.intValue()` // Convert Integer to int |
| 1.7 | IF | `tmpIndex < 0 || tmpIndex >= cd_div_cd_list_list.size()` // [COMMENT: インデックス値がリスト個数-1を超えると、ここでnullを返す - Returns null if index exceeds list size] |
| 1.7.1 | RETURN | `return null` |
| 1.8 | CAST + CALL | `((X33VDataTypeStringBean)cd_div_cd_list_list.get(tmpIndex)).typeModelData(subkey)` // Delegates type resolution to the list element bean |

**Block 7** — ELSE-IF `[キー: コードタイプ名称リスト]` ("Code Type Name List") (L620)

> Handles the "Code Type Name List" array field (item ID: `cd_div_nm_list`).
> Identical logic to Block 6 but operates on the `cd_div_nm_list_list` field.

| # | Type | Code |
|---|------|------|
| 1 | ELSE-IF | `key.equals("コードタイプ名称リスト")` // [KEY: コードタイプ名称リスト = "コードタイプ名称リスト"] Code Type Name List |
| 1.1 | EXEC | `key = key.substring(separaterPoint + 1)` // Extract index after '/' |
| 1.2 | IF | `key.equals("*")` |
| 1.2.1 | RETURN | `return Integer.class` // Returns list element count |
| 1.3 | SET | `tmpIndexInt = null` |
| 1.4 | TRY | `tmpIndexInt = Integer.valueOf(key)` |
| 1.4.1 | CATCH | `NumberFormatException e` // [COMMENT: インデックス値が数値文字列でない場合は、ここでnullを返す] |
| 1.4.1.1 | RETURN | `return null` |
| 1.5 | IF | `tmpIndexInt == null` |
| 1.5.1 | RETURN | `return null` |
| 1.6 | SET | `tmpIndex = tmpIndexInt.intValue()` |
| 1.7 | IF | `tmpIndex < 0 || tmpIndex >= cd_div_nm_list_list.size()` // [COMMENT: インデックス値がリスト個数-1を超えると、ここでnullを返す] |
| 1.7.1 | RETURN | `return null` |
| 1.8 | CAST + CALL | `((X33VDataTypeStringBean)cd_div_nm_list_list.get(tmpIndex)).typeModelData(subkey)` // Delegates to element bean |

**Block 8** — ELSE (no match) (L647)

> No key matched any known item name. Return null to indicate the item is not recognized by this Data Bean.
> [COMMENT: 条件に一致するプロパティが存在しない場合は、nullを返す - Returns null when no matching property exists]

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `cd_div_cd` | Field | Code Type Code — the dropdown code value field identifier (internal tracking ID for code type code entries) |
| `cd_div_nm` | Field | Code Type Name — the human-readable name/label field identifier (internal tracking ID for code type name entries) |
| `cd_div_cd_list_list` | Field | Code Type Code Value List — an `X33VDataTypeList` of `X33VDataTypeStringBean` instances, each representing a code type code value entry |
| `cd_div_nm_list_list` | Field | Code Type Name List — an `X33VDataTypeList` of `X33VDataTypeStringBean` instances, each representing a code type name entry |
| `select_index` | Field | Selected Index — the currently selected dropdown index value |
| `default_cd` | Field | Initial Setting Code (Default Code) — a default/fallback code value for initialization |
| コードタイプコード | Japanese term | Code Type Code — an enumerated code identifier used to classify types in the system |
| コードタイプ名称 | Japanese term | Code Type Name — the display name or label corresponding to a code type code |
| 選択インデックス | Japanese term | Selected Index — the numeric index of the currently selected item in a dropdown or list |
| 初期設定コード | Japanese term | Initial Setting Code — a default or fallback code value used during data initialization |
| コードタイプコード値リスト | Japanese term | Code Type Code Value List — an indexed collection of code type code value beans |
| コードタイプ名称リスト | Japanese term | Code Type Name List — an indexed collection of code type name beans |
| X33 | Acronym | Fujitsu Futurity X33 — the enterprise web client framework used for view-data binding |
| X33VDataTypeBeanInterface | Interface | X33 View Data Type Bean Interface — defines the contract for Data Beans to report field types to the framework |
| X33VDataTypeList | Class | X33 View Data Type List — a framework collection class holding typed bean elements |
| X33VDataTypeStringBean | Class | X33 View Data Type String Bean — a framework bean class representing a string-typed data field with value, enable, and state sub-properties |
| Data Bean | Pattern | A Java bean that holds view-layer data state and implements framework-specific interfaces for binding |
| subkey | Parameter | The sub-property name within an item (value, enable, state) that further identifies which attribute's type is being queried |
| value | subkey | The data value sub-property — the actual content of the field |
| enable | subkey | The editability flag sub-property — indicates whether the field can be edited |
| state | subkey | The UI state sub-property — describes the current display/edit state of the field |
