---

# (DD15) Business Logic — Example.writeHeader() [7 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `io.github.biezhi.java11.string.Example` |
| Layer | Utility |
| Module | `string` (Package: `io.github.biezhi.java11.string`) |

## 1. Role

### Example.writeHeader()

This method generates a visual console header for the examples in this class. It takes a title string, calculates a separator line whose length is four characters longer than the title, and prints the separator, the title, and the separator again with a leading blank line. In business terms, it is a presentation utility used to make each demonstration output easier to read and to visually separate one example section from another.

The method implements a simple formatting/delegation pattern built on the JDK `String.repeat(int)` API. It does not branch by service type or business category; instead, it standardizes console output for every example invocation regardless of the caller. Within the broader system, it acts as a shared helper for sample output formatting in the `Example` class and supports multiple example scenarios such as `String.lines()`, `strip()`, `stripLeading()`, `stripTrailing()`, `isBlank()`, and related demonstrations.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["writeHeader(headerText)"])
    STEP1["Calculate headerSeparator = \"=\".repeat(headerText.length() + 4)"]
    STEP2["Print blank line and separator with System.out.println()"]
    STEP3["Print headerText with System.out.println()"]
    STEP4["Print separator again with System.out.println()"]
    END_NODE(["Return to caller"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> END_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `headerText` | `final String` | The title text to display at the top of a console example block. Its length determines the separator width, so longer titles produce a wider banner and shorter titles produce a narrower one. |

Instance fields or external state read by this method: none. The method uses only the incoming parameter, a local variable, and standard output.

## 4. CRUD Operations / Called Services

This method does not invoke application CRUD services or database access methods. It only performs local string formatting and console output.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `System.out.println` | - | - | Writes formatted header text to the console as presentation output. |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 7 methods.
Terminal operations from this method: -

The method is called only from other methods in `Example` to print section banners before each string API demonstration. No external screen, batch, controller, or CBS entry point is identified in the available source snapshot.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Internal caller: `Example.main` context | `Example.main` -> `Example.writeHeader` | `System.out.println [RUNTIME OUTPUT]` |
| 2 | Internal caller: `Example` method at line 41 | `Example.<example method>` -> `Example.writeHeader` | `System.out.println [RUNTIME OUTPUT]` |
| 3 | Internal caller: `Example` method at line 52 | `Example.<example method>` -> `Example.writeHeader` | `System.out.println [RUNTIME OUTPUT]` |
| 4 | Internal caller: `Example` method at line 62 | `Example.<example method>` -> `Example.writeHeader` | `System.out.println [RUNTIME OUTPUT]` |
| 5 | Internal caller: `Example` method at line 72 | `Example.<example method>` -> `Example.writeHeader` | `System.out.println [RUNTIME OUTPUT]` |
| 6 | Internal caller: `Example` method at line 80 | `Example.<example method>` -> `Example.writeHeader` | `System.out.println [RUNTIME OUTPUT]` |
| 7 | Internal caller: `Example` method at line 97 | `Example.<example method>` -> `Example.writeHeader` | `System.out.println [RUNTIME OUTPUT]` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SEQUENCE] `(no conditional branches)` (L24-L29)

> This method executes a fixed formatting sequence with no branching, looping, or exception handling.

| # | Type | Code |
|---|------|------|
| 1 | SET | `final String headerSeparator = "=".repeat(headerText.length() + 4);` // Build a separator line four characters longer than the title |
| 2 | EXEC | `headerText.length();` // Measure the title length |
| 3 | EXEC | `"=".repeat(headerText.length() + 4);` // Expand the equals sign to match the banner width |
| 4 | EXEC | `System.out.println("
" + headerSeparator);` // Print a blank line and the top separator |
| 5 | EXEC | `System.out.println(headerText);` // Print the header title |
| 6 | EXEC | `System.out.println(headerSeparator);` // Print the bottom separator |
| 7 | RETURN | `return;` // End method execution |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `headerText` | Field | Console banner title displayed before an example section. |
| `headerSeparator` | Variable | Repeated equals-sign line used to frame the title visually. |
| `String.repeat(int)` | Technical API | JDK string utility that repeats a character sequence a specified number of times. |
| `System.out.println` | Technical API | Standard console output used to render the demonstration header. |
| `String.lines()` | Business term | String API example shown elsewhere in the `Example` class. |
| `strip()` | Business term | String trimming example shown elsewhere in the `Example` class. |
| `stripLeading()` | Business term | String leading-trim example shown elsewhere in the `Example` class. |
| `stripTrailing()` | Business term | String trailing-trim example shown elsewhere in the `Example` class. |
| `isBlank()` | Business term | String blank-check example shown elsewhere in the `Example` class. |
| `Example` | Class | Demonstration class for Java 11 string features and console output formatting. |
