# Business Logic — Mover.getLongArray() [11 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.KKW01021SF.Mover` |
| Layer | Utility / Common Component |
| Module | `KKW01021SF` (Package: `eo.web.webview.KKW01021SF`) |

## 1. Role

### Mover.getLongArray()

This method is a **data conversion utility** that extracts a variable-length list of `Long` values from a DataBean (structured business data container) and returns them as a `Long[]` array. It operates as part of the `Mover` class, which serves as a shared facade within the `KKW01021SF` module — a screen processing component for the "Discount Service Contract Overview" screen (割引サービス契約一覧照会, discount service contract list inquiry).

The method implements the **iterator pattern** for typed data extraction: it first queries the DataBean for the count of elements associated with a given item key (via `getArrayCount`), then iterates over each index to fetch the individual `Long` value (via `getLongAt`), and finally assembles them into a properly typed array. This is a general-purpose collection method that mirrors the same pattern used by `getStringArray` and `getBooleanArray` — together forming a family of homogeneous type-conversion helpers.

Its **role in the larger system** is that of a reusable data accessor. It is not tied to any specific business entity or domain; instead, it is called by higher-level methods (such as `getBeanMapFromDataBean`) to reconstruct structured objects from the flat key-value structure stored in a DataBean. In this architecture, DataBeans carry data from the presentation layer through to business logic, and `getLongArray` provides the bridge from the DataBean's indexed storage model back to a native Java array.

The method has no conditional branches — it always executes the same linear path: retrieve count, iterate, collect, convert, return.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getLongArray(bean, item)"])
    COUNT["getArrayCount(bean, item) — retrieve array count"]
    INIT["new ArrayList<Long>(count) — initialize result list"]
    LOOP["for i = 0; i < count; i++ — iterate over each index"]
    GET["getLongAt(bean, item, i) — retrieve Long at index i"]
    ADD["result.add(element) — add Long to list"]
    CONVERT["result.toArray(new Long[0]) — convert to Long array"]
    RETURN["return Long[] — return populated array"]
    END(["Return Long[]"])

    START --> COUNT
    COUNT --> INIT
    INIT --> LOOP
    LOOP --> GET
    GET --> ADD
    ADD --> LOOP
    LOOP --> CONVERT
    CONVERT --> RETURN
    RETURN --> END
