# Business Logic — KKW00129SF01DBean.typeModelData() [133 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKA17701SF.KKW00129SF01DBean` |
| Layer | Utility / DTO (View Bean — Data type metadata router) |
| Module | `KKA17701SF` (Package: `eo.web.webview.KKA17701SF`) |

## 1. Role

### KKW00129SF01DBean.typeModelData()

This method serves as a **data type metadata router** within the KKA17701SF web screen bean. Its business purpose is to determine the Java runtime type of any given data field in the screen's model based on the field's name (`key`) and sub-field identifier (`subkey`). It is called by the X33F view framework during dynamic data binding, specifically when the framework needs to resolve the type of a field at runtime for rendering, validation, or form population.

The method implements a **routing/dispatch design pattern**: it evaluates the `key` parameter against six known field categories — three scalar types (Code Value, Code Type Name, Select Index) and three array/list types (Initial Setup Code List, Code List, Code Name List) — and returns the appropriate `Class<?>` type. For scalar fields, it resolves to either `String.class` (for value and state subkeys) or `Boolean.class` (for the enable subkey). For list fields, the `key` follows an indexed path format (`key/index`) where `"*"` returns `Integer.class` (indicating list size) and numeric indices delegate to the inner `X33VDataTypeStringBean.typeModelData(subkey)` to determine the element type.

This method plays a **shared utility role** across the entire KKA17701SF screen — it is not an entry point but a type-resolution utility called by the X33V framework at various stages (load, save, render) to resolve data binding metadata. It has no side effects (pure function), making it safe to invoke freely during any screen lifecycle phase.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["typeModelData key, subkey"])
    START --> checkNull["key == null or subkey == null"]
    checkNull -->|true| retNull["Return null"]
    checkNull -->|false| findSep["Get indexOf '/' from key"]
    findSep --> codeVal["key equals Code Value"]
    codeVal -->|true| subkeyCheck["subkey matches value / enable / state"]
    subkeyCheck --> codeValReturns["Return String.class or Boolean.class"]
    codeVal --> codeTypeNm["key equals Code Type Name"]
    codeTypeNm -->|true| subkeyCheck2["subkey matches value / enable / state"]
    subkeyCheck2 --> codeTypeReturns["Return String.class or Boolean.class"]
    codeTypeNm --> selIdx["key equals Select Index"]
    selIdx -->|true| subkeyCheck3["subkey matches value / enable / state"]
    subkeyCheck3 --> selIdxReturns["Return String.class or Boolean.class"]
    selIdx --> initCdList["key equals Initial Setup Code List"]
    initCdList -->|true| initCdBranch["Parse index, validate bounds, delegate to default_cd_list_list"]
    initCdList --> cdList["key equals Code List"]
    cdList -->|true| cdBranch["Parse index, validate bounds, delegate to cd_div_cd_list_list"]
    cdList --> cdNmList["key equals Code Name List"]
    cdNmList -->|true| cdNmBranch["Parse index, validate bounds, delegate to cd_div_nm_list_list"]
    cdNmList --> retNull2["Return null"]
    codeValReturns --> END(["Return / Next"])
    codeTypeReturns --> END
    selIdxReturns --> END
    initCdBranch --> END
    cdBranch --> END
    cdNmBranch --> END
    retNull --> END
    retNull2 --> END
