# KKW22501SF01DBean

## Purpose

`KKW22501SF01DBean` is the row-level data bean for the **Agent Event CP Settings** screen (代理店イベントCP設定画面) in the K-Opticom customer base system. It holds the per-row model data — agent codes, timestamps, data extraction conditions, and deletion flags — that is rendered in a dynamic table of the JSP view. This bean exists so the framework can treat each row as a self-contained, key-driven data object with support for value access, enable/disable state, and UI rendering state.

## Design

`KKW22501SF01DBean` plays two architectural roles simultaneously:

1. **Data Transfer Object (DTO) / Row Bean** — It is one element in a list of beans held by the parent `KKW22501SFBean`. Each instance represents one row in the "data extraction condition registration list" (データ抽出項目設定条件一覧照会). The parent bean creates one `KKW22501SF01DBean` per row it displays or edits.

2. **Reflection-style Data Accessor** — It implements `X33VDataTypeBeanInterface` and `X33VListedBeanInterface` from the Fujitsu Futurity X33 web framework, which means it exposes its fields through a key-driven, name-based interface (`loadModelData`, `storeModelData`, `typeModelData`) rather than requiring callers to know the exact field names at compile time. This pattern is common in Japanese enterprise JSP applications where field metadata is driven by configuration.

The bean has **no superclass** and **no outbound code dependencies** — it is a pure data carrier with accessor logic. All data comes from and goes through the framework via reflection-style methods.

## Fields

The bean has 27 data fields, grouped by business concept. Each logical field follows one of two patterns:

- **Three-part** (`_value`, `_enabled`, `_state`, `_update`) — for most string fields and the boolean delete flag
- **Two-part** (`_value`, `_state`, `_update`) — for a few non-interactive fields (data extraction codes and timestamps)

| Concept | Field ID | Type | Sub-fields |
|---------|----------|------|------------|
| Agent Code | `agnt_cd` | `String` (value) | `enabled` (Boolean), `state` (String), `update` (String) |
| Agent Name | `agnt_nm` | `String` (value) | `enabled` (Boolean), `state` (String), `update` (String) |
| Display Data Extraction Code | `dsp_dchskm_cd` | `String` (value) | `enabled` (Boolean), `state` (String), `update` (String) |
| Receipt Start DateTime | `uk_sta_ymdhm` | `String` (value) | `enabled` (Boolean), `state` (String), `update` (String) |
| Receipt End DateTime | `uk_end_ymdhm` | `String` (value) | `enabled` (Boolean), `state` (String), `update` (String) |
| Data Extraction Code (for edit) | `dchskm_cd` | `String` (value) | `state` (String), `update` (String) |
| Data Extraction Condition Number (for edit) | `dchskm_sete_jkn_no` | `String` (value) | `state` (String), `update` (String) |
| Update DateTime | `upd_dtm` | `String` (value) | `state` (String), `update` (String) |
| Delete Checkbox | `del_check` | `Boolean` (value) | `enabled` (Boolean), `state` (String), `update` (String) |
| Row Index | `index` | `int` | — |

Default values: all `_value` fields initialize to `""` (empty string), all `_enabled` and `del_check_value` initialize to `false`.

## Key Methods

### `loadModelData(String key, String subkey) → Object`

Retrieves a value from this bean by Japanese property name and subkey. This is the primary getter used by the framework.

- **Parameters:**
  - `key` — Japanese property name (e.g., `"代理店コード"`, `"削除チェック"`). The method does NOT use the `subkey` for this operation; it routes based on `key`.
  - `subkey` — One of `"value"`, `"enable"`, or `"state"`. The method uses this to decide which field to return.

- **Returns:** The field value as `Object` (typically `String`, `Boolean`, or `null` if no matching property is found).

