# KKW00130SF02DBean

## Purpose

`KKW00130SF02DBean` is a **data-type bean** in the X33 web framework that acts as a state carrier for the "02" sub-screen of the KKW00130 feature set. It aggregates the display and control state of approximately 25 UI fields — phone numbers, service dates, contract statuses, pricing codes, and dynamic list items — and exposes them through the framework's reflection-style data-binding interfaces (`X33VDataTypeBeanInterface`, `X33VListedBeanInterface`). This allows JSP pages to render and process screen data without writing explicit setter/getter calls for each field.

## Design

This class follows the **Java Bean / Data Transfer Object** pattern within the X33 model-view-controller framework. It does not contain business logic; its sole responsibility is to hold transient screen state and forward data access requests from the JSP layer to the correct internal fields.

Key design characteristics:

- **Triple interface implementation**: Implements `X33VDataTypeBeanInterface` (the core data-type bean contract), `X33VListedBeanInterface` (the listed/dynamic-item management contract), and `Serializable` (for session/HTTP transport).
- **Field naming convention**: All result fields follow the pattern `rslt_<fieldId>_<property>`, where `<fieldId>` is a short mnemonic (e.g., `telno` for phone number, `bmp` for number portability, `kei_stat` for contract status) and `<property>` is one of `update`, `value`, `enabled`, or `state`.
- **Three-attribute per field model**: Most interactive fields expose a value, an enabled/disabled flag, and a state string. The `update` property appears to track whether the field's value was modified during the request.
- **Dynamic list support**: The `bmp_haishi_req_ctrl_cd_list` (番号廃止依頼制御コード — number portability cancellation request control codes) field holds a list of child beans (`KKW00130SF01DBean`), enabling the screen to render a variable number of rows.
- **Java 5-era architecture**: This is a scriptlet-driven JSP application (circa 2013–2015) with no framework abstraction beyond X33. Fields are accessed directly in JSP via casts and getter calls.

## Field Summary

| Domain | Field ID (short) | Japanese label | Properties |
|--------|-----------------|----------------|------------|
| Phone number | `rslt_telno` | 電話番号 | value, enabled, state, update |
| Number portability | `rslt_bmp` | 番ポ | value, enabled, state, update |
| Contract status | `rslt_kei_stat` | 契約状態 | value, enabled, state, update |
| Service start date | `rslt_svc_staymd` | サービス開始年月日 | value, enabled, state, update |
| Service end date | `rslt_svc_endymd` | サービス終了年月日 | value, enabled, state, update |
| VA model | `rslt_va_model` | VA型式 | value, enabled, state, update |
| Port number | `rslt_port_no` | ポート番号 | value, enabled, state, update |
| No guide | `rslt_no_guide` | 番号案内 | value, enabled, state, update |
| Toki availability | `rslt_toki_um` | トーキ有無 | value, enabled, state, update |
| Service contract detail no | `rslt_svc_kei_ucwk_no` | サービス契約内詳番号 | value, state, update |
| Service contract detail status | `rslt_svc_kei_ucwk_stat` | サービス契約内詳ステータス | value, state, update |
| Submission detail number | `rslt_mskm_dtl_no` | 申込明細番号 | value, state, update |
| Price course code | `rslt_pcrs_cd` | 料金コースコード | value, state, update |
| Price plan code | `rslt_pplan_cd` | 料金プランコード | value, state, update |
| Display service contract status | `dsp_svc_kei_ucwk_stat` | 表示用サービス契約内詳ステータス | value, state, update |
| Display service contract status name | `dsp_svc_kei_ucwk_stat_nm` | 表示用サービス契約内詳ステータス名称 | value, state, update |
| Indoor device type code | `taknkiki_sbt_cd` | 宅内機器種別コード | value, state, update |
| Device provision service name | `kktk_svc_nm` | 機器提供サービス名 | value, state, update |
| Number portability cancellation control codes | `bmp_haishi_req_ctrl_cd_list` | 番ポ廃止依頼制御コード | X33VDataTypeList of KKW00130SF01DBean |

