# Business Logic — KKW00130SF01DBean.storeModelData() [67 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW00130SF.KKW00130SF01DBean` |
| Layer | Data Access / UI Bean Component — part of the K-Opticom telecom order system's web layer, serving as a data-holding bean for screen state management |
| Module | `KKW00130SF` (Package: `eo.web.webview.KKW00130SF`) |

## 1. Role

### KKW00130SF01DBean.storeModelData()

This method serves as a **centralized data router and dispatcher** for the KKW00130SF screen bean, responsible for storing incoming data into the appropriate internal model fields based on a string key and subkey identifier. It implements a **conditional dispatch pattern** (if/else chain) that examines the `key` parameter to determine which data category the value belongs to, then routes the `in_value` to the correct setter method or nested bean.

The method handles three distinct business data categories: (1) **追加字 (Tsuihashi — "append text/extra field")** which stores index value and state strings for screen display purposes, (2) **コードリスト (Kodo Risuto — "code list")** which delegates data storage into individual elements of a code list array (cd_list_list), and (3) **コード名リスト (Kodo Me Risuto — "code name list")** which delegates data storage into a code name list array (cd_nm_list_list). For array-based lists, it parses an index from the key (using slash-delimited format like `"cd_list/0"`) and delegates to the corresponding element bean's own `storeModelData` method.

In the larger system, this bean acts as a **shared UI model container** called by various screen presentation components to populate form data, update field states, and maintain the view state of the 請求書情報表示 (Request Sheet Information Display) screen. The method enables a uniform data storage interface regardless of whether the target is a direct field, a typed string bean in a list, or a typed long bean (when `isSetAsString` is true).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["storeModelData key, subkey, in_value, isSetAsString"])
    START --> NULL_CHECK["key equals null or subkey equals null"]
    NULL_CHECK -->|true| EARLY_RETURN["Return early"]
    NULL_CHECK -->|false| FIND_SEP["Find separator position in key"]
    FIND_SEP --> KEY_CHECK{"key branch"}
    KEY_CHECK -->|"追加字"| SUB_CHECK{"subkey equals value"}
    SUB_CHECK -->|true| SET_VALUE["setIndex_value"]
    SUB_CHECK -->|false| SUB_STATE{"subkey equals state"}
    SUB_STATE -->|true| SET_STATE["setIndex_state"]
    SUB_STATE -->|false| SKIP_A["Skip"]
    KEY_CHECK -->|"コードリスト"| PARSE_INT_INT["Parse Integer from key substring"]
    KEY_CHECK -->|other| SKIP_C["Skip"]
    PARSE_INT_INT -->|success| BOUNDS_CHECK{"index valid for cd_list_list"}
    BOUNDS_CHECK -->|true| DELEGATE_CD["Store data into cd_list element"]
    BOUNDS_CHECK -->|false| SKIP_B["Skip"]
    PARSE_INT_INT -->|NumberFormatException| SKIP_B
    SKIP_A --> KEY_CHECK2{"next branch"}
    SKIP_B --> KEY_CHECK2
    KEY_CHECK2 -->|"コード名リスト"| PARSE_INT_NM["Parse Integer from key substring"]
    PARSE_INT_NM -->|success| BOUNDS_CHECK_NM{"index valid for cd_nm_list_list"}
    BOUNDS_CHECK_NM -->|true| DELEGATE_NM["Store data into cd_nm_list element"]
    BOUNDS_CHECK_NM -->|false| SKIP_D["Skip"]
    PARSE_INT_NM -->|NumberFormatException| SKIP_D
    SKIP_C --> SKIP_D
    DELEGATE_CD --> END_NODE
    DELEGATE_NM --> END_NODE
    SET_VALUE --> END_NODE
    SET_STATE --> END_NODE
    SKIP_A --> END_NODE
    SKIP_B --> END_NODE
    SKIP_C --> END_NODE
    SKIP_D --> END_NODE
    EARLY_RETURN --> END_NODE
    END_NODE(["End / Return"])
