# KKW22301SF01DBean

## Purpose

`KKW22301SF01DBean` is a **data-binding bean** (data model object) for the KKW22301 service screen in a Fujitsu Futurity X33/X31 web application framework. It holds the domain state for three key fields — Service Contract Number (`svc_kei_no`), System ID (`sysid`), and Billing Contract Number (`seiky_kei_no`) — each with value, enabled state, and display state properties. Its primary role is to act as a bridge between the JSP view layer and the framework's data-binding machinery, allowing the framework to load, store, and introspect field metadata at runtime via reflection-like method calls.

This bean is generated by the "Web Client tool V01/L01" (version 2.0.39) and follows the convention of auto-generated data beans in this codebase.

## Design

`KKW22301SF01DBean` serves as a **plain data model object (DTO)** that integrates with the Fujitsu Futurity X33 framework's `X33VDataTypeBeanInterface` and `X33VListedBeanInterface`. These interfaces require the bean to provide:

- **Dynamic data access**: `loadModelData`, `storeModelData`, and `typeModelData` methods that let the framework resolve field values, store incoming values, and discover types at runtime using string-based keys (field name + subkey). This is the framework's way of supporting loosely-coupled data binding without requiring annotations or a schema file.
- **Field enumeration**: `listKoumokuIds` (a static method) returns the set of valid field identifiers the framework can iterate over.

The class implements `Serializable`, making it safe for HTTP session storage or passivation. It has no superclass.

The three domain fields each expose a standard four-property pattern:

| Field (Internal ID) | Japanese Label | Properties |
|---|---|---|
| `svc_kei_no` | サービス契約番号 (Service Contract Number) | `value`, `enabled`, `state`, `update` |
| `sysid` | SYSID | `value`, `enabled`, `state`, `update` |
| `seiky_kei_no` | 請求契約番号 (Billing Contract Number) | `value`, `enabled`, `state`, `update` |

Each field's subkey properties follow this convention:
- **`value`** — The actual data value (String)
- **`enable`** — Whether the field is enabled for editing (Boolean)
- **`state`** — The field's display state (e.g., error, disabled) as a String
- **`update`** — Update status flag (String), accessible only via direct getter

This appears to be a standard pattern for form-bound fields in the X33 framework, where `value` carries the data, `enable` controls interactivity, and `state` carries visual/hint metadata (such as validation error messages).

## Class Diagram

```mermaid
classDiagram
    class KKW22301SF01DBean {
        -String svc_kei_no_update
        -String svc_kei_no_value
        -Boolean svc_kei_no_enabled
        -String svc_kei_no_state
        -String sysid_update
        -String sysid_value
        -Boolean sysid_enabled
        -String sysid_state
        -String seiky_kei_no_update
        -String seiky_kei_no_value
        -Boolean seiky_kei_no_enabled
        -String seiky_kei_no_state
        -int index
        +KKW22301SF01DBean()
        +String getSvc_kei_no_update()
        +void setSvc_kei_no_update(String)
        +String getSvc_kei_no_value()
        +void setSvc_kei_no_value(String)
        +Boolean getSvc_kei_no_enabled()
        +void setSvc_kei_no_enabled(Boolean)
        +String getSvc_kei_no_state()
        +void setSvc_kei_no_state(String)
        +String getSysid_update()
        +void setSysid_update(String)
        +String getSysid_value()
        +void setSysid_value(String)
        +Boolean getSysid_enabled()
        +void setSysid_enabled(Boolean)
        +String getSysid_state()
        +void setSysid_state(String)
        +String getSeiky_kei_no_update()
        +void setSeiky_kei_no_update(String)
        +String getSeiky_kei_no_value()
        +void setSeiky_kei_no_value(String)
        +Boolean getSeiky_kei_no_enabled()
        +void setSeiky_kei_no_enabled(Boolean)
        +String getSeiky_kei_no_state()
        +void setSeiky_kei_no_state(String)
        +int getIndex()
        +void setIndex(int)
        +Object loadModelData(String key, String subkey)
        +void storeModelData(String gamenId, String key, String subkey, Object in_value)
        +void storeModelData(String key, String subkey, Object in_value)
        +void storeModelData(String key, String subkey, Object in_value, boolean isSetAsString)
        +ArrayList<String> listKoumokuIds()
        +Class<?> typeModelData(String key, String subkey)
    }

    KKW22301SF01DBean --> X33VDataTypeBeanInterface : implements
    KKW22301SF01DBean --> X33VListedBeanInterface : implements
    KKW22301SF01DBean --> Serializable : implements
```

