# Business Logic — KKW01027SF01DBean.typeModelData() [100 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKA15001SF.KKW01027SF01DBean` |
| Layer | Web View / Data Bean (View layer — X33V data type bean implementing X33VDataTypeBeanInterface) |
| Module | `KKA15001SF` (Package: `eo.web.webview.KKA15001SF`) |

## 1. Role

### KKW01027SF01DBean.typeModelData()

This method serves as the central data-type dispatcher for the KKW01027SF01 screen, which manages customer service contract modifications (顧客契約変更 — keiyaku henkou) within K-Opticom's telecom operations platform. It implements the X33VDataTypeBeanInterface contract: given a field name (`key`) and a sub-property name (`subkey`), it returns the Java `Class<?>` that represents the data type of the requested property. This enables the X33V framework to dynamically understand the type schema of the bean's fields at runtime — critical for rendering form elements, performing client-side validation, and binding data to UI components.

The method uses a routing/dispatch pattern: it branches on the `key` to identify one of seven supported data fields (SYSID, service contract number, transfer division, transfer reason code, transfer reason memo, application number, or application detail number), then further dispatches on `subkey` to determine which sub-property's type is requested. For scalar fields (most branches), it always returns `String.class` when `subkey` is `"value"` or `"state"` — corresponding to the data value and validation status of each field respectively.

The one exception is the transfer reason code field ("異動理由コード"), which supports indexed list access. When `subkey` is `"*"` it returns `Integer.class` to report the list element count; when `subkey` is an integer index it delegates to the individual list item's `typeModelData()` method, enabling per-element type introspection on a data-type bean list (X33VDataTypeList of X33VDataTypeStringBean).

This method plays a foundational role in the screen's data binding layer. It is called by the parent bean `KKW01027SFBean` during the X33V framework's load cycle to resolve field types dynamically, allowing the UI framework to correctly instantiate and type fields without hard-coded schema definitions.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["typeModelData key subkey"])

    START --> CHECK_NULL["Check key or subkey is null"]

    CHECK_NULL --> |"null"| RET_NULL["return null"]

    CHECK_NULL --> |"both present"| FIND_SLASH["indexOf '/' in key"]

    FIND_SLASH --> C1["key equals SYSID"]

    C1 --> |"true"| C1A["subkey equals value"]
    C1A --> |"true"| RET1["return String.class"]
    C1 --> |"false"| C1B["subkey equals state"]
    C1B --> |"true"| RET2["return String.class"]

    C1 --> |"false"| C2["key equals service contract number"]

    C2 --> |"true"| C2A["subkey equals value"]
    C2A --> |"true"| RET3["return String.class"]
    C2 --> |"false"| C2B["subkey equals state"]
    C2B --> |"true"| RET4["return String.class"]

    C2 --> |"false"| C3["key equals transfer division"]

    C3 --> |"true"| C3A["subkey equals value"]
    C3A --> |"true"| RET5["return String.class"]
    C3 --> |"false"| C3B["subkey equals state"]
    C3B --> |"true"| RET6["return String.class"]

    C3 --> |"false"| C4["key equals transfer reason code"]

    C4 --> |"true"| SUBSTRING["key = substring after first slash"]

    SUBSTRING --> C4A["key equals asterisk"]

    C4A --> |"true"| RET7["return Integer.class (list count)"]

    C4A --> |"false"| PARSE["parseInt key as tmpIndexInt"]

    PARSE --> CATCH["catch NumberFormatException"]
    CATCH --> RET_NULL

    PARSE --> OK_PARSE["tmpIndexInt valid"]

    OK_PARSE --> BOUNDS["tmpIndex out of bounds"]

    BOUNDS --> |"invalid"| RET_NULL

    BOUNDS --> |"valid"| GET["get item from idorsn_cd_list"]

    GET --> DELEGATE["call typeModelData on bean"]

    DELEGATE --> RET8["return bean.typeModelData(subkey)"]

    C4 --> |"false"| C5["key equals transfer reason memo"]

    C5 --> |"true"| C5A["subkey equals value"]
    C5A --> |"true"| RET9["return String.class"]
    C5 --> |"false"| C5B["subkey equals state"]
    C5B --> |"true"| RET10["return String.class"]

    C5 --> |"false"| C6["key equals application number"]

    C6 --> |"true"| C6A["subkey equals value"]
    C6A --> |"true"| RET11["return String.class"]
    C6 --> |"false"| C6B["subkey equals state"]
    C6B --> |"true"| RET12["return String.class"]

    C6 --> |"false"| C7["key equals application detail number"]

    C7 --> |"true"| C7A["subkey equals value"]
    C7A --> |"true"| RET13["return String.class"]
    C7 --> |"false"| C7B["subkey equals state"]
    C7B --> |"true"| RET14["return String.class"]

    C7 --> |"false"| FINAL["return null"]

    RET_NULL --> END(["End"])
    RET1 --> END
    RET2 --> END
    RET3 --> END
    RET4 --> END
    RET5 --> END
    RET6 --> END
    RET7 --> END
    RET8 --> END
    RET9 --> END
    RET10 --> END
    RET11 --> END
    RET12 --> END
    RET13 --> END
    RET14 --> END
    FINAL --> END