```

**Processing flow:**

1. **Null guard** — If `key` or `subkey` is null, the method returns immediately without processing (key, subkey that are nullの場合、処理を中止 — Abort processing when key/subkey are null).

2. **Separator detection** — Locates the position of "/" in the key string using `indexOf("/")` to extract a potential array index.

3. **Branch A — 追加字 (Append Text / Extra Field)** — When `key` equals "追加字", the method routes based on `subkey`:
   - If `subkey` equals "value" (case-insensitive): Sets the index value via `setIndex_value`.
   - If `subkey` equals "state" (case-insensitive): Sets the index state via `setIndex_state` (subkeyが"state"の場合、ステータスを返す — Return status when subkey is "state").
   - Otherwise: skips to next branch.

4. **Branch B — コードリスト (Code List)** — When `key` equals "コードリスト" (item ID: cd_list):
   - Extracts the substring after "/" from the key (e.g., from "cd_list/0" takes "0").
   - Attempts to parse the substring as an integer index.
   - On `NumberFormatException`: returns null (index value is not a numeric string).
   - On success: validates the index is within bounds of `cd_list_list`, then delegates to the element's `storeModelData(subkey, in_value)` via `X33VDataTypeStringBean`.
   - The cast target varies by item definition type — `X33VDataTypeStringBean`, `X33VDataTypeLongBean`, or `X33VDataTypeBooleanBean` (キャスト部分は、項目定義型に応じてX33VDataTypeStringBean, X33VDataTypeLongBean, X33VDataTypeBooleanBeanのいずれかを指定 — Specify one of X33VDataTypeStringBean, X33VDataTypeLongBean, or X33VDataTypeBooleanBean depending on the item definition type). For `X33VDataTypeLongBean`, the subkey and `isSetAsString` flag are also passed as parameters.

5. **Branch C — コード名リスト (Code Name List)** — When `key` equals "コード名リスト" (item ID: cd_nm_list):
   - Same parsing, validation, and delegation pattern as Branch B, but operates on `cd_nm_list_list`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `key` | `String` | The item name (項目名) that identifies which data category this value belongs to. Can be one of: "追加字" (append text/extra field), "コードリスト" (code list — requires slash-delimited index like "cd_list/0"), or "コード名リスト" (code name list — requires slash-delimited index like "cd_nm_list/0"). Determines which processing branch the method takes. |
| 2 | `subkey` | `String` | The sub-key (サブキー) that further qualifies the data. For "追加字" items, valid values include "value" (for the index value) and "state" (for the item's display state). For list items, it is forwarded to the nested element bean's `storeModelData` to specify which field of the element bean to populate. Cannot be null or the method aborts early. |
| 3 | `in_value` | `Object` | The data (データ) to be stored. Cast to `String` when used with direct setters (`setIndex_value`, `setIndex_state`). Passed as-is to nested element beans' `storeModelData` methods. |
| 4 | `isSetAsString` | `boolean` | A flag that, when true, indicates setting a String-type value into a Long-type item's Value property (Long型項目ValueプロパティへString型値の設定を行う場合true). Used when the nested element bean is `X33VDataTypeLongBean` — forwarded as a parameter to handle type conversion needs. |

**Instance fields read by this method:**
| Field | Type | Usage |
|-------|------|-------|
| `cd_list_list` | `ArrayList` | List of code list element beans — accessed to get and delegate to elements at `cd_list_list[tmpIndex]` |
| `cd_nm_list_list` | `ArrayList` | List of code name list element beans — accessed to get and delegate to elements at `cd_nm_list_list[tmpIndex]` |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKAdEditCC.substring` | JKKAdEditCC | - | Calls `substring` in `JKKAdEditCC` |
| - | `JKKAdEdit.substring` | JKKAdEdit | - | Calls `substring` in `JKKAdEdit` |
| - | `JKKTelnoInfoAddMapperCC.substring` | JKKTelnoInfoAddMapperCC | - | Calls `substring` in `JKKTelnoInfoAddMapperCC` |
| - | `JDKejbStringEdit.substring` | JDKejbStringEdit | - | Calls `substring` in `JDKejbStringEdit` |
| - | `KKW00130SF01DBean.setIndex_state` | KKW00130SF01DBean | - | Calls `setIndex_state` in `KKW00130SF01DBean` — sets the index item's state string (UPDATE internal bean state) |
| - | `KKW00130SF01DBean.setIndex_value` | KKW00130SF01DBean | - | Calls `setIndex_value` in `KKW00130SF01DBean` — sets the index item's value string (UPDATE internal bean state) |
| - | `KKW00130SF01DBean.storeModelData` | KKW00130SF01DBean | - | Calls `storeModelData` in `KKW00130SF01DBean` — recursive delegation to nested element beans (UPDATE element bean data) |

**Analysis of this method's actual calls:**

