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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `io.github.biezhi.java11.string.Example` |
| Layer | Utility (Common Component / JDK 11 String API demonstration) |
| Module | `string` (Package: `io.github.biezhi.java11.string`) |

## 1. Role

### Example.writeHeader()

The `writeHeader()` method is a private static utility that formats and prints a visual text header to the standard output console. It serves as a formatting helper within a broader JDK 11 `String` API feature demonstration suite. The method takes a user-supplied string, computes a separator line made of equal signs whose width is dynamically determined by the input length plus four extra characters on each side, and prints the separator, the header text, and the separator again to form a boxed header pattern. This follows a common console-CLI convention where method demonstrations are visually delineated by header blocks for readability. It implements a simple **delegation pattern** — the core logic is delegated to `String.repeat(int)`, a JDK 11 method, to generate the separator line. The method is not a business operation per se, but a shared formatting utility called by multiple demonstration methods within the `Example` class to consistently bracket each API showcase with a visual separator. All callers pass a descriptive label string that identifies the JDK 11 feature being demonstrated.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START["writeHeader headerText"]
    STEP1["Compute headerSeparator using String.repeat"]
    STEP2["Print newline and headerSeparator"]
    STEP3["Print headerText"]
    STEP4["Print headerSeparator"]
    END_NODE["Return to caller"]

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

**Processing Steps:**

1. **Compute the separator**: The method calls `"=".repeat(headerText.length() + 4)` to produce a string of equal signs. The length is the header text length plus 4 (yielding 2 extra characters on each side of the text when printed between separators).
2. **Print opening separator**: Prints a newline followed by the separator to visually separate from prior output.
3. **Print the header text**: Prints the supplied `headerText` string.
4. **Print closing separator**: Prints the separator again to close the header block.

There are no conditional branches, loops, or error-handling paths. The method executes linearly from start to finish.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `headerText` | `final String` | A descriptive label identifying the JDK 11 `String` feature being demonstrated. Examples include `"String.lines()"`, `"String.strip() on 'originalString'"`, `"String.isBlank()"`. The content directly affects the visual formatting: it determines the width of the equal-sign separator (text length + 4) and is printed as the header body. |

**External state:**
- This method reads no instance fields and accesses no external services or data stores. It is a pure side-effect method that writes only to `System.out`.

## 4. CRUD Operations / Called Services

This method performs no CRUD operations, database access, or service calls. Its only external interaction is console output via `System.out.println`.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| (none) | `System.out.println(String)` | — | — | Standard output console print (visual formatting) |

## 5. Dependency Trace

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

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

All callers are internal demonstration methods within the same `Example` class. This method is a leaf in the call graph — it does not call any other application code.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Method: `Example.stripLinesBlock` | `Example.stripLinesBlock` -> `writeHeader` | — |
| 2 | Method: `Example.stripTests` | `Example.stripTests` -> `writeHeader` | — |
| 3 | Method: `Example.stripLeadingTests` | `Example.stripLeadingTests` -> `writeHeader` | — |
| 4 | Method: `Example.stripTrailingTests` | `Example.stripTrailingTests` -> `writeHeader` | — |
| 5 | Method: `Example.isBlankTests` | `Example.isBlankTests` -> `writeHeader` | — |
| 6 | Method: `Example.linesTests` | `Example.linesTests` -> `writeHeader` | — |

## 6. Per-Branch Detail Blocks

This method has no conditional branches, loops, or exception handlers. The entire method is a single linear block.

**Block 1** — [SEQUENTIAL] `(no conditions)` (L24–L30)

> Computes and prints a visual header separator block to the console. The header text is boxed between equal-sign separators.

| # | Type | Code |
|---|------|------|
| 1 | SET | `headerSeparator = "=".repeat(headerText.length() + 4)` — Creates a string of equal signs; length is `headerText.length() + 4` to provide 2 padding characters on each side when printed as a separator |
| 2 | EXEC | `System.out.println("
" + headerSeparator)` — Prints a newline followed by the top separator line |
| 3 | EXEC | `System.out.println(headerText)` — Prints the header text body |
| 4 | EXEC | `System.out.println(headerSeparator)` — Prints the bottom separator line |
| 5 | RETURN | `return;` (void method, implicit return at end) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `headerText` | Parameter | The descriptive label string passed to the method that identifies the JDK 11 String API feature being demonstrated |
| `headerSeparator` | Local variable | A dynamically-sized string of equal signs used as a visual divider in console output formatting |
| `String.repeat(int)` | JDK 11 API | A JDK 11 method on `String` that returns a string consisting of the repetitions of the original string |
| `System.out.println()` | Java I/O API | Standard output method that prints text followed by a newline to the console |
| JDK 11 | Technology | Java Development Kit version 11, which introduced new `String` API methods including `repeat()`, `lines()`, `strip()`, `stripLeading()`, `stripTrailing()`, and `isBlank()` |
