# (DD26) Business Logic — JKKStringUtil.nullToSpace() [8 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.common.util.JKKStringUtil` |
| Layer | Utility (Common Component) |
| Module | `util` (Package: `eo.common.util`) |

## 1. Role

### JKKStringUtil.nullToSpace()

The `nullToSpace` method is a defensive string-handling utility used throughout the KoptCommon shared component library. Its sole business purpose is to **prevent null-pointer exceptions and missing-value display issues** by converting a `null` string reference into a blank space (`" "`). This is a common pattern in enterprise telecom systems where database columns or form fields may contain `NULL` values, and downstream display logic (UI rendering, CSV export, log writing) cannot gracefully handle a `null` reference — it requires a non-null string, even if that string is empty or a space.

This method implements a **guard clause / null-safe wrapper** design pattern: it acts as the first line of defense in data transformation pipelines, ensuring that any nullable string passed through the system is normalized to a non-null value before further processing. It is a shared utility method (`public static`) called from many screens, CBS (Common Business Service) classes, and batch processors across the application.

The method is typically used when preparing data for display or export — for example, converting a database `NULL` phone number into a space so that table columns do not collapse, or filling a mandatory string field in a data transfer object (DTO) before serialization. It is the simpler counterpart to `nullBlankToSpace`, which also handles empty strings (`""`) in addition to `null`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["nullToSpace(str)"])
    COND(["str == null"])
    RETURN_SPACE(["Return \" \""])
    RETURN_ORIG(["Return str"])

    START --> COND
    COND -->|Yes| RETURN_SPACE
    COND -->|No| RETURN_ORIG
```

**Processing Description:**

1. **Entry**: The method receives a `String str` parameter that may be `null` (from a database query, a form field, or a data object property).
2. **Null Check**: The method evaluates whether `str` is `null`.
   - If `str` **is `null`** → the method returns a single blank space `" "` to guarantee a non-null return value. This prevents `NullPointerException` in any downstream code that uses the result.
   - If `str` **is not `null`** (including when `str` is an empty string `""`) → the method returns `str` unchanged. No transformation is applied to non-null inputs.
3. **Return**: The method returns either `" "` or the original `str` as a `String`.

There are no constant lookups, no external method calls, no database access, and no conditional branches beyond the single null check.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `str` | `String` | A nullable string value representing business data (e.g., customer name, phone number, address field, service code). This value may originate from a database column that allows `NULL`, a form submission that omitted a field, or a data object that was not yet populated. When `null`, the method replaces it with a blank space `" "` to ensure safe downstream consumption. |

**No instance fields or external state** are read by this method. It is a pure, stateless function.

## 4. CRUD Operations / Called Services

This method performs **no CRUD operations**. It makes no calls to external services, data access components, or other business methods. It operates solely on the input parameter and returns a transformed value.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | — | — | — | No database or service calls. Pure in-memory string transformation. |

## 5. Dependency Trace

A search across the entire codebase (107 Java files) found **no callers** of `JKKStringUtil.nullToSpace()`. The method is defined but currently unused in the scanned codebase. It may be used by external projects, imported as part of a shared library (koptCommon JAR), or called from classes outside the scanned scope.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | *(No callers found in codebase)* | — | — |

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(str == null)` (L84)

> Null-guard branch: when the input string is `null`, return a blank space to ensure non-null return value.

| # | Type | Code |
|---|------|------|
| 1 | COND | `if (str == null)` [L84] |
| 2 | RETURN | `return " ";` [L86] |

**Block 2** — [ELSE-IMPLIED] `(str != null)` (L88)

> Default branch: when the input string is not `null` (including empty string `""`), return it unchanged.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return str;` [L88] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `nullToSpace` | Method | A utility method that converts a `null` string to a blank space (`" "`), preventing null-pointer exceptions in downstream processing |
| `JKKStringUtil` | Class | A shared Java utility class in the `eo.common.util` package providing common string manipulation helpers used across the KoptCommon library |
| `koptCommon` | Module | The shared common component library containing utilities, constants, and base classes reused across all screens and batches in the system |
| `null` | Data concept | A database or object-level null value indicating the absence of data; often arises from optional database columns or unpopulated DTO fields |
| `" "` | Constant | A single blank space character — the sentinel value used by this method as a safe non-null replacement for `null` strings |
| `nullBlankToSpace` | Method | A related utility method in the same class that also converts empty strings (`""`) to spaces, in addition to `null` |
| SC | Acronym | Service Component — a layer in the architecture that handles business logic and service-level operations |
| CBS | Acronym | Common Business Service — a shared service class that provides business functionality reused across multiple screens or processes |
