# KKW01023SF03DBean

## Purpose

`KKW01023SF03DBean` is a data transfer object (DTO) / "data bean" within the Fujitsu Futurity X33 web framework. It holds the UI-bound state for a single row of a data entry screen dealing with service charge and discount management — specifically item identifiers, internal content descriptions, category codes, discount application counts, discount effective dates, and service charge start/end dates. Its primary job is to carry field-level data (values, enabled/disabled flags, and validation states) between the JSP view and the underlying business logic.

## Design

This class follows the **active record / data bean** pattern used throughout the X33 framework. It implements three interfaces:

- **`X33VDataTypeBeanInterface`** — requires `loadModelData`, `storeModelData`, and `typeModelData` methods that bridge field-level keys (Japanese labels like "番号", "割引適用回数") to typed Java values.
- **`X33VListedBeanInterface`** — requires `listKoumokuIds()` which returns the list of recognized field keys.
- **`Serializable`** — allows the bean to be serialized (e.g., stored in session scope).

It does not extend any base class, though it imports `X33VViewBaseBean` (likely as a reference). This is a pure, flat data container with no behavior beyond getter/setter access and model data routing.

### Field Structure

Each of the 8 business fields follows an identical 4-property micro-pattern:

| Field (internal name) | Japanese label | `_value` (type) | `_enabled` (type) | `_state` (type) | `_update` (type) |
|---|---|---|---|---|---|
| `no` | 番号 (Item ID) | `String` (default `""`) | `Boolean` (default `false`) | `String` (default `""`) | `String` (nullable) |
| `ucwk_ny` | 内容内容 (Internal Content) | `String` (default `""`) | `Boolean` (default `false`) | `String` (default `""`) | `String` (nullable) |
| `sbt_cd` | 種類コード (Category Code) | `String` (default `""`) | `Boolean` (default `true`) | `String` (default `""`) | `String` (nullable) |
| `sbt_cd_nm` | 種類コード名称 (Category Code Name) | `String` (default `""`) | `Boolean` (default `false`) | `String` (default `""`) | `String` (nullable) |
| `wrib_aply_cnt` | 割引適用回数 (Discount Application Count) | `String` (default `""`) | `Boolean` (default `false`) | `String` (default `""`) | `String` (nullable) |
| `first_wrib_aply_ymd` | 初回割引適用年月日 (First Discount Date) | `String` (default `""`) | `Boolean` (default `false`) | `String` (default `""`) | `String` (nullable) |
| `svc_chrg_staymd` | サービス課金開始年月日 (Charge Start Date) | `String` (default `""`) | `Boolean` (default `false`) | `String` (default `""`) | `String` (nullable) |
| `svc_chrg_endymd` | サービス課金終了年月日 (Charge End Date) | `String` (default `""`) | `Boolean` (default `false`) | `String` (default `""`) | `String` (default `""`) | `String` (nullable) |

That's 32 field properties plus an `index` (int, for row ordering in a table).

### `_update`, `_state`, and `_enabled` Semantics

Each field has:
- **`*_value`** — the actual data displayed or collected on the form. Initialized to `""`.
- **`*_enabled`** — a boolean flag indicating whether the field is interactive (editable) on the UI. Most default to `false` (read-only), except `sbt_cd` which defaults to `true`.
- **`*_state`** — a string holding validation or rendering state (e.g., error messages, CSS state classes). Initialized to `""`.
- **`*_update`** — a string flag likely used by the X33 framework to track whether a field has been modified in the current screen session (dirty tracking). Not initialized.

The `_enabled` default of `false` for most fields suggests they are rendered as read-only by default and only made interactive when the application explicitly enables them.

## Key Methods

### Constructors

**`KKW01023SF03DBean()`** (line 80)

The no-arg constructor. It is empty except for generating a constant string (commented as "コンストラクタの宣言部生成" — constructor declaration block generation). No initialization logic is performed; all fields use their declared defaults.