Some fields (the contract detail / price / display fields) have only `value` and `state` properties — no `enabled` flag — because they appear to be informational-only (display) fields rather than user-editable inputs.

## Key Methods

### `KKW00130SF02DBean()` — Constructor

Initializes the constructor block, generating the data-type bean. Specifically, it instantiates the `bmp_haishi_req_ctrl_cd_list` as a new `X33VDataTypeList` (lines 124–130). This ensures the list is never null when the bean enters the request lifecycle.

```java
public KKW00130SF02DBean() {
    bmp_haishi_req_ctrl_cd_list = new X33VDataTypeList();
}
```

### `Object loadModelData(String key, String subkey)` — Read Data

**The most important method in this class.** It implements the `X33VDataTypeBeanInterface.loadModelData()` contract, enabling the X33 framework to retrieve field values by name rather than by method call. The method accepts a Japanese field name as `key` and a property specifier as `subkey` (typically `"value"`, `"enable"`, or `"state"`), then dispatches to the appropriate getter.

The method is structured as a long chain of `if-else` blocks — one per field — each checking the `key` against a Japanese literal, then checking the `subkey` (case-insensitively) to determine which getter to invoke. For example:

- `key = "電話番号"`, `subkey = "value"` → calls `getRslt_telno_value()`
- `key = "電話番号"`, `subkey = "enable"` → calls `getRslt_telno_enabled()`
- `key = "電話番号"`, `subkey = "state"` → calls `getRslt_telno_state()`

Some fields (the non-editable ones like contract detail number, price course code) only handle `"value"` and `"state"` subkeys — there is no `"enable"` path.

For the dynamic list field (`"番号廃止依頼制御コード"`), the method handles a composite key format: `"番号廃止依頼制御コード/0/プロダクト/0/プロ文件名"`. If the index part is `"*"`, it returns the list size as an `Integer`. Otherwise, it parses the index, validates bounds, and delegates to the child bean's `loadModelData()`.

**Parameters:**
- `key` — The Japanese field name (e.g., `"電話番号"`). Must not be null.
- `subkey` — The property specifier (e.g., `"value"`, `"enable"`, `"state"`, or for the list field, a composite path like `"0/プロダクト"`). Must not be null.

**Returns:** The field's value as an `Object` (typically `String` or `Boolean`), or `null` if the key/subkey pair doesn't match any field, or if the subkey is unrecognized.

### `void storeModelData(...)` — Write Data

Implements the `X33VDataTypeBeanInterface.storeModelData()` contract. There are three overloaded variants:

1. **`storeModelData(String gamenId, String key, String subkey, Object in_value)`** — The full signature. The `gamenId` (screen ID) parameter is present but unused; it simply delegates to the three-parameter version.

2. **`storeModelData(String key, String subkey, Object in_value)`** — The convenience overload that defaults `isSetAsString` to `false`.

3. **`storeModelData(String key, String subkey, Object in_value, boolean isSetAsString)`** — The core implementation. Structurally mirrors `loadModelData` with the same `if-else` chain by field name. It performs a type cast on `in_value` and calls the corresponding setter. For example:

```java
if(key.equals("電話番号")){
    if(subkey.equalsIgnoreCase("value")){
        setRslt_telno_value((String)in_value);
    }
    else if(subkey.equalsIgnoreCase("enable")){
        setRslt_telno_enabled((Boolean)in_value);
    }
    else if(subkey.equalsIgnoreCase("state")){
        setRslt_telno_state((String)in_value);
    }
}
```

For the dynamic list field, it parses the composite key, extracts the index, and delegates to the child bean's `storeModelData()` with the `isSetAsString` flag propagated.

**Parameters:**
- `gamenId` — Screen ID (reserved, unused).
- `key` — The Japanese field name (must not be null).
- `subkey` — The property specifier.
- `in_value` — The value to set, cast to the expected type.
- `isSetAsString` — Flag for special string-type handling of `Long` values (inherited from `X31CBaseBean` contract).