```

**Processing flow:**

1. **Null guard** — If either parameter is `null`, returns `null` immediately (early exit).
2. **Separator extraction** — Computes the position of the first `/` character in `key` (used by list-type branches to locate the index portion).
3. **Scalar field routing** — Checks `key` against three scalar field categories ("Code Value", "Code Type Name", "Select Index"). For each, checks `subkey` against `"value"`, `"enable"`, and `"state"` (case-insensitive) and returns `String.class` for value/state, `Boolean.class` for enable.
4. **List field routing** — For three list-type fields ("Initial Setup Code List", "Code List", "Code Name List"), extracts the index portion from `key` by stripping everything up to and including the `/` separator. Supports `"*"` (returns `Integer.class` for list size) and numeric indices (parses, validates bounds against the list, then delegates to `X33VDataTypeStringBean.typeModelData(subkey)` on the element at that index).
5. **Fallback** — If no category matches, returns `null`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The field name / item identifier in the screen model. Can be a simple field name (e.g., "コード値" for Code Value) or a path-style identifier with index for list fields (e.g., "コードリスト/0" for the first element of the Code List). |
| 2 | `subkey` | `String` | The sub-field identifier within a field. For scalar types, this is one of: "value" (the data value), "enable" (whether the field is editable), or "state" (the display/state status). For list elements, this is forwarded to the inner bean's `typeModelData(subkey)`. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `default_cd_list_list` | `X33VDataTypeList` | Initial Setup Code List — holds a list of `X33VDataTypeStringBean` objects representing the initial setup code configuration entries |
| `cd_div_cd_list_list` | `X33VDataTypeList` | Code List — holds a list of `X33VDataTypeStringBean` objects representing code value entries |
| `cd_div_nm_list_list` | `X33VDataTypeList` | Code Name List — holds a list of `X33VDataTypeStringBean` objects representing code name entries |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `String.indexOf` | JDK | - | String search — finds the position of `/` separator in key |
| - | `String.equals` | JDK | - | String comparison — matches key against known field names |
| - | `String.equalsIgnoreCase` | JDK | - | Case-insensitive comparison — matches subkey against "value", "enable", "state" |
| - | `String.substring` | JDK | - | Extracts the index portion from key (after the `/` separator) for list-type fields |
| - | `X33VDataTypeList.size` | X33V | - | Gets the number of elements in a data type list |
| - | `X33VDataTypeList.get` | X33V | - | Retrieves an element at a specific index from a data type list |
| - | `Integer.valueOf` | JDK | - | Parses the index string to an Integer |
| - | `X33VDataTypeStringBean.typeModelData` | X33V | - | Delegates to inner bean's type resolution for list element subkeys |

**Classification notes:** This method performs **no database operations** (no C/R/U/D). It is a pure type-resolution function that reads from in-memory list objects (`X33VDataTypeList`) and delegates to inner bean methods. All operations are Java standard library or X33V framework calls.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen: KKA17701SF | `KKW00129SF01DBean.typeModelData` (self-call) | N/A — type resolution only, no SC/CRUD |

**Notes:** The pre-computed call graph shows this method is called from within `KKW00129SF01DBean` itself (likely by the X33V framework via reflection or interface methods). It is invoked by the X33F view framework during data binding resolution. No database or SC endpoints are reached.

## 6. Per-Branch Detail Blocks

**Block 1** — IF (null guard) (L562)

> If either key or subkey is null, returns null immediately. This prevents NPE in downstream operations.

| # | Type | Code |
|---|------|------|
| 1 | COND | `key == null \|\| subkey == null` [-> null check] |
| 2 | RETURN | `return null;` // Early exit on null inputs |

---

**Block 2** — SET (separator position extraction) (L567)

> Computes the position of the first `/` character in key. Used by list-type branches to locate the index segment of path-style keys like "コードリスト/0".

| # | Type | Code |
|---|------|------|
| 1 | SET | `int separaterPoint = key.indexOf("/")` // Position of first '/' in key |

---

**Block 3** — IF-ELSE-IF (scalar field: Code Value) (L571)

> Handles the "Code Value" field (item ID: `cd_div_cd`). This is a scalar field where the code value and its metadata (enable, state) are stored.

| # | Type | Code |
|---|------|------|
| 1 | COND | `key.equals("コード値")` [-> "コード値" = "Code Value"] |
| 2 | IF-ELSE-IF | See Block 3.1–3.3 for subkey branches |
| 3 | RETURN | `return String.class` // For "value" subkey |
| 4 | RETURN | `return Boolean.class` // For "enable" subkey |
| 5 | RETURN | `return String.class` // For "state" subkey |

**Block 3.1** — nested IF (subkey: value) (L572)

> Returns the data value type for a code value field.

| # | Type | Code |
|---|------|------|
| 1 | COND | `subkey.equalsIgnoreCase("value")` [-> case-insensitive check for "value"] |
| 2 | RETURN | `return String.class` // The code value is stored as a string |

**Block 3.2** — nested ELSE-IF (subkey: enable) (L575)

> Returns the enabled-state type for a code value field.

| # | Type | Code |
|---|------|------|
| 1 | COND | `subkey.equalsIgnoreCase("enable")` [-> case-insensitive check for "enable"] |
| 2 | RETURN | `return Boolean.class` // Enabled/disabled is a boolean flag |

**Block 3.3** — nested ELSE-IF (subkey: state) (L578)

> Returns the display-state type for a code value field.

| # | Type | Code |
|---|------|------|
| 1 | COND | `subkey.equalsIgnoreCase("state")` [-> case-insensitive check for "state"] |
| 2 | RETURN | `return String.class` // State/status is stored as a string |

---

**Block 4** — ELSE-IF (scalar field: Code Type Name) (L585)

> Handles the "Code Type Name" field (item ID: `cd_div_nm`). Functionally identical to Code Value but refers to the code's descriptive name rather than its code value.

| # | Type | Code |
|---|------|------|
| 1 | COND | `key.equals("コードタイプ名称")` [-> "コードタイプ名称" = "Code Type Name"] |
| 2 | IF-ELSE-IF | See Block 4.1–4.3 for subkey branches |

**Block 4.1** — nested IF (subkey: value) (L586)

| # | Type | Code |
|---|------|------|
| 1 | COND | `subkey.equalsIgnoreCase("value")` |
| 2 | RETURN | `return String.class` |

**Block 4.2** — nested ELSE-IF (subkey: enable) (L589)

| # | Type | Code |
|---|------|------|
| 1 | COND | `subkey.equalsIgnoreCase("enable")` |
| 2 | RETURN | `return Boolean.class` |

**Block 4.3** — nested ELSE-IF (subkey: state) (L592)

| # | Type | Code |
|---|------|------|
| 1 | COND | `subkey.equalsIgnoreCase("state")` |
| 2 | RETURN | `return String.class` |

---

**Block 5** — ELSE-IF (scalar field: Select Index) (L599)

> Handles the "Select Index" field (item ID: `select_index`). This represents the index of a selected item in a dropdown/select control.

| # | Type | Code |
|---|------|------|
| 1 | COND | `key.equals("選択インデックス")` [-> "選択インデックス" = "Select Index"] |
| 2 | IF-ELSE-IF | See Block 5.1–5.3 for subkey branches |

**Block 5.1** — nested IF (subkey: value) (L600)

| # | Type | Code |
|---|------|------|
| 1 | COND | `subkey.equalsIgnoreCase("value")` |
| 2 | RETURN | `return String.class` |

**Block 5.2** — nested ELSE-IF (subkey: enable) (L603)

| # | Type | Code |
|---|------|------|
| 1 | COND | `subkey.equalsIgnoreCase("enable")` |
| 2 | RETURN | `return Boolean.class` |

**Block 5.3** — nested ELSE-IF (subkey: state) (L606)

| # | Type | Code |
|---|------|------|
| 1 | COND | `subkey.equalsIgnoreCase("state")` |
| 2 | RETURN | `return String.class` |

---

**Block 6** — ELSE-IF (list field: Initial Setup Code List) (L613)

> Handles the "Initial Setup Code List" field (item ID: `default_cd_list_list`). This is a list-type field where each element is an `X33VDataTypeStringBean`. The key includes a path-style index (e.g., "初期設定コードリスト/0").

| # | Type | Code |
|---|------|------|
| 1 | COND | `key.equals("初期設定コードリスト")` [-> "初期設定コードリスト" = "Initial Setup Code List"] |
| 2 | SET | `key = key.substring(separaterPoint + 1)` // Extract index portion: strips "初期設定コードリスト/" prefix |
| 3 | IF | See Block 6.1 for wildcard check |
| 4 | TRY-CATCH | See Block 6.2–6.3 for index parsing |
| 5 | IF | `tmpIndexInt == null` [-> L638] |
| 6 | IF | Bounds check: `tmpIndex < 0 \|\| tmpIndex >= default_cd_list_list.size()` [-> L642] |
| 7 | RETURN | `((X33VDataTypeStringBean)default_cd_list_list.get(tmpIndex)).typeModelData(subkey)` [-> Delegate to inner bean] |

**Block 6.1** — nested IF (wildcard: return list size type) (L617)

> When `"*"` is specified as the index instead of a numeric value, returns `Integer.class` to indicate the list size.

| # | Type | Code |
|---|------|------|
| 1 | COND | `key.equals("*")` [-> wildcard marker for list size query] |
| 2 | RETURN | `return Integer.class` // "*" indicates the caller wants the list size type |

**Block 6.2** — TRY block (index parsing) (L620)

> Attempts to parse the key as an integer index into the list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Integer tmpIndexInt = null` |
| 2 | SET | `tmpIndexInt = Integer.valueOf(key)` // Parse index string |