```

**CRITICAL — Constant Resolution:**
This method does not use any named constants in its conditions. The branch keys are hardcoded Japanese field labels:
- `"SYSID"` — System ID field (item ID: sysid)
- `"サービス契約番号"` — Service Contract Number (item ID: svc_kei_no)
- `"異動区分"` — Transfer Division (item ID: ido_div)
- `"異動理由コード"` — Transfer Reason Code (item ID: ido_rsn_cd)
- `"異動理由メモ"` — Transfer Reason Memo (item ID: ido_rsn_memo)
- `"申込番号"` — Application Number (item ID: mskm_no)
- `"申込明細番号"` — Application Detail Number (item ID: mskm_dtl_no)

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The field name (項目名) identifying which data property to inspect. Must match one of seven known Japanese field labels: "SYSID" (system identifier), "サービス契約番号" (service contract number), "異動区分" (transfer division), "異動理由コード" (transfer reason code — may include `/index` suffix for list indexing), "異動理由メモ" (transfer reason memo), "申込番号" (application number), or "申込明細番号" (application detail number). |
| 2 | `subkey` | `String` | The sub-property name within the field. For scalar fields, valid values are `"value"` (returns the data type of the field's value) or `"state"` (returns the data type of the field's validation status). For the transfer reason code field, it can also be `"*"` (returns Integer.class for list count) or an integer string like `"0"`, `"1"`, etc. (returns the type of that indexed list element). |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `ido_rsn_cd_list` | `X33VDataTypeList` | Transfer reason code list — a dynamic list of transfer reason entries, each element being an X33VDataTypeStringBean. Used for indexed access when subkey specifies a list index. |

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `X33VDataTypeStringBean.typeModelData` | (framework method) | - | Delegates to the individual bean in the transfer reason code list to resolve its sub-property type. No external service or database interaction. |
| - | `KKW01027SF01DBean.typeModelData` | KKW01027SF01DBean | - | Self-recursive call (via list item bean) for the transfer reason code branch when subkey is an index. Pure in-memory type introspection. |

**Note:** This method performs no direct CRUD operations (Create/Read/Update/Delete) against any database or service component. It is a pure type-resolution utility operating entirely in-memory. The only external call is delegation to `X33VDataTypeStringBean.typeModelData(subkey)` on list elements of `ido_rsn_cd_list`, which similarly performs type introspection without I/O.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKW01027SF | `KKW01027SFBean` (X33V framework) -> `typeModelData` (inherited or overridden via X33VDataTypeBeanInterface) -> `KKW01027SF01DBean.typeModelData(key, subkey)` | `N/A (pure type introspection, no CRUD endpoints)` |
| 2 | Screen:KKW01027SF | `KKW01027SFBean` -> `typeModelData` (via X33V framework bean loading) -> `KKW01027SF01DBean.typeModelData` (for "異動理由コード" with index subkey) -> `X33VDataTypeStringBean.typeModelData(subkey)` | `N/A (pure type introspection, no CRUD endpoints)` |

**Instructions:**

The `typeModelData` method is part of the X33V view framework's data binding contract. It is invoked automatically by the X33V framework (not by explicit Java code calls from other application classes) during the bean initialization and rendering lifecycle. The parent bean `KKW01027SFBean` (KKA15001SF) holds the view context and the framework routes type-lookup requests to this method via the `X33VDataTypeBeanInterface` implementation.

No other external screens, CBS, or SC components directly call this method. It is exclusively a framework-level callback used for dynamic type resolution.

## 6. Per-Branch Detail Blocks

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

> Guard clause: if either parameter is null, return null immediately.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Returns null if key or subkey is null — prevents NPE in subsequent branch comparisons |

**Block 2** — SET (slash index calculation) (L510)

| # | Type | Code |
|---|------|------|
| 1 | SET | `int separaterPoint = key.indexOf("/");` // Finds the first '/' position in key for potential indexed field access |

**Block 3** — ELSE-IF (SYSID field) `(key.equals("SYSID"))` (L513)

> Handles the system ID field (項目ID: sysid). Branches on subkey to return the type of the data value or its validation status.

**Block 3.1** — IF (subkey equals "value") (L514)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // SYSID value is a String |

**Block 3.2** — ELSE-IF (subkey equals "state") (L515)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // SYSID validation state is a String |

**Block 4** — ELSE-IF (Service Contract Number field) `(key.equals("サービス契約番号"))` (L522)

> Handles the service contract number field (項目ID: svc_kei_no). Branches on subkey for value or state type.

**Block 4.1** — IF (subkey equals "value") (L523)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // Service contract number value is a String |

**Block 4.2** — ELSE-IF (subkey equals "state") (L525)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // Service contract number validation state is a String |

**Block 5** — ELSE-IF (Transfer Division field) `(key.equals("異動区分"))` (L530)

> Handles the transfer division field (項目ID: ido_div), which classifies the type of service transfer/change.

**Block 5.1** — IF (subkey equals "value") (L531)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // Transfer division value is a String |

**Block 5.2** — ELSE-IF (subkey equals "state") (L533)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // Transfer division validation state is a String |

**Block 6** — ELSE-IF (Transfer Reason Code field) `(key.equals("異動理由コード"))` (L538)

> Handles the transfer reason code field (項目ID: ido_rsn_cd). This is the most complex branch — it supports indexed list access.
>
> The key may contain a '/' followed by an index (e.g., `"異動理由コード/0"` or `"異動理由コード/*"`). The method extracts the part after the first slash and processes it.

**Block 6.1** — SET (extract index portion from key) (L540)

| # | Type | Code |
|---|------|------|
| 1 | SET | `key = key.substring(separaterPoint + 1);` // Extracts the portion after '/' — e.g., `"0"` from `"異動理由コード/0"` or `"*"` for list count |

**Block 6.2** — IF (subkey equals "*") (L542)

> When `*` is specified as the index, return Integer.class to report the list element count (list item count).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return Integer.class;` // "If '*' is specified as the index value, return the number of list elements" |