## Key Methods

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

Retrieves a field value by string-based key. The framework calls this method to dynamically read property values from the bean without using reflection.

- **Parameters:**
  - `key` — The Japanese display name of the field (e.g., `"サービス契約番号"`, `"SYSID"`, `"請求契約番号"`)
  - `subkey` — One of `"value"`, `"enable"`, or `"state"` (case-insensitive)
- **Returns:** The corresponding `Object` value, or `null` if the key/subkey combination is not recognized or either parameter is `null`
- **Side effects:** None
- **Behavior:** Routes to the appropriate getter. For example, `key = "SYSID"` + `subkey = "enable"` returns `getSysid_enabled()`.

This method is the read-side counterpart to `storeModelData`. It supports exactly three field names and three subkeys each, yielding 9 possible (key, subkey) combinations.

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

Sets a field value by string-based key. This is the `X33VListedBeanInterface` required overload.

- **Parameters:**
  - `gamenId` — Screen ID (reserved/unused in implementation; passed through to the next overload)
  - `key` — The Japanese display name (same as `loadModelData`)
  - `subkey` — `"value"`, `"enable"`, or `"state"`
  - `in_value` — The value to set
- **Returns:** Nothing
- **Side effects:** Delegates to the 3-parameter overload, which delegates to the 4-parameter overload, performing the actual setter call.
- **Behavior:** Performs a cast on `in_value` and calls the appropriate setter: `(String)` for value/state, `(Boolean)` for enable. No null-safety or type checking is performed beyond the cast — passing the wrong type will cause a `ClassCastException`.

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

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

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

The core implementation of the write-side data binding.

- **Parameters:**
  - `key` — Japanese field name
  - `subkey` — `"value"`, `"enable"`, or `"state"`
  - `in_value` — Value to set
  - `isSetAsString` — When `true`, controls behavior for Long-type property writes as a String (though this bean has no Long properties; the parameter is reserved for framework generality)
- **Returns:** Nothing
- **Side effects:** Sets the corresponding field via the direct setter
- **Behavior:** Mirrors `loadModelData` routing. If `subkey` is `"value"`, calls `setXxx_value()`. If `"enable"`, calls `setXxx_enabled()`. If `"state"`, calls `setXxx_state()`. Returns silently if `key` or `subkey` is `null`.

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

Returns the expected Java type for a given field/subkey pair.

- **Parameters:**
  - `key` — Japanese field name
  - `subkey` — `"value"`, `"enable"`, or `"state"`
- **Returns:** The `Class` object: `String.class` for `value` and `state`, `Boolean.class` for `enable`, or `null` for unknown combinations
- **Side effects:** None

This method allows the framework to perform type-safe validation or conversion when storing values.

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

A **static** method that returns the list of valid Japanese field names.

- **Returns:** An `ArrayList<String>` containing `"サービス契約番号"`, `"SYSID"`, `"請求契約番号"`
- **Side effects:** Creates a new `ArrayList` each time it is called (no caching)
- **Usage:** The framework iterates over these to discover all bindable fields on the bean.

Note: This method is `static` — unusual for a data bean, and unlike `loadModelData`/`storeModelData`/`typeModelData` which are instance methods, this can be called without instantiating the bean.

### Direct Getters and Setters

Each of the 12 data fields (`svc_kei_no_*`, `sysid_*`, `seiky_kei_no_*`) has a standard getter and setter pair. There are also `getIndex()` / `setIndex(int)` for list-item positioning. The `update` fields (e.g., `svc_kei_no_update`) are `String` types accessible only through direct getters/setters — they are not routed through the dynamic `loadModelData`/`storeModelData` methods.

### Default Field Values

On construction:
- All `_value` fields default to `""` (empty string)
- All `_enabled` fields default to `false`
- All `_state` fields default to `""` (empty string)
- `index` defaults to `0` (Java int default)
- All `_update` fields default to `null`

## Usage Example

Here is a typical calling pattern where the X33 framework binds a JSP form to this bean:

```java
KKW22301SF01DBean bean = new KKW22301SF01DBean();

// Framework-driven: store a value from the request
bean.storeModelData("", "サービス契約番号", "value", "SC-2024-0001");
bean.storeModelData("", "サービス契約番号", "enable", true);
bean.storeModelData("", "SYSID", "value", "SYS-42");
bean.storeModelData("", "SYSID", "enable", false);

// Framework-driven: read values back
Object svcValue = bean.loadModelData("サービス契約番号", "value");
// => "SC-2024-0001"

Object sysidEnabled = bean.loadModelData("SYSID", "enable");
// => Boolean(false)

// Framework-driven: type checking
Class<?> svcType = bean.typeModelData("サービス契約番号", "value");
// => String.class

// Iterating over all field names (static method)
ArrayList<String> fields = KKW22301SF01DBean.listKoumokuIds();
// => ["サービス契約番号", "SYSID", "請求契約番号"]
```

## Relationships

### Who Depends on This Class

| Consumer | Description |
|---|---|
| `KKW223010P.jsp` | The JSP view page that renders the form. It accesses this bean's properties to display and collect user input. |

### What This Class Depends On

The bean depends on the Fujitsu Futurity X33/X31 framework interfaces:

- `X33VDataTypeBeanInterface` — requires `loadModelData`, `typeModelData`, and the 4-parameter `storeModelData`
- `X33VListedBeanInterface` — requires `listKoumokuIds` and the `gamenId`-parameter variant of `storeModelData`
- `Serializable` — standard Java serialization marker

No other classes in this codebase import or use this bean directly beyond the JSP, indicating a **single-screen data model** that is tightly coupled to its view page.

```mermaid
flowchart TD
    A["KKW223010P.jsp"] --> B["KKW22301SF01DBean"]

    B --> C["loadModelData<br/>key + subkey -> Object"]
    B --> D["storeModelData<br/>key + subkey + value -> void"]
    B --> E["typeModelData<br/>key + subkey -> Class<?>"]
    B --> F["listKoumokuIds<br/>static -> String[]"]

    C --> G["svc_kei_no<br/>value/enable/state"]
    C --> H["sysid<br/>value/enable/state"]
    C --> I["seiky_kei_no<br/>value/enable/state"]

    D --> G
    D --> H
    D --> I
```

## Notes for Developers

- **Not thread-safe.** This bean holds mutable instance state and is designed for per-request/scoped usage. Do not share instances across threads without external synchronization.
- **Japanese-language keys.** The `key` parameter in `loadModelData`, `storeModelData`, `typeModelData`, and `listKoumokuIds` uses Japanese strings (e.g., `"サービス契約番号"`). This is a framework convention where the field name in Japanese serves as the lookup key. Do not use the internal Java field names (e.g., `svc_kei_no`) as keys — they will not match.
- **Case-insensitive subkeys.** The `subkey` parameter is compared using `equalsIgnoreCase`, so `"VALUE"`, `"Value"`, and `"value"` all work. The accepted values are `"value"`, `"enable"`, and `"state"`.
- **Type casting risk.** `storeModelData` performs unchecked casts on `in_value`. Passing a `String` for an `enable` subkey (which expects `Boolean`) will throw a `ClassCastException` at runtime.
- **`update` fields are not dynamically accessible.** The `svc_kei_no_update`, `sysid_update`, and `seiky_kei_no_update` fields are not routed through `loadModelData`/`storeModelData`. They can only be accessed via their direct getters and setters.
- **`isSetAsString` parameter is unused.** The 4-parameter `storeModelData` has a boolean `isSetAsString` that is intended to control Long-to-String conversion for other beans in the framework, but this bean has no Long properties, so the parameter has no effect.
- **`gamenId` parameter is unused.** The `gamenId` (screen ID) parameter in the `X33VListedBeanInterface` overload is passed through but never used — the method ignores it and delegates to the 3-parameter overload.
- **Every call to `listKoumokuIds()` allocates a new `ArrayList`.** If called in a hot loop, this creates unnecessary garbage. Consider caching the result.
- **Auto-generated code.** This bean was generated by the "Web Client tool V01/L01". Any changes to the underlying data model (adding fields) should be done through the tool rather than by hand-editing, to maintain consistency with other generated artifacts.
- **No validation logic.** The bean stores raw values and metadata. Validation, conversion, and business logic belong elsewhere in the MVC stack (likely in the controller/bean processing layer).
- **`index` field.** The `index` field is likely used by the framework for list-based forms or for tracking the position of this record within a list of similar beans. Its usage is not directly documented in the bean itself.