This method performs **data assignment (U — Update) operations** on internal bean state and delegates to nested element beans for compound data structures. There are **no direct database CRUD operations, no SC codes, and no CBS calls** — this is purely an in-memory data routing method that updates the bean's model state.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `KKW00130SF01DBean.setIndex_value` | - | - | Sets the index value string on this bean when key is "追加字" and subkey is "value" — internal data field update |
| U | `KKW00130SF01DBean.setIndex_state` | - | - | Sets the index state string on this bean when key is "追加字" and subkey is "state" — internal data field update (ステータスを設定 — set status) |
| U | `X33VDataTypeStringBean.storeModelData` | - | - | Delegates data storage to a code list element bean at the given index — updates the nested element bean's model data |
| U | `X33VDataTypeStringBean.storeModelData` | - | - | Delegates data storage to a code name list element bean at the given index — updates the nested element bean's model data |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 2 methods.
Terminal operations from this method: `storeModelData` [-], `storeModelData` [-], `storeModelData` [-], `substring` [-], `substring` [-], `substring` [-], `substring` [-], `storeModelData` [-], `storeModelData` [-], `storeModelData` [-], `substring` [-], `substring` [-], `substring` [-], `substring` [-], `setIndex_state` [-], `setIndex_value` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | KKW00130SF01DBean | `KKW00130SF01DBean.storeModelData(key, subkey, in_value, isSetAsString)` | `setIndex_value [U] internal state` |
| 2 | KKW00130SF01DBean | `KKW00130SF01DBean.storeModelData(key, subkey, in_value, isSetAsString)` | `setIndex_state [U] internal state` |
| 3 | KKW00130SF01DBean | `KKW00130SF01DBean.storeModelData(key, subkey, in_value, isSetAsString)` → `X33VDataTypeStringBean.storeModelData(subkey, in_value)` | `storeModelData [U] nested element bean` |

**Note:** This method is a shared utility within the `KKW00130SF01DBean` class itself (self-called), and also serves as a public API point for other screen components in the KKW00130SF screen module to populate form data. No external screen (KKSV*) or batch (KKBV*) entry points were found within 8 hops of the call graph. The method's primary role is as an internal data setter — it does not invoke any database operations, SC codes, or CBS endpoints directly.

## 6. Per-Branch Detail Blocks

**Block 1** — IF (null guard) `(key == null || subkey == null)` (L253)

> If key or subkey is null, abort processing (key, subkeyがnullの場合、処理を中止 — Abort processing when key/subkey are null).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return;` // Early return when key or subkey is null |

---

**Block 2** — EXEC (separator detection) (L257)

> Find the position of the "/" separator in the key to later extract an array index from slash-delimited keys like "cd_list/0".

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

---

**Block 3** — IF/ELSE-IF/ELSE-IF (key branching) — Key equals "追加字" (key.equals("追加字")) (L260)

> Branch A: Handle the "追加字" (Tsuihashi — append text / extra field) item type. The item ID is "index". This branch manages direct field storage for the index's value and state. (データタイプがStringの項目"追加字" — Item whose data type is String "append text")

| # | Type | Code |
|---|------|------|
| 1 | IF | `if(key.equals("追加字"))` // Branch: key is "追加字" (append text) |

**Block 3.1** — IF (subkey equals "value") `(subkey.equalsIgnoreCase("value"))` (L261)

> When subkey is "value", cast the input data to String and set it as the index value (インデックス値を設定 — Set index value).

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setIndex_value((String)in_value);` // Set index value field — cast in_value to String |

**Block 3.2** — ELSE-IF (subkey equals "state") `(subkey.equalsIgnoreCase("state"))` (L263)

> When subkey is "state", set the item's state/status (subkeyが"state"の場合、ステータスを返す — Return status when subkey is "state").

| # | Type | Code |
|---|------|------|
| 1 | CALL | `setIndex_state((String)in_value);` // Set index state field — cast in_value to String |

---

**Block 4** — ELSE-IF (key equals "コードリスト") `key.equals("コードリスト")` (L268)

> Branch B: Handle the "コードリスト" (Kodo Risuto — code list) item type. Item ID: cd_list. This branch processes array-indexed data by parsing the key to extract an index, validating it, and delegating to the corresponding list element bean. (配列項目 "コードリスト" — Array item "code list")

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `key = key.substring(separaterPoint + 1);` // Extract substring after first "/" from key (e.g., "cd_list/0" → "0") |
| 2 | SET | `Integer tmpIndexInt = null;` // Initialize index variable to null |

**Block 4.1** — TRY/CATCH (integer parsing) `Integer.valueOf(key)` (L271)

> Attempt to parse the extracted key substring as an integer to get the array index. If not a numeric string, return null (インデックス値が数値文字列でない場合は、ここでnullを返す — If the index value is not a numeric string, return null here).

| # | Type | Code |
|---|------|------|
| 1 | TRY | `tmpIndexInt = Integer.valueOf(key);` // Parse key substring as integer |
| 2 | CATCH | `catch(NumberFormatException e)` // Caught: key substring is not a valid number |
| 3 | SET | `tmpIndexInt = null;` // Set to null when parsing fails |

**Block 4.2** — IF (index is valid integer) `(tmpIndexInt != null)` (L279)

> If parsing succeeded (index value is a numeric string), proceed with bounds checking. (インデックス値が数値文字列の場合 — When index value is a numeric string)

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