### Getter / Setter Pairs (64 methods)

For each of the 32 sub-fields, there is a standard getter and setter:

```java
public String getNo_value() { return this.no_value; }
public void setNo_value(String param) { this.no_value = param; }
public Boolean getNo_enabled() { return this.no_enabled; }
public void setNo_enabled(Boolean param) { this.no_enabled = param; }
```

These are auto-generated, trivial accessors. The `Boolean` type (object wrapper) for `*_enabled` fields — as opposed to the primitive `boolean` — allows `null` to represent an "unset" state, which may be significant to the X33 framework's data binding logic.

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

This is one of the two most important methods (alongside `storeModelData`). It retrieves a typed value from the bean based on a **human-readable field label** (`key`) and a **sub-property name** (`subkey`).

- **`key`** — one of the 8 Japanese labels: "番号", "内容内容", "種類コード", "種類コード名称", "割引適用回数", "初回割引適用年月日", "サービス課金開始年月日", "サービス課金終了年月日".
- **`subkey`** — one of "value", "enable", or "state" (case-insensitive comparison via `equalsIgnoreCase`).

For example, calling `loadModelData("番号", "value")` returns the `no_value` string, and `loadModelData("割引適用回数", "enable")` returns the `wrib_aply_cnt_enabled` boolean.

If the key/subkey pair does not match any known field, or if either parameter is `null`, the method returns `null`.

The method body contains a long chain of `if-else` branches — one per field — making the routing explicit and easy to audit.

### `storeModelData(...)` (3 overloaded versions)

These are the write-side counterparts to `loadModelData`.

**`storeModelData(String gamenId, String key, String subkey, Object in_value)`** (line 485)

Takes a screen ID (`gamenId`, unused in the body — noted as "予備" meaning reserved) and delegates to the 3-parameter version. The screen ID parameter suggests this method was designed to support multi-screen routing but currently ignores it.

**`storeModelData(String key, String subkey, Object in_value)`** (line 496)

Delegates to the 4-parameter version with `isSetAsString = false`.

**`storeModelData(String key, String subkey, Object in_value, boolean isSetAsString)`** (line 508)

The full implementation. If `key` or `subkey` is `null`, it returns without doing anything. Otherwise, it uses the same `if-else` branching logic as `loadModelData` to route to the correct setter:

- `subkey.equalsIgnoreCase("value")` → calls the `setXxx_value()` method
- `subkey.equalsIgnoreCase("enable")` → calls the `setXxx_enabled()` method
- `subkey.equalsIgnoreCase("state")` → calls the `setXxx_state()` method

The cast `(String) in_value` or `(Boolean) in_value` is unguarded — the caller is responsible for passing the correct type.

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

A `static` method that returns a list of all 8 recognized Japanese field labels in order:

1. 番号
2. 内容内容
3. 種類コード
4. 種類コード名称
5. 割引適用回数
6. 初回割引適用年月日
7. サービス課金開始年月日
8. サービス課ン金終了年月日

This method is called by the X33 framework to build form field metadata, likely for dynamic form generation or iteration.

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

Returns the Java type of a field given its label and sub-property. This is the type-safe counterpart to `loadModelData`:

- For `subkey` = "value" or "state" → returns `String.class`
- For `subkey` = "enable" → returns `Boolean.class`

Like the other routing methods, if the key/subkey pair is unrecognized or either is `null`, it returns `null`.

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

Simple getter/setter for an integer row index, likely used for ordering rows in a tabular display.

## Relationships