**Block 6.3** — ELSE (parse integer index) (L544)

> Attempts to parse the key substring as an integer to use as a list index.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Integer tmpIndexInt = null;` // Initialize index variable |
| 2 | TRY | `tmpIndexInt = Integer.valueOf(key);` // Parse key substring as Integer |

**Block 6.3.1** — CATCH (NumberFormatException) (L548)

> If the key substring is not a valid number, return null — the framework will handle this gracefully.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Returns null if index value is not a numeric string |

**Block 6.4** — IF (tmpIndexInt is null) (L552)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Safety check if tmpIndexInt is null after parse |

**Block 6.5** — SET (extract int value) (L554)

| # | Type | Code |
|---|------|------|
| 1 | SET | `int tmpIndex = tmpIndexInt.intValue();` // Converts Integer wrapper to primitive int |

**Block 6.6** — IF (index bounds check) `(tmpIndex < 0 || tmpIndex >= ido_rsn_cd_list.size())` (L556)

> Validates the index is within the bounds of the transfer reason code list. If out of bounds, return null.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Returns null if index exceeds list size - 1 |

**Block 6.7** — CALL (delegate to list item bean) (L558)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `((X33VDataTypeStringBean)ido_rsn_cd_list.get(tmpIndex)).typeModelData(subkey);` // Retrieves the bean at the specified index and delegates subkey resolution to it |

**Block 7** — ELSE-IF (Transfer Reason Memo field) `(key.equals("異動理由メモ"))` (L562)

> Handles the transfer reason memo field (項目ID: ido_rsn_memo), a free-text memo field for transfer reasons.

**Block 7.1** — IF (subkey equals "value") (L563)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // Transfer reason memo value is a String |

**Block 7.2** — ELSE-IF (subkey equals "state") (L565)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // Transfer reason memo validation state is a String |

**Block 8** — ELSE-IF (Application Number field) `(key.equals("申込番号"))` (L570)

> Handles the application number field (項目ID: mskm_no), the identifier for a service contract application.

**Block 8.1** — IF (subkey equals "value") (L571)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // Application number value is a String |

**Block 8.2** — ELSE-IF (subkey equals "state") (L573)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // Application number validation state is a String |

**Block 9** — ELSE-IF (Application Detail Number field) `(key.equals("申込明細番号"))` (L578)

> Handles the application detail number field (項目ID: mskm_dtl_no), the identifier for a specific line item within an application.

**Block 9.1** — IF (subkey equals "value") (L579)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // Application detail number value is a String |

**Block 9.2** — ELSE-IF (subkey equals "state") (L581)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return String.class;` // Application detail number validation state is a String |

