# CRW02702SF01DBean

## Purpose

`CRW02702SF01DBean` is a **data bean** (model object) within the K-Opticom web client framework. It holds the display state for a service contract detail screen, representing a single row of a data table that shows operational service information — including service codes, usage dates, and display flags. It also acts as a **data dispatcher**, routing generic key/subkey lookups to the correct strongly-typed field, enabling the view layer to interact with the bean through a uniform `loadModelData` / `storeModelData` interface rather than calling individual getters and setters.

## Design

This class follows the **JavaBean + data dispatcher** pattern used by the Fujitsu Futurity X33 web framework:

- **Field groups**: Each business field has a group of related state variables (value, enable/disable, UI state) stored as `protected` fields. Each group is named `l_<fieldname>_update`, `l_<fieldname>_value`, `l_<fieldname>_enabled`, `l_<fieldname>_state`.
- **Interfaces**: It implements `X33VDataTypeBeanInterface` (data type dispatch for the X33V framework) and `X33VListedBeanInterface` (listed/row-based data handling). It also implements `Serializable` so instances can be serialized across request scopes.
- **Dispatcher pattern**: The trio of `loadModelData`, `storeModelData`, and `typeModelData` accept Japanese property names as keys (e.g., `"詳細インデックス"`) and subkeys (`"value"`, `"enable"`, `"state"`). This allows the view layer — a JSP page — to read and write bean fields through a generic contract without hardcoding field names. The dispatcher maps these to the actual Java getters/setters.
- **List membership**: `listKoumokuIds()` returns the canonical list of field names supported by this bean, enabling the framework to iterate over all fields dynamically.

This design separates the view's data access from the bean's internal field layout, making it possible to change field structures without updating every JSP expression.

## Key Methods

### Data Dispatcher (Read)

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

The central read-dispatcher. Given a Japanese property name and a subkey, returns the corresponding field value as an `Object`.

| Parameter | Type | Meaning |
|---|---|---|
| `key` | `String` | The property name (e.g. `"詳細インデックス"`) |
| `subkey` | `String` | One of `"value"`, `"enable"`, or `"state"` |

- Returns the value of the corresponding getter (e.g. `getL_detail_index_value()`, `getL_detail_index_enabled()`, or `getL_detail_index_state()`).
- Returns `null` if either parameter is `null` or no matching property is found.
- Subkey matching is case-insensitive (`equalsIgnoreCase`).

This method is the primary way the JSP reads field values. The framework's data-binding layer calls it to populate form controls.

### Data Dispatcher (Write)

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

A convenience overload. Delegates to `storeModelData(key, subkey, in_value, false)`.

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

A compatibility overload that ignores `gamenId` (reserved for future use) and delegates to the two-argument variant.

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

The main write-dispatcher. Given a property name, subkey, and value, routes to the correct setter.

| Parameter | Type | Meaning |
|---|---|---|
| `key` | `String` | Property name (e.g. `"オプションサービス名"`) |
| `subkey` | `String` | One of `"value"`, `"enable"`, or `"state"` |
| `in_value` | `Object` | The value to set |
| `isSetAsString` | `boolean` | Reserved flag (currently unused) |

- Performs a cast on `in_value` to the expected type (`String` or `Boolean`) before calling the setter.
- Returns `void` — side effects are on the bean's field values.
- Returns early (no-op) if `key` or `subkey` is `null`.

### Type Inspection

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

Returns the Java type of a field given its key and subkey.

| Parameter | Type | Meaning |
|---|---|---|
| `key` | `String` | Property name |
| `subkey` | `String` | `"value"`, `"enable"`, or `"state"` |

- Returns `String.class` for value and state subkeys on most fields.
- Returns `Boolean.class` for `enable` subkeys on fields that support enabled/disabled state.
- Returns `Boolean.class` for the `l_op_svc_niy_link_dsp_flg` value (a display flag).
- Returns `null` if no matching field or if `key`/`subkey` is `null`.

This method enables the framework to validate data types before setting values and to generate the correct HTML form elements.

### Metadata

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

Returns the complete list of supported property names. The 13 property names (all in Japanese) are:

| Property Name (Japanese) | Field Prefix | Type |
|---|---|---|
| `"詳細インデックス"` (Detail Index) | `l_detail_index_*` | String value, Boolean enabled, String state |
| `"オプションサービス名"` (Op Service Name) | `l_op_svc_cd_nm_*` | String value, Boolean enabled, String state |
| `"オプション内容"` (Op Content) | `l_op_svc_niy_*` | String value, Boolean enabled, String state |
| `"サブオプション内容"` (SubOp Content) | `l_sbop_svc_niy_*` | String value, Boolean enabled, String state |
| `"利用状況"` (Usage Status) | `l_op_svc_kei_stat_nm_*` | String value, Boolean enabled, String state |
| `"利用開始日"` (Start Date) | `l_svc_staymd_*` | String value, Boolean enabled, String state |
| `"解約予定日"` (Resignation Date) | `l_rsv_tsta_kibo_ymd_*` | String value, Boolean enabled, String state |
| `"利用終了日"` (End Date) | `l_svc_endymd_*` | String value, Boolean enabled, String state |
| `"オプションサービス契約番号"` (Contract Number) | `l_op_svc_kei_no_*` | String value, String state (no enabled) |
| `"オプションサービスコード"` (Service Code) | `l_op_svc_cd_*` | String value, String state (no enabled) |
| `"オプション内容リンク表示フラグ"` (Link Display Flag) | `l_op_svc_niy_link_dsp_flg_*` | Boolean value, String state |
| `"行スタイルクラス"` (Line Style Class) | `l_line_style_class_*` | String value, String state |
| `"行スタイルID"` (Line Style ID) | `l_line_style_id_*` | String value, String state |