**Block 6.3** — nested CATCH (NumberFormatException) (L625)

> If the index is not a valid numeric string, return null (no type resolution possible).

| # | Type | Code |
|---|------|------|
| 1 | CATCH | `catch (NumberFormatException e)` |
| 2 | RETURN | `return null` // Index is not a numeric string |

**Block 6.4** — nested IF (null check after parse) (L638)

> Defensive check: if tmpIndexInt is still null, return null.

| # | Type | Code |
|---|------|------|
| 1 | COND | `tmpIndexInt == null` |
| 2 | RETURN | `return null` |

**Block 6.5** — nested IF (bounds validation) (L642)

> Ensures the index is within the bounds of `default_cd_list_list`. If out of range, returns null.

| # | Type | Code |
|---|------|------|
| 1 | COND | `tmpIndex < 0 \|\| tmpIndex >= default_cd_list_list.size()` |
| 2 | RETURN | `return null` // Index out of range |
| 3 | SET | `int tmpIndex = tmpIndexInt.intValue()` |
| 4 | RETURN | `((X33VDataTypeStringBean)default_cd_list_list.get(tmpIndex)).typeModelData(subkey)` // Delegate to inner bean |

---

**Block 7** — ELSE-IF (list field: Code List) (L645)

> Handles the "Code List" field (item ID: `cd_div_cd_list_list`). Functionally identical to Block 6 but operates on the Code List list instead of the Initial Setup Code List.