**Block 4.2.1** — IF (index within bounds) `(tmpIndex >= 0 && tmpIndex < cd_list_list.size())` (L280)

> Validate the index is within the valid range [0, list size - 1) of the code list. If valid, delegate data storage to the corresponding `X33VDataTypeStringBean` element. (インデックス値がリスト個数-1以下の場合 — When index value is less than list count minus 1). The cast target varies by item definition type: X33VDataTypeStringBean, X33VDataTypeLongBean, or X33VDataTypeBooleanBean (キャスト部分は、項目定義型に応じて...いずれかを指定 — Specify one depending on item definition type). For X33VDataTypeLongBean, the subkey and isSetAsString flag are also passed as parameters.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `((X33VDataTypeStringBean)cd_list_list.get(tmpIndex)).storeModelData(subkey, in_value);` // Get element bean at tmpIndex, cast to X33VDataTypeStringBean, delegate data storage |

---

**Block 5** — ELSE-IF (key equals "コード名リスト") `key.equals("コード名リスト")` (L287)

> Branch C: Handle the "コード名リスト" (Kodo Me Risuto — code name list) item type. Item ID: cd_nm_list. Same pattern as Branch B (codes list), but operates on the `cd_nm_list_list` data structure instead. (配列項目 "コード名リスト" — Array item "code name list")

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `key = key.substring(separaterPoint + 1);` // Extract substring after first "/" (e.g., "cd_nm_list/0" → "0") |
| 2 | SET | `Integer tmpIndexInt = null;` // Initialize index variable to null |

**Block 5.1** — TRY/CATCH (integer parsing) `Integer.valueOf(key)` (L290)

> Attempt to parse the extracted key substring as an integer to get the array index. Same logic as Block 4.1.

| # | Type | Code |
|---|------|------|
| 1 | TRY | `tmpIndexInt = Integer.valueOf(key);` // Parse key substring as integer |
| 2 | CATCH | `catch(NumberFormatException e)` // Caught: key substring is not a valid number |
| 3 | SET | `tmpIndexInt = null;` // Set to null when parsing fails |

**Block 5.2** — IF (index is valid integer) `(tmpIndexInt != null)` (L298)

> If parsing succeeded, proceed with bounds checking and delegation.

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

**Block 5.2.1** — IF (index within bounds) `(tmpIndex >= 0 && tmpIndex < cd_nm_list_list.size())` (L299)

> Validate the index is within the valid range of the code name list. If valid, delegate to the corresponding element bean's `storeModelData`. Same delegation pattern as Block 4.2.1.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `((X33VDataTypeStringBean)cd_nm_list_list.get(tmpIndex)).storeModelData(subkey, in_value);` // Get element bean at tmpIndex, cast to X33VDataTypeStringBean, delegate data storage |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `追加字` (Tsuihashi) | Field | Append Text — an extra/ancillary text field used to store supplementary item data on the screen. The item ID is "index". |
| `コードリスト` (Kodo Risuto) | Field | Code List — an array/list of coded values (item ID: cd_list). Each element is a typed data bean holding a code value. |
| `コード名リスト` (Kodo Me Risuto) | Field | Code Name List — an array/list of code display names (item ID: cd_nm_list). Each element is a typed data bean holding a code name. |
| `index` | Field | Index item — the internal field identifier for the 追加字 item, comprising a value and a state property. |
| `cd_list_list` | Field | Code List data array — an ArrayList of typed data beans (X33VDataTypeStringBean, X33VDataTypeLongBean, or X33VDataTypeBooleanBean) representing entries in the code list. |
| `cd_nm_list_list` | Field | Code Name List data array — an ArrayList of typed data beans representing entries in the code name list. |
| `setIndex_value` | Method | Setter for the index value — stores the String value of the 追加字 item. |
| `setIndex_state` | Method | Setter for the index state — stores the display state/status of the 追加字 item. |
| `X33VDataTypeStringBean` | Class | A data type bean for String-type fields — used as the common cast target for list elements in this method. |
| `X33VDataTypeLongBean` | Class | A data type bean for Long-type fields — used when the item definition type is Long, handling type conversion via isSetAsString. |
| `X33VDataTypeBooleanBean` | Class | A data type bean for Boolean-type fields — used when the item definition type is Boolean. |
| `isSetAsString` | Parameter | A flag indicating whether to set a String-type value into a Long-type item's Value property — used for type conversion in Long-type data beans. |
| KKW00130SF | Module | K-Opticom telecom order system module — Request Sheet Information Display (請求書情報表示) screen processing module. |
| DBean | Type | Data Bean — a UI-level bean that holds model data for screen presentation, serving as the view model between the controller and the JSP view. |