- **Mapping table:**

  | key (Japanese) | subkey | Returns |
  |----------------|--------|---------|
  | `代理店コード` | `value` | `agnt_cd_value` |
  | `代理店コード` | `enable` | `agnt_cd_enabled` |
  | `代理店コード` | `state` | `agnt_cd_state` |
  | `代理店名` | `value` | `agnt_nm_value` |
  | `代理店名` | `enable` | `agnt_nm_enabled` |
  | `代理店名` | `state` | `agnt_nm_state` |
  | `表示用データ抽出項目コード` | `value` | `dsp_dchskm_cd_value` |
  | `表示用データ抽出項目コード` | `enable` | `dsp_dchskm_cd_enabled` |
  | `表示用データ抽出項目コード` | `state` | `dsp_dchskm_cd_state` |
  | `受付開始年月日時分` | `value` | `uk_sta_ymdhm_value` |
  | `受付開始年月日時分` | `enable` | `uk_sta_ymdhm_enabled` |
  | `受付開始年月日時分` | `state` | `uk_sta_ymdhm_state` |
  | `受付終了年月日時分` | `value` | `uk_end_ymdhm_value` |
  | `受付終了年月日時分` | `enable` | `uk_end_ymdhm_enabled` |
  | `受付終了年月日時分` | `state` | `uk_end_ymdhm_state` |
  | `データ抽出項目コード（変更用）` | `value` | `dchskm_cd_value` |
  | `データ抽出項目コード（変更用）` | `state` | `dchskm_cd_state` |
  | `データ抽出項目設定条件番号（変更用）` | `value` | `dchskm_sete_jkn_no_value` |
  | `データ抽出項目設定条件番号（変更用）` | `state` | `dchskm_sete_jkn_no_state` |
  | `更新年月日時分秒` | `value` | `upd_dtm_value` |
  | `更新年月日時分秒` | `state` | `upd_dtm_state` |
  | `削除チェック` | `value` | `del_check_value` |
  | `削除チェック` | `enable` | `del_check_enabled` |
  | `削除チェック` | `state` | `del_check_state` |

- **Behavior:** If either `key` or `subkey` is `null`, returns `null`. If no matching property is found, falls through to the end and returns `null`.

### `storeModelData(String key, String subkey, Object in_value, boolean isSetAsString) → void`

Sets a value in this bean by Japanese property name and subkey. This is the primary setter used by the framework.

- **Parameters:**
  - `key` — Japanese property name (same set as `loadModelData`).
  - `subkey` — One of `"value"`, `"enable"`, or `"state"`. Determines which field to set.
  - `in_value` — The value to set. Cast to the appropriate type (`String` or `Boolean`) by the caller or the method itself.
  - `isSetAsString` — A boolean flag documented for "setting String values to Long-type property properties." In the current code, this parameter is accepted but never referenced in the method body — it appears to be a legacy placeholder.

- **Mapping table (same key/subkey combinations as `loadModelData`):**

  | key (Japanese) | subkey | Sets |
  |----------------|--------|------|
  | `代理店コード` | `value` | `agnt_cd_value` |
  | `代理店コード` | `enable` | `agnt_cd_enabled` |
  | `代理店コード` | `state` | `agnt_cd_state` |
  | `削除チェック` | `value` | `del_check_value` (cast to `Boolean`) |
  | `削除チェック` | `enable` | `del_check_enabled` (cast to `Boolean`) |
  | `削除チェック` | `state` | `del_check_state` |

  (Full mapping mirrors `loadModelData` in reverse.)

- **Behavior:** If either `key` or `subkey` is `null`, returns without modifying any fields. All casts (`(String)`, `(Boolean)`) are performed at runtime and will throw `ClassCastException` if the caller passes the wrong type.

- **Overloads:**
  - `storeModelData(String key, String subkey, Object in_value)` — delegates to the four-argument version with `isSetAsString = false`.
  - `storeModelData(String gamenId, String key, String subkey, Object in_value)` — ignores `gamenId` and delegates to `storeModelData(key, subkey, in_value)`. The `gamenId` (screen ID) parameter is marked as reserved/future-use in the source comment.

### `typeModelData(String key, String subkey) → Class<?>`

Returns the Java type of a field given a property name and subkey. This is used by the X33 framework for type-safe data binding.

- **Parameters:** Same `key` and `subkey` as `loadModelData` / `storeModelData`.
- **Returns:** `Class<?>` — one of `String.class`, `Boolean.class`, or `null`.