### `Class<?> typeModelData(String key, String subkey)` — Type Introspection

Returns the Java type of a field's value. Implements the type introspection side of the X33 data binding contract. For every field, `value` maps to `String.class` and `enable` (where present) maps to `Boolean.class`. `state` always maps to `String.class`.

This allows the X33 framework to validate type compatibility before calling `storeModelData()`.

For the dynamic list field, it delegates to the child bean's `typeModelData()` after parsing the composite key. If the index is `"*"`, it returns `Integer.class` (for the list size).

**Parameters:**
- `key` — The Japanese field name.
- `subkey` — The property specifier.

**Returns:** A `Class<?>` representing the expected type, or `null` if the key/subkey is unrecognized or the index is out of bounds.

### `ArrayList<String> listKoumokuIds()` — Discover Field Names

A static method that returns a list of all Japanese field names known to this bean. This is used by the X33 framework to enumerate which fields the screen should render. The list is built in the order the fields appear on screen (lines 1305–1335).

**Returns:** An `ArrayList` containing 18 field name strings.

### `int addListDataInstance(String key)` — Add List Row

Implements the `X33VListedBeanInterface` contract. Adds a new `KKW00130SF01DBean` instance to the `bmp_haishi_req_ctrl_cd_list` when the key is `"番号廃止依頼制御コード"`. Returns the index of the newly added element, or `-1` if the key is invalid or null.

**Parameters:**
- `key` — Must be `"番号廃止依頼制御コード"` to trigger list expansion.

**Returns:** The index of the new element, or `-1` on failure.

### `void removeElementFromListData(String key, int index)` — Remove List Row

Removes the element at the given index from the `bmp_haishi_req_ctrl_cd_list`. Validates that the index is within bounds. No-op if the key doesn't match or the index is out of range.

### `void clearListDataInstance(String key)` — Clear All List Rows

Clears the entire `bmp_haishi_req_ctrl_cd_list` when the key matches `"番号廃止依頼制御コード"`.

### `ArrayList<SelectItem> getJsflist_typelist_bmp_haishi_req_ctrl_cd()` — JSF Select List

Builds an `ArrayList<SelectItem>` from the list data, converting each element's value into a JSF-compatible select item with the list index as the item value. This supports rendering the list as a dropdown or selection component on the UI.

### Getter/Setter Methods

Each of the ~50 field properties has a standard JavaBean getter and setter. These are thin delegations — they read or write the field directly with no validation or transformation. The `getJsflist_typelist_bmp_haishi_req_ctrl_cd()` method is notable as it traverses the list rather than returning a single field value.

## Relationships