```mermaid
flowchart TD
    A["KKW01023SF03DBean"] --> B["KKW010230PJP.jsp"]
    A --> C["X33VDataTypeBeanInterface"]
    A --> D["X33VListedBeanInterface"]
    A --> E["Serializable"]
    subgraph Properties["Data Properties"]
        F1["no (Item ID)"]
        F2["ucwk_ny (Internal Content)"]
        F3["sbt_cd (Category Code)"]
        F4["sbt_cd_nm (Category Code Name)"]
        F5["wrib_aply_cnt (Discount Application Count)"]
        F6["first_wrib_aply_ymd (First Discount Date)"]
        F7["svc_chrg_staymd (Charge Start Date)"]
        F8["svc_chrg_endymd (Charge End Date)"]
    end
    A --> F1
    A --> F2
    A --> F3
    A --> F4
    A --> F5
    A --> F6
    A --> F7
    A --> F8
```

**Inbound:** The JSP page `KKW010230PJP.jsp` references this bean, presumably in a table or form context to display/edit the data it contains.

**Outbound:** No outbound references to other application classes. It depends on X33 framework interfaces (`X33VDataTypeBeanInterface`, `X33VListedBeanInterface`), Java `Serializable`, `java.util.ArrayList`, and `javax.faces.model.SelectItem`.

## Usage Example

A typical usage pattern within the X33 framework:

```java
// Create a bean instance for a single row
KKW01023SF03DBean row = new KKW01023SF03DBean();

// Set data via model keys (used by X33 framework binding)
row.storeModelData("番号", "value", "001");
row.storeModelData("割引適用回数", "value", "3");
row.storeModelData("割引適用回数", "enable", true);

// Retrieve via the same key-based routing
Object itemId = row.loadModelData("番号", "value");   // returns "001"
Boolean canEdit = row.loadModelData("割引適用回数", "enable"); // returns true

// Get the class type for type checking
Class<?> type = row.typeModelData("番号", "value");    // returns String.class

// Get the full list of field keys for iteration
ArrayList<String> fields = KKW01023SF03DBean.listKoumokuIds();

// Or use direct getters/setters
row.setNo_value("002");
String val = row.getNo_value();  // "002"
```

The bean is typically stored in request or session scope and accessed from the JSP page via EL (Expression Language) or scriptlet bindings.

## Notes for Developers

- **Auto-generated code**: This class is generated by the "Web Client tool" (Web Client tool V01/L01). Manual edits will be lost on regeneration. Any changes should be made through the code generation configuration.
- **No thread safety**: The bean is a mutable, stateful data holder. It is not designed for concurrent access. Each row/record should get its own instance.
- **Type casts in storeModelData**: The `storeModelData(String, String, Object, boolean)` method performs unguarded casts `(String)` and `(Boolean)` on the `in_value` parameter. Passing the wrong type will cause a `ClassCastException` at runtime. The `isSetAsString` parameter is declared but never used in the method body — it may be vestigial or intended for future Long-type support.
- **Unused `separaterPoint` variable**: Both `loadModelData` and `storeModelData` compute `int separaterPoint = key.indexOf("/");` but never use it. This suggests the original design supported a hierarchical key format like `"screen/番号"` but the current implementation does not.
- **`gamenId` is unused**: The 4-parameter `storeModelData` accepts a screen ID but immediately delegates without using it.
- **Japanese labels as keys**: The routing in `loadModelData`, `storeModelData`, and `typeModelData` uses Japanese strings (e.g., "番号") as keys rather than English field names. These are hardcoded literals — a typo in any of them would silently cause a `null` return with no compile-time warning.
- **`_enabled` is `Boolean` (wrapper)**: Using the wrapper class instead of the primitive `boolean` means the field can be `null`, which the X33 framework may interpret as "uninitialized". Code checking enabled state should guard against `null`.
- **`_update` fields are nullable and never initialized**: The `*_update` fields have no default value and the class never sets them. They may be populated by a separate X33 framework mechanism (e.g., before/after screen load comparison) rather than by this bean's own methods.
- **`_state` is `String` for all fields**: The state field can hold arbitrary strings — likely validation error messages, CSS class names, or framework-rendering hints. Its exact meaning is determined by the X33 framework's view layer.