- **Type mapping:**

  | key | subkey | Returns |
  |-----|--------|---------|
  | All fields | `value` | `String.class` (except `削除チェック` → `Boolean.class`) |
  | All fields with `enable` | `enable` | `Boolean.class` |
  | All fields | `state` | `String.class` |

- **Behavior:** Same `null`-check and fallback-to-`null` pattern as the other two methods.

### `listKoumokuIds() → ArrayList<String>`

A static factory method that returns the list of valid property name keys for this bean type. Used by the parent `KKW22501SFBean` to determine which keys to iterate over when setting up data type binding.

- **Returns:** An `ArrayList<String>` containing exactly 9 Japanese strings:

  ```
  "代理店コード", "代理店名", "表示用データ抽出項目コード",
  "受付開始年月日時分", "受付終了年月日時分",
  "データ抽出項目コード（変更用）", "データ抽出項目設定条件番号（変更用）",
  "更新年月日時分秒", "削除チェック"
  ```

- **Note:** This is `static` — it does not require an instance of the bean.

### `getIndex() / setIndex(int)`

Simple getter/setter for the row index within the list. Useful for the JSP to correlate UI elements with data rows.

## Relationships

```mermaid
classDiagram
    class KKW22501SF01DBean {
        implements X33VDataTypeBeanInterface
        implements X33VListedBeanInterface
        implements Serializable
        -String agnt_cd_value
        -Boolean agnt_cd_enabled
        -String agnt_cd_state
        -String agnt_nm_value
        -Boolean agnt_nm_enabled
        -String agnt_nm_state
        -String dsp_dchskm_cd_value
        -Boolean dsp_dchskm_cd_enabled
        -String dsp_dchskm_cd_state
        -String uk_sta_ymdhm_value
        -Boolean uk_sta_ymdhm_enabled
        -String uk_sta_ymdhm_state
        -String uk_end_ymdhm_value
        -Boolean uk_end_ymdhm_enabled
        -String uk_end_ymdhm_state
        -String dchskm_cd_value
        -String dchskm_cd_state
        -String dchskm_sete_jkn_no_value
        -String dchskm_sete_jkn_no_state
        -String upd_dtm_value
        -String upd_dtm_state
        -Boolean del_check_value
        -Boolean del_check_enabled
        -String del_check_state
        -int index
        +getAgnt_cd_value() String
        +getAgnt_nm_value() String
        +getUk_sta_ymdhm_value() String
        +getUk_end_ymdhm_value() String
        +getDchskm_cd_value() String
        +getDchskm_sete_jkn_no_value() String
        +getUpd_dtm_value() String
        +getDel_check_value() Boolean
        +loadModelData(String, String) Object
        +storeModelData(String, String, Object) void
        +storeModelData(String, String, Object, boolean) void
        +typeModelData(String, String) Class
        +listKoumokuIds() ArrayList
        +getIndex() int
    }

    class KKW22501SFBean {
        +X33VDataTypeList dchskm_sete_jkn_list_list
        +X33VDataTypeList bf_dchskm_sete_jkn_list_list
    }

    class KKW225010PJP {
        +JSP view
        +renders table rows
    }

    KKW22501SFBean --> KKW22501SF01DBean : instantiates for each row
    KKW225010PJP --> KKW22501SF01DBean : reads row fields via getters
```

**Who uses this class:**

- `KKW22501SFBean` (the parent screen bean) — instantiates `KKW22501SF01DBean` objects and adds them to `dchskm_sete_jkn_list_list` and `bf_dchskm_sete_jkn_list_list`. The parent uses `listKoumokuIds()` to determine property metadata binding for the data type view.
- `KKW225010PJP.jsp` — the JSP view page that renders the agent event CP settings screen. It casts the first element of `getServiceFormBeanList()` to `KKW22501SF01DBean` to access per-row values for rendering table cells, inputs, and checkboxes.

**What this class depends on:**

- `X33VDataTypeBeanInterface` and `X33VListedBeanInterface` from the Fujitsu Futurity X33 framework
- `java.io.Serializable` — the bean must be serializable for session storage or request forwarding

## Usage Example

Here is the typical calling pattern as seen in the JSP view (`KKW225010PJP.jsp`):