```mermaid
classDiagram
  class KKW00130SF02DBean {
    implements X33VDataTypeBeanInterface
    implements X33VListedBeanInterface
    implements Serializable
    +String rslt_telno_update
    +String rslt_telno_value
    +Boolean rslt_telno_enabled
    +String rslt_telno_state
    +String rslt_bmp_update
    +String rslt_bmp_value
    +Boolean rslt_bmp_enabled
    +String rslt_bmp_state
    +String rslt_kei_stat_update
    +String rslt_kei_stat_value
    +Boolean rslt_kei_stat_enabled
    +String rslt_kei_stat_state
    +String rslt_svc_staymd_update
    +String rslt_svc_staymd_value
    +Boolean rslt_svc_staymd_enabled
    +String rslt_svc_staymd_state
    +String rslt_svc_endymd_update
    +String rslt_svc_endymd_value
    +Boolean rslt_svc_endymd_enabled
    +String rslt_svc_endymd_state
    +String rslt_va_model_update
    +String rslt_va_model_value
    +Boolean rslt_va_model_enabled
    +String rslt_va_model_state
    +String rslt_port_no_update
    +String rslt_port_no_value
    +Boolean rslt_port_no_enabled
    +String rslt_port_no_state
    +String rslt_no_guide_update
    +String rslt_no_guide_value
    +Boolean rslt_no_guide_enabled
    +String rslt_no_guide_state
    +String rslt_toki_um_update
    +String rslt_toki_um_value
    +Boolean rslt_toki_um_enabled
    +String rslt_toki_um_state
    +String rslt_svc_kei_ucwk_no_update
    +String rslt_svc_kei_ucwk_no_value
    +String rslt_svc_kei_ucwk_no_state
    +String rslt_svc_kei_ucwk_stat_update
    +String rslt_svc_kei_ucwk_stat_value
    +String rslt_svc_kei_ucwk_stat_state
    +String rslt_mskm_dtl_no_update
    +String rslt_mskm_dtl_no_value
    +String rslt_mskm_dtl_no_state
    +String rslt_pcrs_cd_update
    +String rslt_pcrs_cd_value
    +String rslt_pcrs_cd_state
    +String rslt_pplan_cd_update
    +String rslt_pplan_cd_value
    +String rslt_pplan_cd_state
    +String dsp_svc_kei_ucwk_stat_update
    +String dsp_svc_kei_ucwk_stat_value
    +String dsp_svc_kei_ucwk_stat_state
    +String dsp_svc_kei_ucwk_stat_nm_update
    +String dsp_svc_kei_ucwk_stat_nm_value
    +String dsp_svc_kei_ucwk_stat_nm_state
    +String taknkiki_sbt_cd_update
    +String taknkiki_sbt_cd_value
    +String taknkiki_sbt_cd_state
    +String kktk_svc_nm_update
    +String kktk_svc_nm_value
    +String kktk_svc_nm_state
    +X33VDataTypeList bmp_haishi_req_ctrl_cd_list
    +int index
    +KKW00130SF02DBean()
    +Object loadModelData(key: String, subkey: String) Object
    +void storeModelData(key: String, subkey: String, in_value: Object)
    +Class<?> typeModelData(key: String, subkey: String) Class<?>
    +ArrayList<String> listKoumokuIds() ArrayList<String>
    +int addListDataInstance(key: String) int
    +void removeElementFromListData(key: String, index: int) void
    +void clearListDataInstance(key: String) void
  }

  class KKW00130SF01DBean {
    Data type bean
    Implements X33VDataTypeBeanInterface
  }

  class KKW00130SFBean {
    Parent screen form bean
    Contains getTelno_lst_list()
  }

  class KKW001300PJP {
    JSP page
    Renders screen 02 data
  }

  class KKW001360PJP {
    JSP page
    Renders screen 02 data
  }

  KKW001300PJP --> KKW00130SFBean : references
  KKW00130SFBean --> KKW00130SF02DBean : contains in list (getTelno_lst_list)
  KKW001360PJP --> KKW00130SFBean : references
  KKW00130SFBean --> KKW00130SF02DBean : contains in list
  KKW00130SF02DBean --> KKW00130SF01DBean : creates instances for list
```

**Inbound (2 direct callers):**

| Class | Type | How it's used |
|-------|------|---------------|
| `KKW001300PJP.jsp` | JSP page | Casts to `KKW00130SF02DBean` from `KKW00130SFBean.getTelno_lst_list()` to read field values for display in scriptlet expressions |
| `KKW001360PJP.jsp` | JSP page | Same pattern — accesses the bean from the parent form bean's list to render table rows |

**Outbound:**

| Dependency | How it's used |
|------------|---------------|
| `KKW00130SF01DBean` | Created and stored in `bmp_haishi_req_ctrl_cd_list`; child bean instances handle their own data for the dynamic "number portability cancellation request control codes" sub-items |
| `X33VDataTypeBeanInterface` | Interface implemented for data binding |
| `X33VListedBeanInterface` | Interface implemented for dynamic list management |
| `X33VDataTypeList` | Container for the dynamic list of child beans |
| `X33SException` | Thrown by list management methods |
| `java.io.Serializable` | Interface for HTTP/session transport |
| `javax.faces.model.SelectItem` | Used in `getJsflist_typelist_bmp_haishi_req_ctrl_cd()` for JSF dropdown rendering |

There are no other outbound code references beyond these interface and type dependencies.

## Usage Example

