---

# (DD07) Business Logic — Example.syncGet() [12 LOC]

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

## 1. Role

### Example.syncGet()

This method performs a synchronous HTTP GET request against a caller-supplied URI, then writes the resulting HTTP status code and response body to the console. In business terms, it acts as a minimal HTTP client execution path for validating remote endpoints, retrieving payloads, and exposing the response outcome immediately to the operator or calling process. The method is not a data transformation service; it is a direct integration utility that bridges application code with an external HTTP service.

The method uses a straightforward request/response routing pattern: it builds an `HttpClient`, constructs an `HttpRequest` from the input URI, sends the request synchronously, and then prints the returned status and body. There are no conditional business branches, no retries, and no local persistence concerns. Its role in the larger system is to serve as a reusable example entry point for HTTP GET access, likely supporting manual verification or demonstration of Java 11 HTTP client behavior.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["syncGet(uri)"])
    CREATE_CLIENT["Create HttpClient with HttpClient.newHttpClient()"]
    BUILD_REQUEST["Build HttpRequest"]
    URI_NODE["URI.create(uri)"]
    SEND_REQUEST["Send request with client.send(request, BodyHandlers.ofString())"]
    PRINT_STATUS["Print response.statusCode()"]
    PRINT_BODY["Print response.body()"]
    END_NODE(["Method exits"])

    START --> CREATE_CLIENT
    CREATE_CLIENT --> BUILD_REQUEST
    BUILD_REQUEST --> URI_NODE
    URI_NODE --> SEND_REQUEST
    SEND_REQUEST --> PRINT_STATUS
    PRINT_STATUS --> PRINT_BODY
    PRINT_BODY --> END_NODE
```

**Constant resolution:** This method does not reference any application constants, constant classes, or branch-specific codes.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `uri` | `String` | Target endpoint address for the outbound HTTP GET operation. It defines which external resource will be requested and directly controls the remote service being contacted. The value is expected to be a valid URI string; invalid input causes URI construction to fail before the request is sent. |

**Instance fields / external state read:** None. The method only uses its input parameter and locally created HTTP objects.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|-----------------------|
| R | `HttpClient.send(...)` | N/A | External HTTP endpoint | Executes a synchronous read-style HTTP GET to retrieve remote content and response metadata. |
| R | `URI.create(...)` | N/A | URI target | Parses the supplied endpoint string into a request target used for outbound access. |
| R | `HttpResponse.BodyHandlers.ofString()` | N/A | Response body | Configures response extraction as a string payload for readback and console output. |

This method does not perform CRUD against an internal database or business entity. The only operational effect is an external read from the target URI and console output of the response.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `Example` (self-reference in comments) | `Example.main` comment reference -> `Example.syncGet` | `HttpClient.send(...) [R] External HTTP endpoint` |

No Java caller classes were found by repository search for `syncGet(` outside of `Example.java`. The available evidence indicates this method is intended for direct invocation from the example class rather than being widely reused by other application layers.

## 6. Per-Branch Detail Blocks

**Block 1** — `SEQUENCE` `(straight-line execution)` (L29-L40)

> Synchronous HTTP GET execution with immediate console reporting of the response.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HttpClient client = HttpClient.newHttpClient();` // create a default HTTP client |
| 2 | SET | `HttpRequest request = HttpRequest.newBuilder()` // begin request construction |
| 3 | EXEC | `.uri(URI.create(uri))` // convert input string into a URI target |
| 4 | EXEC | `.build();` // finalize the HTTP request |
| 5 | SET | `HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());` // send request and capture string response |
| 6 | EXEC | `System.out.println(response.statusCode());` // output HTTP status code |
| 7 | EXEC | `System.out.println(response.body());` // output HTTP response body |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `uri` | Field | Target resource address for the outbound HTTP GET request. |
| `HttpClient` | Technical term | Java HTTP client used to initiate outbound network requests. |
| `HttpRequest` | Technical term | Immutable request object that defines the outbound call details. |
| `HttpResponse` | Technical term | Container for the HTTP status and payload returned by the remote server. |
| `BodyHandlers.ofString()` | Technical term | Response handler that converts the response body into a text string. |
| GET | HTTP verb | Read-oriented request used to fetch data from a remote endpoint. |
| synchronous | Technical term | Execution mode where the caller waits until the remote request completes. |
| `statusCode` | Technical term | Numeric HTTP result indicating the outcome of the request. |
| `body` | Technical term | Response payload content returned by the remote endpoint. |
| `java.net.URI` | Technical term | Standard URI representation used to validate and hold endpoint addresses. |
| console output | Technical term | Standard output stream used to display the response for observation or debugging. |
| `io.github.biezhi.java11.http` | Package | HTTP example module containing Java 11 client demonstrations. |