```java
// 1. Get the row bean from the parent bean's list
KKW22501SF01DBean rowBean = (KKW22501SF01DBean)
    ((KKW22501SFBean) KKW225010PJP.getServiceFormBeanList().get(0));

// 2. Access a specific row (via an index counter from a loop)
// The JSP iterates through dchskm_sete_jkn_list_list
// where each element IS a KKW22501SF01DBean instance.

// 3. Read field values for rendering
String agentCode = rowBean.getAgnt_cd_value();
Boolean enabled = rowBean.getAgnt_cd_enabled();
String state = rowBean.getAgnt_cd_state();
Boolean isChecked = rowBean.getDel_check_value();

// 4. Or use the key-driven accessor (used by the framework)
Object value = rowBean.loadModelData("代理店コード", "value");
rowBean.storeModelData("代理店コード", "value", "A001");
```

The parent `KKW22501SFBean` creates `KKW22501SF01DBean` instances and populates them:

```java
// Inside KKW22501SFBean
KKW22501SF01DBean tmpBean = new KKW22501SF01DBean();
// ... populate fields via setters ...
dchskm_sete_jkn_list_list.add(tmpBean);
```

And the framework can use the type metadata:

```java
// Data type binding registration
if (listName.equals("dchskm_sete_jkn_list")) {
    return KKW22501SF01DBean.listKoumokuIds();
}
```

## Notes for Developers

### Framework Integration
This bean is part of the Fujitsu Futurity X33 web framework (not to be confused with the older X31 framework also imported). It implements `X33VDataTypeBeanInterface` which enables the framework's automatic data type binding — the framework uses `loadModelData`, `storeModelData`, and `typeModelData` to read/write data without knowing field names at compile time.

### Thread Safety
This bean is **not thread-safe**. Each row in a list gets its own instance, but the bean's fields are mutable `protected` (except via public getters/setters). In the request-response model of JSP applications, each HTTP request gets its own bean instances, so this is not a practical concern. However, sharing a `KKW22501SF01DBean` instance across threads would cause data races.

### Null Safety
- `loadModelData` returns `null` for null keys or unmatched properties. Callers should guard against `NullPointerException` if they pass the returned `Object` directly.
- `typeModelData` also returns `null` for unmatched properties.
- All `_value` fields are initialized to empty strings, not `null`, so dereferencing them after `loadModelData` (which does field-level null checks) could still hit `null` from the `state` and `update` fields which are not initialized.

### Reflection-style API Coupling
The key-driven methods (`loadModelData`, `storeModelData`, `typeModelData`) use **Japanese string literals** as property names. This means:
- Renaming a field requires updating all three methods' `if/else` chains manually.
- Adding a new field requires updating all three methods plus `listKoumokuIds()`.
- Missing a method in one of the three creates a silent bug — the field is accessible via getters/setters but not via the framework's key-driven interface.

### Casting Risks in `storeModelData`
The four-argument `storeModelData` performs unchecked casts: `(String)in_value` and `(Boolean)in_value`. If the caller passes an incompatible type (e.g., a `Long` when a `Boolean` is expected), a `ClassCastException` will be thrown at runtime.

### Field Pattern Consistency
Some fields (like `dchskm_cd` and `upd_dtm`) only have `value`, `state`, and `update` — no `enabled` field. The `storeModelData` and `loadModelData` methods only handle `value` and `state` for these fields; attempting to use subkey `"enable"` will fall through to the no-match case and return `null` (or do nothing).

### The Unused `isSetAsString` and `gamenId` Parameters
The `isSetAsString` parameter in the four-argument `storeModelData` is never read — the method body does not branch on it. The `gamenId` parameter in the three-parameter-with-screen-ID overload is similarly ignored. These appear to be forward-compatibility scaffolding from a parent class pattern (likely `X31CBaseBean`).

### Serialization
The bean implements `Serializable` but declares no `serialVersionUID`. This is a minor risk — if the field set changes (which it may, as new fields are added regularly), deserializing old serialized instances on the new class could fail silently or produce unexpected results.

### Row Index
The `index` field is a simple `int` with no framework integration. It is likely set by the JSP loop counter to correlate HTML element IDs (e.g., `del_check_<%=counter%>`) with the corresponding bean in the list.