```

The method follows a straightforward sequential flow:

1. **Count retrieval**: Delegates to `getArrayCount(bean, item)` to determine how many indexed `Long` values are stored under the given item key.
2. **List initialization**: Creates a new `ArrayList<Long>` with the pre-allocated capacity equal to the count, avoiding unnecessary resizing.
3. **Indexed iteration**: Loops from index `0` to `count - 1`, calling `getLongAt(bean, item, i)` on each iteration to fetch the `Long` value at position `i`.
4. **Collection accumulation**: Each fetched `Long` element is appended to the result list via `result.add(element)`.
5. **Array conversion**: Converts the populated `ArrayList` into a `Long[]` array using `toArray(new Long[0])`.
6. **Return**: Returns the final `Long[]` array to the caller.

If `count` is `0`, the loop is skipped entirely and the method returns an empty `Long[]` array.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `bean` | `X31SDataBeanAccess` | The DataBean access object that holds business data transferred between the presentation layer and business logic. It acts as a keyed data container where fields are stored by string identifiers and optional indices (for repeated/structured data). |
| 2 | `item` | `String` | The key (field identifier) under which an array of `Long` values is stored in the DataBean. This identifies a specific group of indexed values — for example, a list of service IDs, contract line item numbers, or other `Long`-typed entity identifiers collected for a single logical grouping. |

**External state accessed:**

| Name | Type | Business Description |
|------|------|---------------------|
| (None) | — | This method is static and does not access any instance fields, static fields, or external services. All state is derived from its parameters. |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

No entity or database operations are performed in this method. It is a pure in-memory data extraction utility with no SC/CBS invocations or database access.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `Mover.getArrayCount` | Mover | DataBean (in-memory) | Reads the element count of an indexed field from the DataBean |
| R | `Mover.getLongAt` | Mover | DataBean (in-memory) | Reads a single `Long` value at a given index from the DataBean |
| R | `JFUKyokaIpAdActionChkUtil.toArray` | — | — | Invoked transitively via `toArray()` on `ArrayList` (standard Java API) |

All operations are **Read** from the DataBean, which is an in-memory data structure (not a database). No Create, Update, or Delete operations occur.

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `toArray` [-], `getLongAt` [R], `getArrayCount` [R]

This method is called by `Mover.getBeanMapFromDataBean()`, which reconstructs structured Java objects (including arrays and nested maps) from a flat DataBean representation. The `getBeanMapFromDataBean` method is itself invoked at multiple points within the `KKW01021SFLogic` class — the primary logic controller for the Discount Service Contract Overview screen (KKW01021).

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0004 (KKW01021) | `KKW01021SFLogic.<method>` -> `Mover.getBeanMapFromDataBean` -> `Mover.getLongArray` | `getLongAt [R] DataBean`, `getArrayCount [R] DataBean` |

The terminal operations reachable from this method are purely DataBean reads — `getLongAt` and `getArrayCount` — which access in-memory data carried from the preceding screen or request. No CBS or SC layer is involved in the downstream call chain from this method.

## 6. Per-Branch Detail Blocks

**Block 1** — [ASSIGN] `int count = getArrayCount(bean, item)` (L1288)

> Retrieve the number of indexed elements stored in the DataBean under the given item key.

| # | Type | Code |
|---|------|------|
| 1 | SET | `count = getArrayCount(bean, item)` // Calls Mover's own helper to get the element count of the indexed field from the DataBean [-> DataBean.get count] |

**Block 2** — [ASSIGN] `ArrayList<Long> result = new ArrayList<Long>(count)` (L1289)

> Initialize a typed result list with pre-allocated capacity to avoid dynamic resizing during the loop.

| # | Type | Code |
|---|------|------|
| 1 | SET | `result = new ArrayList<Long>(count)` // Typed list of Long with capacity set to count [-> in-memory collection] |

**Block 3** — [FOR LOOP] `(int i = 0; i < count; i++)` (L1290)

> Iterate over each index from 0 to count-1, fetching the Long value at each position.

| # | Type | Code |
|---|------|------|
| 1 | SET | `i = 0` // Loop initializer |
| 2 | COND | `i < count` // Continue while i is less than the element count |
| 3 | SET | `i++` // Post-iteration increment |

**Block 3.1** — [FOR BODY] — indexed collection (L1291–L1293)

> Fetch the Long element at the current index and append it to the result list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `element = getLongAt(bean, item, i)` // Retrieves Long at position i from the DataBean [-> DataBean.get value at index] |
| 2 | EXEC | `result.add(element)` // Appends the fetched Long to the result list |

**Block 4** — [ASSIGN] `return (Long[]) result.toArray(new Long[0])` (L1295)

> Convert the collected list into a `Long[]` array and return it to the caller.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `(Long[]) result.toArray(new Long[0])` // Casts the result of toArray to Long[] type |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `X31SDataBeanAccess` | Class | The DataBean access object — a key-value data container used to pass structured business data between the presentation layer and business logic in the K-Opticom web framework. Fields can be stored with optional integer indices to support lists/arrays of values. |
| `getBeanMapFromDataBean` | Method | A `Mover` utility that reconstructs a `BeanMap` (structured object tree) from a flat DataBean, using field structure definitions to determine how to extract each value (including array fields via methods like `getLongArray`). |
| `getArrayCount` | Method | `Mover` utility that reads the number of indexed elements stored under a given item key in the DataBean. |
| `getLongAt` | Method | `Mover` utility that retrieves the `Long` value at a specified index from the DataBean. |
| `Long` | Type | Java wrapper for `long` primitive — used here to represent entity identifiers, numeric codes, or other `Long`-typed business data stored as indexed fields in the DataBean. |
| `BeanMap` | Class | A structured key-value map that mirrors a data bean's field hierarchy, used to organize extracted DataBean values into typed groups before further processing. |
| KKW01021 | Screen ID | Discount Service Contract Overview screen (割引サービス契約一覧照会) — a screen for viewing a consolidated list of discount service contracts. |
| KKW01021SF | Module | Service screen module for the Discount Service Contract Overview. |
| Mover | Class | Shared utility facade within the K-Opticom framework providing common data access, conversion, and routing methods reused across multiple screen modules. |