**Block 10** — RETURN (no matching key) (L585)

> No condition matched — the key does not correspond to any known field. Returns null.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return null;` // Returns null if no matching property exists — framework treats as unknown field |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `sysid` | Field | System ID — a unique system-generated identifier for the record, used for internal tracking and state management |
| `svc_kei_no` | Field | Service Contract Number — the primary identifier for a customer's service contract line item |
| `ido_div` | Field | Transfer Division (異動区分) — classifies the type of service transfer or change being performed (e.g., new connection, modification, cancellation) |
| `ido_rsn_cd` | Field | Transfer Reason Code (異動理由コード) — a coded reason for the service transfer/change; stored as a list of entries allowing multiple reasons |
| `ido_rsn_memo` | Field | Transfer Reason Memo (異動理由メモ) — a free-text memo field for additional notes on the transfer reason |
| `mskm_no` | Field | Application Number (申込番号) — the identifier for a service contract application request |
| `mskm_dtl_no` | Field | Application Detail Number (申込明細番号) — the identifier for a specific line item/detail within an application |
| `X33VDataTypeBeanInterface` | Interface | Fujitsu X33V framework interface for beans that provide dynamic type information for their properties |
| `X33VDataTypeList` | Class | X33V framework container for lists of typed data bean instances |
| `X33VDataTypeStringBean` | Class | X33V framework bean representing a string-typed data field with value and state sub-properties |
| `subkey "value"` | Parameter value | Requests the data type of the field's actual data value |
| `subkey "state"` | Parameter value | Requests the data type of the field's validation/error status |
| `subkey "*"` | Parameter value | Requests the data type of the list element count (returns Integer.class) |
| KKW01027SF | Screen | Customer service contract modification screen — manages changes to existing customer service contracts |
| X33V | Technology | Fujitsu's Web Client tool / view framework for building Java EE web applications |
