---

# (DD11) Business Logic — PatternCExtractor.extractRevisions() [14 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.optage.parser.PatternCExtractor` |
| Layer | Utility |
| Module | `parser` (Package: `com.optage.parser`) |

## 1. Role

### PatternCExtractor.extractRevisions()

This method extracts revision history records from a free-form documentation text block by scanning for lines that match the repository’s revision-line convention. It is a parsing helper used to convert human-written change history text into structured `FileHeader.RevisionEntry` objects so the higher-level `extract()` method can assemble a complete `FileHeader` model.

Business-wise, the method focuses on revision metadata only: it does not interpret system name, module name, or purpose text, and it does not persist anything. Instead, it performs a lightweight routing and transformation role, repeatedly identifying each revision line, splitting it into author and description, and packaging the result into a normalized domain object.

The method implements a loop-based extraction pattern over a compiled regular expression. Every matching line is treated as one revision record, while non-matching content is ignored. In the broader system, this makes the class a shared text-to-structure utility for documentation ingestion or header parsing workflows.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START["extractRevisions(code)"]
    INIT["Create empty ArrayList for revision entries"]
    PATTERN["Bind matcher to REVISION_PATTERN against code"]
    LOOP{"matcher.find() returns true?"}
    EXTRACT["Read group(1) as author and group(2) as description"]
    CREATE["Create new FileHeader.RevisionEntry with blank system/module, author, null, description"]
    ADD["Add revision entry to revisions list"]
    RETURN["Return revisions list"]

    START --> INIT
    INIT --> PATTERN
    PATTERN --> LOOP
    LOOP -->|Yes| EXTRACT
    EXTRACT --> CREATE
    CREATE --> ADD
    ADD --> LOOP
    LOOP -->|No| RETURN
```

The method performs a single extraction path with one loop:
1. It initializes an empty list to accumulate parsed revisions.
2. It creates a matcher from the precompiled `REVISION_PATTERN` and the supplied `code` text.
3. It repeatedly advances through all revision matches using `matcher.find()`.
4. For each match, it reads the author from capture group 1 and the revision description from capture group 2.
5. It creates a new `FileHeader.RevisionEntry` with blank system/module fields, the parsed author, a `null` placeholder for the date-related field, and the parsed description.
6. It appends the entry to the result list and continues scanning until no more matches remain.
7. It returns the accumulated list.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `code` | `String` | Source documentation text or file content that may contain one or more revision-history lines. The method scans this input for revision records in the format defined by `REVISION_PATTERN`; non-matching text is ignored. |

Instance fields or external state read by the method:
- `REVISION_PATTERN` — compiled regular expression used to detect revision lines and capture author and description values.

## 4. CRUD Operations / Called Services

This method has no CRUD interaction and no external service calls. It only performs in-memory parsing, object creation, and list accumulation.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `new FileHeader.RevisionEntry(...)` | - | In-memory `FileHeader.RevisionEntry` | Creates a new revision entry object for each matched revision line. |

## 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: -

Trace who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Utility: `PatternCExtractor.extract()` | `PatternCExtractor.extract()` -> `PatternCExtractor.extractRevisions()` | `new FileHeader.RevisionEntry(...) [C] In-memory object` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(method entry)` (L39)

> Initializes the revision accumulator for all parsed revision lines.

| # | Type | Code |
|---|------|------|
| 1 | SET | `List<FileHeader.RevisionEntry> revisions = new ArrayList<>();` // create empty result list |

**Block 2** — [SET] `(prepare matcher)` (L40)

> Builds a regex matcher over the full input text so the method can iterate through every matching revision line.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Matcher matcher = REVISION_PATTERN.matcher(code);` // bind input text to the revision pattern |

**Block 3** — [WHILE] `(matcher.find() == true)` (L42)

> Repeats once for each revision line found in the input text.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `matcher.find()` // advance to next revision match |

**Block 3.1** — [SET] `(extract matched fields)` (L43-L44)

> Reads the captured author and revision description from the current regex match.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String author = matcher.group(1);` // capture author from group 1 |
| 2 | SET | `String description = matcher.group(2);` // capture description from group 2 |

**Block 3.2** — [CALL] `(create revision entry)` (L45-L47)

> Creates a structured revision record from the parsed line content.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `new FileHeader.RevisionEntry("", "", author, null, description);` // build a revision entry with blank system and module fields |

**Block 3.3** — [EXEC] `(append to result list)` (L45-L47)

> Adds the newly created revision entry to the accumulated output.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `revisions.add(...);` // append parsed revision entry |

**Block 4** — [RETURN] `(no more matches)` (L50)

> Returns the complete list of parsed revision records.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return revisions;` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `code` | Field/Parameter | Source text being parsed, typically a file’s documentation body or header content. |
| `REVISION_PATTERN` | Technical term | Precompiled regular expression that identifies revision-history lines and captures author and description fields. |
| `matcher` | Technical term | Regex matcher used to iterate through each revision line in the input text. |
| `group(1)` | Technical term | First capture group in the revision pattern, used here for the author name. |
| `group(2)` | Technical term | Second capture group in the revision pattern, used here for the revision description. |
| `FileHeader` | Domain object | Structured header model that stores parsed metadata for a file. |
| `FileHeader.RevisionEntry` | Domain object | One revision-history record containing author and description-related fields. |
| revision history | Business term | Chronological record of changes documented in a file header. |
| parser | Technical term | Package area responsible for converting raw text into structured model objects. |
| utility | Layer | Reusable helper logic that performs parsing without owning business transactions or persistence. |
| regular expression | Technical term | Pattern-matching mechanism used to detect and extract revision lines from text. |