| # | Type | Code |
|---|------|------|
| 1 | COND | `key.equals("コードリスト")` [-> "コードリスト" = "Code List"] |
| 2 | SET | `key = key.substring(separaterPoint + 1)` |
| 3 | IF | Wildcard check → `return Integer.class` |
| 4 | TRY-CATCH | Index parsing |
| 5 | IF | Bounds check against `cd_div_cd_list_list.size()` |
| 6 | RETURN | `((X33VDataTypeStringBean)cd_div_cd_list_list.get(tmpIndex)).typeModelData(subkey)` |

**Block 7.1** — nested IF (wildcard) (L649)

| # | Type | Code |
|---|------|------|
| 1 | COND | `key.equals("*")` |
| 2 | RETURN | `return Integer.class` |

**Block 7.2** — TRY-CATCH (parse + bounds) (L652–L658)

| # | Type | Code |
|---|------|------|
| 1 | SET | `Integer tmpIndexInt = null` |
| 2 | SET | `tmpIndexInt = Integer.valueOf(key)` |
| 3 | CATCH | `catch (NumberFormatException e) { return null; }` |
| 4 | COND | `tmpIndex < 0 \|\| tmpIndex >= cd_div_cd_list_list.size()` |
| 5 | RETURN | `return null` |
| 6 | RETURN | `((X33VDataTypeStringBean)cd_div_cd_list_list.get(tmpIndex)).typeModelData(subkey)` |

---

**Block 8** — ELSE-IF (list field: Code Name List) (L661)

