# Business Logic — MsgEditer.setBulk() [7 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.MsgEditer` |
| Layer | Common Component / Utility (Package: `com.fujitsu.futurity.bp.custom.common`) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### MsgEditer.setBulk()

`MsgEditer.setBulk()` is a bulk key-value setter utility method that populates a `CAANMsg` (Communication Application ANdle Message — a message envelope used across the Fujitsu Futurity application framework) with multiple key-value pairs in a single invocation. It operates as a batch/iteration pattern: given a `String[][]` array where each inner array contains a key-value pair (`key[0]` = key, `key[1]` = value), it iterates over each pair and delegates to the `set(CAANMsg, String, Object)` method, which in turn handles null/empty value normalization before writing to the message.

The `set()` method ensures data integrity by treating `null` or empty string (`""`) values as database nulls (via `msg.setNull(key)`), while non-empty values are stored via `msg.set(key, value)`. This normalization prevents empty strings from being inadvertently persisted as blank data.

This method serves as a shared utility called from various screens and CBS (Common Business Service) classes to bulk-populate message payloads — for example, when building a request message to a service component (SC) with many parameters, or when transferring form data from a screen request into a business logic message envelope. It implements a **delegation pattern** combined with a **batch-set loop** to keep caller code concise: instead of writing individual `set()` calls for each field, a caller passes a 2D array and lets `setBulk()` handle the iteration.

**Design pattern:** Batch iteration with delegation. This method does not introduce conditional branches or routing logic — it provides uniform treatment to all key-value pairs in the input array.

**Caller analysis:** No callers were found in the codebase that reference `MsgEditer.setBulk()` directly (via `JKKWribSvcKeiOperateCC.setBulk(...)` or a qualified class reference). This suggests the method may be invoked via reflection, accessed from dynamically loaded classes, or its callers reside in a module not present in the scanned file tree.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setBulk(CAANMsg msg, String[][] keyValues)"])

    START --> FOR["for each keyValue in keyValues"]
    FOR --> EXTRACT1["key = keyValue[0]"]
    EXTRACT1 --> EXTRACT2["value = keyValue[1]"]
    EXTRACT2 --> CALL["set(msg, key, value)"]
    CALL --> NEXT["next iteration"]
    NEXT --> FOR
    FOR --> END(["Return / Done"])
```

**Block description:**

1. **Entry:** `setBulk()` receives a `CAANMsg` message envelope and a `String[][]` array of key-value pairs.
2. **Loop:** Iterates over each `String[]` element in `keyValues`.
3. **Extract key:** Reads `keyValue[0]` as the message field key.
4. **Extract value:** Reads `keyValue[1]` as the value to set.
5. **Delegate:** Calls `set(msg, key, value)` — which internally resolves null/empty values into database nulls via `msg.setNull(key)`, or stores non-empty values via `msg.set(key, value)`.
6. **Repeat:** Continues until all key-value pairs are processed.
7. **Exit:** Returns void — no return value.

There are **no conditional branches** at the `setBulk()` level itself. All branching (null-check, empty-string-check) occurs within the delegated `set()` method.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `msg` | `CAANMsg` | The message envelope (business data carrier) to be populated. In the Fujitsu Futurity framework, `CAANMsg` is a strongly-typed message object built from a schema (e.g., request/response messages for service components). This method modifies the payload of that message. |
| 2 | `keyValues` | `String[][]` | A 2D array of key-value pairs to populate into the message. Each inner array must have at least two elements: `[0]` = the message field key (matching a field defined in the CAANMsg schema), `[1]` = the value to assign. If the inner array has fewer than 2 elements, an `ArrayIndexOutOfBoundsException` will occur at runtime. Empty strings (`""`) in position `[1]` are normalized to null. |

**No instance fields or external state** are read by this method. It is a pure static utility with no side effects beyond modifying the `msg` parameter.

## 4. CRUD Operations / Called Services

This method performs **no database or SC-level CRUD operations** itself. It operates entirely in-memory on the `CAANMsg` object. The only method it delegates to is `set()`, which is a local in-memory operation within the `CAANMsg` class.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | `set(CAANMsg msg, String key, Object value)` | — | — | In-memory setter on CAANMsg — writes key-value pairs into the message envelope. Null/empty values → `msg.setNull(key)`, otherwise → `msg.set(key, value)`. No database interaction. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | — (not found in scanned files) | `N/A` | `set(CAANMsg, String, Object) [in-memory]` |

**Notes:** No callers were found in the codebase. The method is declared as `public static` and is available for use by any class in the same module (`common` package) or external callers. The `set()` method it delegates to is also static and defined in the same `MsgEditer` class.

## 6. Per-Branch Detail Blocks

**Block 1** — [FOR-EACH LOOP] (L16585)

> Iterates over the `keyValues` array, extracting each key-value pair and delegating to `set()`.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (String[] keyValue : keyValues)` |
| 2 | SET | `key = keyValue[0]` // Extract field key from pair |
| 3 | SET | `value = keyValue[1]` // Extract value from pair |
| 4 | CALL | `set(msg, key, value)` // Delegate to local setter |

**Block 1.1** — [Nested method: `set(CAANMsg msg, String key, Object value)`] (L16570–L16576)

> The `set()` method resolves null and empty-string values into database nulls, ensuring data integrity.

| # | Type | Code |
|---|------|------|
| 1 | IF | `null == value || "".equals(value)` [empty/null check] (L16570) |
| 1.1 | [IF-TRUE] | `setRaw(msg, key, value, true)` // Mark value as null (L16572) |
| 1.2 | [IF-FALSE] | `setRaw(msg, key, value, false)` // Store value normally (L16574) |

**Block 1.1.1** — [Nested method: `setRaw(CAANMsg msg, String key, Object value, boolean isNull)`] (L16558–L16564)

> Low-level setter that directly invokes `CAANMsg.setNull()` or `CAANMsg.set()`.

| # | Type | Code |
|---|------|------|
| 1 | IF | `isNull` [boolean flag from caller] (L16559) |
| 1.1 | [IF-TRUE] | `msg.setNull(key)` // Store as database null (L16560) |
| 1.2 | [IF-FALSE] | `msg.set(key, value)` // Store actual value (L16562) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `CAANMsg` | Class | Communication Application ANdle Message — the core message envelope class in the Fujitsu Futurity framework, used to carry request/response data between screens, CBS classes, and service components. Fields are strongly typed via a schema. |
| `keyValues` | Parameter | A 2D String array where each inner array holds a key-value pair for bulk message population. `[0]` = field key, `[1]` = field value. |
| `setBulk()` | Method | Bulk setter — iterates over key-value pairs and populates a CAANMsg. Contrast with `set()` which handles a single pair with null/empty normalization. |
| `set()` | Method | Single key-value setter with null/empty value normalization (converts `null` or `""` to DB null). |
| `setRaw()` | Method | Low-level setter — directly stores or nulls a value based on a boolean flag, no normalization. |
| `keyValue[0]` | Field | The message field key (e.g., `"CD00037"`) — must match a field name defined in the CAANMsg schema. |
| `keyValue[1]` | Field | The message field value (e.g., `"1"`, `"01"`) — the string value to assign to the key. |

---

*Document auto-generated. Method source: `JKKWribSvcKeiOperateCC.java` lines 16584–16590.*