In the JSP pages, the bean is accessed through the parent form bean's list. A typical scriptlet expression reads:

```jsp
<%=KKW001300PJP.tool_KaigyoHtml(
    KKW001300PJP.tool_Escape(true, "full",
        ((KKW00130SF02DBean)((KKW00130SFBean)KKW001300PJP.getServiceFormBeanList().get(0))
            .getTelno_lst_list().get(telno)).getRslt_telno_value())) %>
```

The access pattern is:
1. Retrieve the parent form bean (`KKW00130SFBean`) from the service form bean list.
2. Call `getTelno_lst_list()` to get the list of `KKW00130SF02DBean` instances (one per telephone number row).
3. Index into the list with the loop variable (`telno`) to select a specific row's bean.
4. Call specific getters (e.g., `getRslt_telno_value()`, `getRslt_bmp_value()`) to populate table cells.
5. Wrap each value with escape and newline-handling utility methods for safe HTML output.

The X33 framework also uses the reflection-style methods directly:

```java
// X33 framework internally calls these methods:
Object value = bean.loadModelData("電話番号", "value");   // returns "03-1234-5678"
Class<?> type = bean.typeModelData("電話番号", "value");  // returns String.class
bean.storeModelData("電話番号", "value", "03-9999-8888");  // sets rslt_telno_value
```

## Notes for Developers

- **Thread safety**: This bean is not thread-safe. In a servlet/JSP environment, one instance is created per request and stored in the session or passed between pages. Never share an instance across threads.

- **No validation**: None of the getters or setters perform validation, normalization, or null checks. The `rslt_*_value` fields default to `""` (empty string) and `rslt_*_enabled` default to `false`, but `rslt_*_state` defaults to `""` and `rslt_*_update` defaults to `null`. Callers must handle null `update` fields gracefully.

- **Hardcoded Japanese literals**: The `if-else` chains in `loadModelData`, `storeModelData`, and `typeModelData` use hardcoded Japanese field names as switch keys. Any addition of a new field requires modifying all three methods in lockstep. This is brittle and a common source of bugs when fields are added but one of the three methods is overlooked.

- **The `update` property**: Many fields have an `update` property (e.g., `rslt_telno_update`) that is never accessed through `loadModelData`/`storeModelData`/`typeModelData`. It appears to be set externally (possibly by the X33 framework or a preceding processing step) and may track dirty state, but it is not routable through the reflection-style methods.

- **List field complexity**: The `"番号廃止依頼制御コード"` list field has a three-part composite key format: `"番号廃止依頼制御コード/{index}/{childKey}"`. The child beans (`KKW00130SF01DBean`) handle their own `load`/`store`/`type` dispatch. This is the only dynamic/list component in the bean and introduces a level of indirection that can be hard to debug.

- **Type casting risks**: `storeModelData` performs unchecked casts — `(String) in_value` and `(Boolean) in_value`. If the framework passes a value of an unexpected type, a `ClassCastException` will be thrown at runtime. The `isSetAsString` flag provides an escape hatch for `Long` values but the exact handling is not visible in this class (delegated to `X31CBaseBean`).

- **No business logic**: This bean does not perform any data access, computation, or validation beyond field assignment. All business logic lives in the JSP pages (scriptlet blocks) and the parent form bean (`KKW00130SFBean`).

- **Field count growth**: The class has grown incrementally over time (visible from the `20130326`, `ANK-1587`, `20150313` change-set comments). New fields keep being added to the `if-else` chains, making them longer and harder to maintain. Consider whether a data-driven approach (e.g., a `Map<String, Map<String, Property>>` registry) would reduce maintenance burden if the field count continues to grow.

- **The `index` field**: The bean has a single `int index` property with getter/setter, but its usage is not visible from the class itself. It likely tracks the position within the parent list when the bean is being processed row-by-row in the JSP loop.

- **Serializable**: The class implements `Serializable` for session persistence or HTTP request/response transport, but defines no `serialVersionUID`. In a production system, this can cause `InvalidClassException` if the class structure changes between deployment versions.