> Handles the "Code Name List" field (item ID: `cd_div_nm_list_list`). Same logic as Blocks 6 and 7 but operates on the Code Name List.

| # | Type | Code |
|---|------|------|
| 1 | COND | `key.equals("コード名リスト")` [-> "コード名リスト" = "Code Name List"] |
| 2 | SET | `key = key.substring(separaterPoint + 1)` |
| 3 | IF | Wildcard check → `return Integer.class` |
| 4 | TRY-CATCH | Index parsing |
| 5 | IF | Bounds check against `cd_div_nm_list_list.size()` |
| 6 | RETURN | `((X33VDataTypeStringBean)cd_div_nm_list_list.get(tmpIndex)).typeModelData(subkey)` |

**Block 8.1** — nested IF (wildcard) (L665)

| # | Type | Code |
|---|------|------|
| 1 | COND | `key.equals("*")` |
| 2 | RETURN | `return Integer.class` |

**Block 8.2** — TRY-CATCH (parse + bounds) (L668–L674)

| # | Type | Code |
|---|------|------|
| 1 | SET | `Integer tmpIndexInt = null` |
| 2 | SET | `tmpIndexInt = Integer.valueOf(key)` |
| 3 | CATCH | `catch (NumberFormatException e) { return null; }` |
| 4 | COND | `tmpIndex < 0 \|\| tmpIndex >= cd_div_nm_list_list.size()` |
| 5 | RETURN | `return null` |
| 6 | RETURN | `((X33VDataTypeStringBean)cd_div_nm_list_list.get(tmpIndex)).typeModelData(subkey)` |

---

**Block 9** — ELSE (fallback) (L681)

> If no condition matches, returns null. This is the default case for unrecognized field names.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // No matching field category found |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `コード値` | Field | Code Value — the actual code value of a code-type field. Item ID: `cd_div_cd` |
| `コードタイプ名称` | Field | Code Type Name — the descriptive name of a code type field. Item ID: `cd_div_nm` |
| `選択インデックス` | Field | Select Index — the index of a selected item in a dropdown/select list. Item ID: `select_index` |
| `初期設定コードリスト` | Field | Initial Setup Code List — a list of code configurations for initial/default settings. Item ID: `default_cd_list_list` |
| `コードリスト` | Field | Code List — a list of code value entries. Item ID: `cd_div_cd_list_list` |
| `コード名リスト` | Field | Code Name List — a list of code name entries. Item ID: `cd_div_nm_list_list` |
| `cd_div_cd_update` | Field | Code Value update flag — tracks whether the code value has been modified |
| `cd_div_cd_enabled` | Field | Code Value enabled flag — whether the code value field is editable |
| `cd_div_cd_state` | Field | Code Value state — display/state metadata for the code value |
| `cd_div_nm_update` | Field | Code Type Name update flag |
| `cd_div_nm_enabled` | Field | Code Type Name enabled flag |
| `cd_div_nm_state` | Field | Code Type Name state |
| `select_index_update` | Field | Select Index update flag |
| `select_index_value` | Field | Select Index value |
| `select_index_enabled` | Field | Select Index enabled flag |
| `select_index_state` | Field | Select Index state |
| `value` | Subkey | The data value of a field |
| `enable` | Subkey | Whether the field is enabled (editable) |
| `state` | Subkey | The display state of a field |
| `*` | Constant | Wildcard marker — when used as index, returns Integer.class to indicate list size |
| `X33VDataTypeList` | Type | X33F framework type — a dynamic list data type holder for view beans |
| `X33VDataTypeStringBean` | Type | X33F framework type — a data type bean for string-based fields, used as list element type |
| `X33VDataTypeBeanInterface` | Interface | X33F framework interface — defines type resolution contract for data type beans |
| `X33VListedBeanInterface` | Interface | X33F framework interface — defines contract for list-type beans |
| `subkey` | Parameter | Sub-field identifier — specifies which metadata field of a data type is being queried (value/enable/state) |
| `separaterPoint` | Variable | Index position of `/` in key — used to split list-type keys into field name and index |