Some fields (contract number, service code) only have value/state — no enabled/disabled toggle — because they are display-only identifiers.

### Index

#### `getIndex() → int` / `setIndex(int index) → void`

Tracks the row index in a data table. Used to maintain ordering when the JSP renders repeated bean instances as a table.

### Individual Field Getters/Setters

Each field group has four accessor methods:

| Getter | Setter | Returns |
|---|---|---|
| `getL_<field>_update()` | `setL_<field>_update(String)` | The `_update` flag (not yet populated — always null in the constructor) |
| `getL_<field>_value()` | `setL_<field>_value(String or Boolean)` | The current data value |
| `getL_<field>_enabled()` | `setL_<field>_enabled(Boolean)` | Whether the field is editable/enabled |
| `getL_<field>_state()` | `setL_<field>_state(String)` | UI state (e.g., CSS styling or validation state) |

All `_value` fields default to `""` (empty string) except `l_op_svc_niy_link_dsp_flg_value` which defaults to `false`. All `_enabled` fields default to `false`.

## Relationships

```mermaid
flowchart TD
    JSP["CRW027020PJP<br/>JSP Page<br/>References Bean"]
    BEAN["CRW02702SF01DBean<br/>Data Bean<br/>Field holder +<br/>Data dispatch"]
    IF1["X33VDataTypeBeanInterface<br/>Data type dispatch"]
    IF2["X33VListedBeanInterface<br/>Listed data handling"]
    IF3["Serializable"]

    JSP --> BEAN
    IF1 -.-> BEAN
    IF2 -.-> BEAN
    IF3 -.-> BEAN

    F1["l_detail_index_*"]
    F2["l_op_svc_cd_nm_*"]
    F3["l_op_svc_niy_*"]
    F4["l_sbop_svc_niy_*"]
    F5["l_op_svc_kei_stat_nm_*"]
    F6["l_svc_staymd_*"]
    F7["l_rsv_tsta_kibo_ymd_*"]
    F8["l_svc_endymd_*"]
    F9["l_op_svc_kei_no_*"]
    F10["l_op_svc_cd_*"]
    F11["l_op_svc_niy_link_dsp_flg_*"]
    F12["l_line_style_class_*"]
    F13["l_line_style_id_*"]

    BEAN --> F1
    BEAN --> F2
    BEAN --> F3
    BEAN --> F4
    BEAN --> F5
    BEAN --> F6
    BEAN --> F7
    BEAN --> F8
    BEAN --> F9
    BEAN --> F10
    BEAN --> F11
    BEAN --> F12
    BEAN --> F13
```

**Inbound (1 dependency)**:

- `CRW027020PJP.jsp` — The JSP page that renders the service contract detail screen. It creates instances of this bean, sets field values, and reads them back via both the dispatcher and individual getters/setters.

**Outbound (no direct Java dependencies)**:

- No outbound Java references beyond the framework interfaces and `java.io.Serializable`.

## Usage Example

A typical flow in the JSP:

1. **Creation**: The framework creates an instance of `CRW02702SF01DBean` for each row of the data table, often in a loop.

2. **Population**: Business logic (e.g., `CRW02702SFLogic`) sets field values via the dispatcher:
   ```java
   bean.storeModelData("オプションサービス名", "value", "Some Service");
   bean.storeModelData("オプションサービス名", "enable", true);
   bean.storeModelData("利用開始日", "value", "20230101");
   bean.storeModelData("オプション内容リンク表示フラグ", "value", true);
   ```

3. **Rendering**: The JSP reads values back via the dispatcher:
   ```jsp
   <c:out value="${bean.loadModelData('オプションサービス名', 'value')}"/>
   <c:out value="${bean.loadModelData('利用開始日', 'value')}"/>
   ```

4. **Type-aware rendering**: The `typeModelData` method allows the framework to determine HTML element types:
   ```jsp
   <c:if test="${bean.typeModelData('オプション内容', 'enable') == boolean}">
       <input type="checkbox" />
   </c:if>
   ```

5. **Row tracking**: The `index` property distinguishes rows in multi-row table rendering.

## Notes for Developers

- **All fields are `protected`** — subclasses and the framework can access them directly, but external code should use the public getters/setters or the dispatcher methods.
- **No threading safety** — this is a request-scoped bean. A new instance is created per request (or per table row within a request). Do not share instances across threads.
- **The `_update` fields** are always `null` at construction time. They appear to be reserved for framework-internal change tracking but are not populated by the current code.
- **Subkey matching is case-insensitive** — `"value"`, `"VALUE"`, and `"Value"` all match. This is important for JSP EL expressions.
- **Property names are Japanese** — the dispatcher uses literal Japanese strings. Adding a new field requires updating `loadModelData`, `storeModelData`, `typeModelData`, and `listKoumokuIds` in lockstep. This is the main coupling concern.
- **`isSetAsString` parameter** in `storeModelData` is accepted but not used in the current implementation — it is reserved for future type coercion logic.
- **The `separaterPoint` variable** (a typo of `separatorPoint`) is computed but never used. It was likely intended for supporting hierarchical keys like `"group/subfield"` but is currently dead code.
- **All `_state` fields default to `""`** — empty string represents an unstyled/default state. CSS class names or validation messages are set via the `_state` field to control row styling.
- **`l_line_style_class_*` and `l_line_style_id_*`** are presentation-only fields used to apply CSS classes and IDs to table rows — likely for highlighting specific rows (e.g., rows with active link flags).
