# Business Logic — KKW21502SFBean.typeModelData() [40 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW21502SF.KKW21502SFBean` |
| Layer | Service / View Bean (webview) |
| Module | `KKW21502SF` (Package: `eo.web.webview.KKW21502SF`) |

## 1. Role

### KKW21502SFBean.typeModelData()

This method serves as a **type resolution router** within the KKW21502SF screen bean. It determines the Java type (`Class<?>`) of data associated with a given item identifier, enabling the framework to understand what kind of data structure a particular field or nested element holds without needing runtime reflection. The method implements a **routing/dispatch pattern**, parsing a structured string key to classify the request into one of several handling strategies. It supports four distinct routing cases: (1) returning null when the key itself is null, (2) delegating to the parent class for shared information (common info) beans identified by a `//` prefix, (3) extracting the root element name when the key follows a path-style nested format (`itemA/0/itemB`), and (4) returning null for unrecognized patterns. This method acts as a **shared utility** called by the X33V view framework (via the `X33VListedBeanInterface` contract) during data binding and list rendering, where the framework queries item types to determine how to render or validate data on the screen. It plays a critical role in the bean-based view system's ability to handle polymorphic data types — primitive types (String, Long, Boolean), repeated items (lists), and nested data-type beans — by mapping textual key descriptors to their corresponding Java type information.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["typeModelData key, subkey"])
    START --> CheckNull{key equals null}
    CheckNull -->|true| ReturnNull(["return null"])
    CheckNull -->|false| CheckSubkeyNull{subkey equals null}
    CheckSubkeyNull -->|true| SetEmpty["subkey = empty string"]
    SetEmpty --> CheckCommonInfo{key starts with //}
    CheckSubkeyNull -->|false| CheckCommonInfo
    CheckCommonInfo -->|true| CallSuper["super.typeCommonInfoData(key)"]
    CallSuper --> ReturnSuper(["return super.typeCommonInfoData(key)"])
    CheckCommonInfo -->|false| FindSep["separaterPoint = key.indexOf('/')"]
    FindSep --> FindRoot{separaterPoint greater than 0}
    FindRoot -->|true| Extract["keyElement = key.substring(0, separaterPoint)"]
    Extract --> ReturnNull
    FindRoot -->|false| NoMatch["keyElement = key"]
    NoMatch --> ReturnNull
```

**CRITICAL — Constant Resolution:**

The key format conventions are defined in source code comments (not file-based constants). The key string can follow these patterns:

| Key Format | Meaning | Example |
|-----------|---------|---------|
| `itemName` | Primitive type (String, Long, Boolean) without repetition | `koumoku_name` |
| `itemName/repeated` | Repeated item, get list element type | `items/0` |
| `itemName/index` | Data-type view repeated item with index | `items/0/name` |
| `itemName/index/dataTypeItemName` | Data-type view item with explicit index and field | `items/0/koumoku_cd` |
| `itemName/*` | Data-type view repeated item, get list element count type | `items/*` |
| `//index/itemName` | Shared info (common info) view, get type info | `//0/addr_city` |
| `//index/*` | Shared info view, get list element count type | `//0/*` |

**Business descriptions of key patterns (from source comments):**
- **Item name only**: For items of type String, Long, Boolean (no repetition flag) — retrieves type information.
- **Item name / repetition flag**: For repeated items — retrieves the list element type.
- **Item name / index value**: For data-type view repeated items — retrieves type information.
- **Item name / index value / data-type view item name**: For data-type view items — retrieves type information.
- **Item name / ***: For data-type view repeated items — retrieves the list element count type.
- **// index value / item name**: For shared info view items — retrieves type information.
- **// index value / ***: For shared info view list elements — retrieves the list element count type.

The `//` prefix specifically identifies **shared info (common info) view items** — these are items whose data is shared across multiple views and requires delegation to the parent class type resolution.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The item identifier string that encodes the path to a data field. It uses a structured format to specify: the base item name, optional repetition context (index or wildcard), and optional nesting (data-type bean path). A key starting with `//` indicates a shared info (common info) view item. A null key returns null immediately. |
| 2 | `subkey` | `String` | A secondary key parameter that is used when the parent class's `typeCommonInfoData` method resolves types. Within this method, if subkey is null it is set to an empty string. Its primary role is delegated to the parent class's implementation. |

**External/Instance state read:**
| No | Field | Source | Description |
|----|-------|--------|-------------|
| 1 | `X33VDataTypeList` | Source comment (external) | A framework class that stores the order of lists for each view. The index values referenced in the `key` parameter correspond to positions within the lists held in this framework class. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `super.typeCommonInfoData` | X33VViewBaseBean | - | Reads the parent class to resolve type information for shared info (common info) view items identified by keys starting with `//`. This is a framework-level type resolution call, not a database operation. |
| - | `String.indexOf` | JDK | - | Searches the key string for delimiter positions (`//` and `/`) to classify the key format. |
| - | `String.substring` | JDK | - | Extracts a substring from the key when a root element path (`/`) is found. |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `substring` [-], `substring` [-], `substring` [-], `substring` [-]  # NOSONAR

Trace who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | KKW21502SFBean | `KKW21502SFBean.typeModelData` | `super.typeCommonInfoData [R] framework type resolution` |

**Note:** This method is part of the X33V view bean interface contract (`X33VListedBeanInterface`). It is called by the X33V framework infrastructure during view rendering and data binding phases, rather than by explicit screen logic. The `super.typeCommonInfoData()` call delegates to the parent class `X33VViewBaseBean` for shared info view type resolution.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(key == null)` (L798)

> Early return guard: if the key parameter itself is null, the method returns null immediately. This prevents NullPointerException on subsequent string operations and serves as a null-safety guard for callers that may pass incomplete data.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // key is null, no type information available |

**Block 2** — [ELSE-IF] `(subkey == null)` (L801)

> When key is not null but subkey is null, the method normalizes subkey to an empty string. This prevents null pointer issues in the parent class's `typeCommonInfoData` method and ensures consistent downstream processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `subkey = new String("");` // Normalize null subkey to empty string |

**Block 3** — [IF] `(separaterPoint == 0)` / `[key starts with '//']` (L805)

> This branch detects shared info (common info) view items. The `//` prefix at position 0 indicates that the key refers to a shared info view. Processing delegates to the parent class's `typeCommonInfoData` method, which handles the complex type resolution for shared info view data structures.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String keyElement;` // Declare local variable for key element extraction |
| 2 | SET | `int separaterPoint = key.indexOf("//");` // Check if key is a common info view indicator // keyが共通情報ビューに関する指示か否かチェック |
| 3 | CALL | `return super.typeCommonInfoData(key);` // Delegate type resolution to parent class for shared info views |

**Block 4** — [IF-ELSE] `(separaterPoint > 0)` / `key.indexOf("/")` (L811)

> For keys that do not start with `//`, this block determines whether the key represents a root-specified path (e.g., `itemA/0/itemB`). If a `/` delimiter is found, the root element name is extracted as the substring before the first slash. If no `/` is found, the entire key becomes the element name. In both cases, the method then returns null, as this method only delegates shared info types and returns null for standard data-type resolutions (which are handled by individual data-type bean implementations).

| # | Type | Code |
|---|------|------|
| 1 | SET | `separaterPoint = key.indexOf("/");` // Search for root path delimiter / keyがルート指定("項目a/0/項目b"のような)の場合を想定し、区切り符("/")を検索する |
| 2 | IF | `separaterPoint > 0` |

**Block 4.1** — [IF] `[separaterPoint > 0]` (L812)

> The key contains a `/` delimiter, indicating a nested path format. Extract the root element name by taking the substring before the first slash.

| # | Type | Code |
|---|------|------|
| 1 | SET | `keyElement = key.substring(0, separaterPoint);` // Extract root element name from nested path |

**Block 4.2** — [ELSE] `[separaterPoint <= 0]` (L814)

> No `/` delimiter found in the key. The entire key string is treated as the element name directly.

| # | Type | Code |
|---|------|------|
| 1 | SET | `keyElement = key;` // Use full key as element name |

**Block 5** — [RETURN] (L817)

> Default return: for non-shared-info keys, the method returns null. Type resolution for standard data-type beans is handled by the individual bean's own `typeModelData` implementation (e.g., for String, Long, Boolean, or nested data-type view beans).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Standard data types resolved by individual bean implementations |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `typeModelData` | Method | Type model data — resolves the Java `Class<?>` type for a given item key within the view framework |
| `key` | Parameter | Item key — a structured string identifier that encodes the full path to a data field, including repetition indices and nested item references |
| `subkey` | Parameter | Sub key — a secondary identifier used alongside the key for shared info view type resolution |
| `//` (double slash) | Format constant | Shared info (common info) view prefix — indicates that the key refers to a data item whose view is shared across multiple screens/views |
| `X33VViewBaseBean` | Class | Base view bean — the parent class providing shared view bean infrastructure including `typeCommonInfoData` for common info type resolution |
| `X33VListedBeanInterface` | Interface | Listed bean interface — defines the contract for beans that participate in list-based view rendering, including the `typeModelData` method |
| `X33VDataTypeList` | Class (framework) | Data type list — framework class holding the ordered list of view data types; index values in the key parameter reference positions in these lists |
| **Common Info View** | Business term | Shared info (common information) view — a view type where data items are shared across multiple screens, requiring special type resolution through the parent class |
| **Data-Type View Bean** | Business term | Nested view bean — a bean that represents a structured data type with multiple fields, used for repeated/complex items in forms |
| **Repeated Item** | Business term | Repetition flag item — a data field that appears multiple times (as a list), where the key encodes repetition context |
| **Root Element** | Technical term | The top-level item name extracted from a nested path key (e.g., `koumoku_cd` from `koumoku_cd/0/name`) |
