---

# (DD14) 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()

`writeHeader()` is a small presentation utility that formats a text value as a console-style section header for the Java 11 String examples. The method calculates a repeated `=` border using the supplied title length, then prints a blank line, the title text, and the matching border to standard output. In business terms, it provides a consistent visual separator so each demonstration method can render its topic in a readable, human-friendly way before showing example output.

The method implements a simple formatting-and-dispatch pattern: it derives a display frame from the input text and emits it immediately, without storing state or returning a value. Its role in the larger module is shared output scaffolding for the string feature demonstrations; every public example method in this class invokes it to label the scenario being shown. There are no branches, loops, or external service interactions, so the logic is entirely deterministic and side-effect driven through console output.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START["writeHeader(headerText)"]
    LEN["Build headerSeparator = '='.repeat(headerText.length() + 4)"]
    OUT1["Print newline plus headerSeparator"]
    OUT2["Print headerText"]
    OUT3["Print headerSeparator"]
    END_NODE["Return"]
    START --> LEN
    LEN --> OUT1
    OUT1 --> OUT2
    OUT2 --> OUT3
    OUT3 --> END_NODE
```

**CRITICAL — Constant Resolution:**
This method does not reference any project constants, constant classes, or conditional constant branches. The only literal value used is the repeated border character `=`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `headerText` | `final String` | Display title for the example section. It defines the text printed between the two separator lines and also controls the separator width because its character length determines how many `=` symbols are generated. Any non-null string can be passed, and longer titles produce wider headers. |

Instance fields or external state read by this method: none. The method depends only on the `headerText` argument and writes directly to standard output.

## 4. CRUD Operations / Called Services

This method does not perform CRUD operations against a database, file store, or remote service. It only calls JDK string and console APIs.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `headerText.length()` | N/A | N/A | Reads the title length to determine the display width of the header border. |
| R | `"=".repeat(...)` | N/A | N/A | Creates the repeated separator string used for presentation formatting. |
| C | `System.out.println(...)` | N/A | Console output | Writes the blank line, title, and separator to the console as display 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: -

`writeHeader()` is a local formatting helper inside `Example.java`. All observed callers are other methods in the same class; there are no external screen, batch, controller, or CBS entry points in the available source set. The method itself terminates in console output only and does not delegate to any downstream business service.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Utility: `Example.demonstrateStringLines()` | `Example.demonstrateStringLines()` -> `Example.writeHeader()` | `System.out.println [C] Console output` |
| 2 | Utility: `Example.demonstrateStringStrip()` | `Example.demonstrateStringStrip()` -> `Example.writeHeader()` | `System.out.println [C] Console output` |
| 3 | Utility: `Example.demonstrateStringStripLeading()` | `Example.demonstrateStringStripLeading()` -> `Example.writeHeader()` | `System.out.println [C] Console output` |
| 4 | Utility: `Example.demonstrateStringStripTrailing()` | `Example.demonstrateStringStripTrailing()` -> `Example.writeHeader()` | `System.out.println [C] Console output` |
| 5 | Utility: `Example.demonstrateStringIsBlank()` | `Example.demonstrateStringIsBlank()` -> `Example.writeHeader()` | `System.out.println [C] Console output` |
| 6 | Utility: `Example.lines()` | `Example.lines()` -> `Example.writeHeader()` | `System.out.println [C] Console output` |
| 7 | Utility: `Example.main(String[])` | `Example.main(String[])` -> `Example.lines()` -> `Example.writeHeader()` | `System.out.println [C] Console output` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SEQUENCE] `(no branching)` (L24-L30)

> Formats a header and prints it in three lines for consistent console presentation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `final String headerSeparator = "=".repeat(headerText.length() + 4);` // Build the visual border around the title |
| 2 | EXEC | `System.out.println("
" + headerSeparator);` // Print a leading blank line and the top border |
| 3 | EXEC | `System.out.println(headerText);` // Print the section title |
| 4 | EXEC | `System.out.println(headerSeparator);` // Print the bottom border |
| 5 | RETURN | `return;` // End of method |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `headerText` | Field | Console section title supplied by a demonstration method. |
| `headerSeparator` | Field | Repeated `=` border used to visually frame the section title. |
| `String.repeat(int)` | Java API | JDK 11 string utility that repeats the current string a specified number of times. |
| `String.length()` | Java API | Returns the number of characters in the title text and drives the separator width. |
| `System.out.println` | Technical term | Standard console output used to render the header in the terminal. |
| `String.lines()` | Java API | JDK 11 line-splitting method demonstrated by the surrounding class, not by this method directly. |
| `String.strip()` | Java API | JDK 11 whitespace-trimming method demonstrated by the surrounding class, not by this method directly. |
| `String.stripLeading()` | Java API | JDK 11 leading-whitespace trimming method demonstrated by the surrounding class, not by this method directly. |
| `String.stripTrailing()` | Java API | JDK 11 trailing-whitespace trimming method demonstrated by the surrounding class, not by this method directly. |
| `String.isBlank()` | Java API | JDK 11 blank-text check method demonstrated by the surrounding class, not by this method directly. |
| `Console output` | Technical term | Text written to the terminal for human-readable demonstration output. |

---
