public final class Pp2FormatResult extends Object
Pp2Formatter.format(...) call.
Carries the formatted SQL text, the overall outcome
(FormatStatus), the per-region rendering record
(Pp2FormatResult.Region), and the diagnostic events the engine emitted along the
way (FormatDiagnostic).
Built only by pp2 internals. Callers consume the immutable accessors:
getText(), getStatus(), getRegions(),
getDiagnostics(). The two list accessors return unmodifiable
views.
getRegions() is how you tell what actually formatted your SQL.
A region tagged RendererId.GUARDED_AST holds
FormatterFactory.pp's own output, unchanged — on input that parses
as a whole, every region is that and getText() is byte-identical to
pp(). Any other RendererId marks a byte range pp could not
format, which pp2 rendered from the token stream instead.
| Modifier and Type | Class and Description |
|---|---|
static class |
Pp2FormatResult.Region
Per-region rendering record.
|
| Constructor and Description |
|---|
Pp2FormatResult(String text,
FormatStatus status,
List<Pp2FormatResult.Region> regions,
List<FormatDiagnostic> diagnostics) |
Pp2FormatResult(String text,
FormatStatus status,
List<Pp2FormatResult.Region> regions,
List<FormatDiagnostic> diagnostics,
boolean wholeDocument,
boolean nameCaseApplied) |
| Modifier and Type | Method and Description |
|---|---|
List<FormatDiagnostic> |
getDiagnostics()
Unmodifiable view; never
null, may be empty. |
List<Pp2FormatResult.Region> |
getRegions()
Unmodifiable view; never
null, may be empty. |
FormatStatus |
getStatus() |
String |
getText() |
boolean |
isNameCaseApplied()
True when the per-kind name cases (
GFmtOpt.caseTableName,
caseColumnName, caseTableAlias, caseColumnAlias)
applied: the whole document was formatted by pp, its names were
resolved, and they could be cased consistently. |
boolean |
isWholeDocument()
True when the whole input parsed and
getText() is
FormatterFactory.pp's output for it. |
String |
toString() |
public Pp2FormatResult(String text, FormatStatus status, List<Pp2FormatResult.Region> regions, List<FormatDiagnostic> diagnostics)
public Pp2FormatResult(String text, FormatStatus status, List<Pp2FormatResult.Region> regions, List<FormatDiagnostic> diagnostics, boolean wholeDocument, boolean nameCaseApplied)
wholeDocument - true when text is FormatterFactory.pp's
output for the whole input; see isWholeDocument()nameCaseApplied - see isNameCaseApplied()public FormatStatus getStatus()
public List<Pp2FormatResult.Region> getRegions()
null, may be empty.public List<FormatDiagnostic> getDiagnostics()
null, may be empty.public boolean isWholeDocument()
getText() is
FormatterFactory.pp's output for it. An all-RendererId.GUARDED_AST
regional run looks the same in getRegions(), so this is the
way to tell.public boolean isNameCaseApplied()
GFmtOpt.caseTableName,
caseColumnName, caseTableAlias, caseColumnAlias)
applied: the whole document was formatted by pp, its names were
resolved, and they could be cased consistently. The regional pipeline
parses without name resolution, so a regional result never applies them.