Class AbstractModelExporter
- All Implemented Interfaces:
JustificationVisitor<Void>
- Direct Known Subclasses:
DotExporter, JsonExporter, PythonExporter
JustificationModel to text. Provides the common infrastructure shared
by all single-model exporters:
- A
StringBuilderaccumulator (builder) and the associated reset-before-export pattern. - A
currentModelNamefield populated from the model under export. - A
qualify(String)helper that prefixes element ids with the current model name ("modelName:elementId"). visit(Unit)— rejectsUnitwithUnsupportedOperationException; single-model exporters requireSelectModelto extract a model first.visit(Justification)andvisit(Template)— both delegate toexportModel(JustificationModel).
Subclasses implement exportModel(JustificationModel) to perform the
actual serialisation, setting currentModelName as their first
action. Element visit methods (visit(Conclusion), etc.) are left
abstract so each exporter controls its own output format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringBuilderAccumulates the serialised output.protected StringName of the model currently being exported. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidexportModel(JustificationModel<?> model) Performs the actual serialisation ofmodel.protected final voidinitAliases(JustificationModel<?> model) Builds the inverted alias lookup and the link index formodel.protected final StringminimalLink(String qualifiedKey) ShortensqualifiedKeyto the shortest trailing run of colon-separated segments that still designates the same element, never going belowcontainer:id.qualifiedAliasesOf(String plainElementId) Returns the qualified original ids that were merged intoplainElementId, or an empty list when the element is not the target of any alias.qualifiedAuthoredOriginalsOf(String plainElementId) Returns the qualified idsplainElementIdwas merged from that an author actually wrote: the ids as they stood in the source models.qualifiedOriginalsOf(String plainElementId) Returns every qualified idplainElementIdwas merged from, following alias chains transitively.protected final StringQualifieselementIdwith the current model name:"currentModelName:elementId".final Voidvisit(Justification justification) Delegates toexportModel(JustificationModel).final VoidDelegates toexportModel(JustificationModel).final VoidRejectsUnit— single-model exporters require a specific model.
-
Field Details
-
builder
Accumulates the serialised output. Reset at the start of each export. -
currentModelName
Name of the model currently being exported. Set byexportModel(JustificationModel)before any element visit methods are called.
-
-
Constructor Details
-
AbstractModelExporter
public AbstractModelExporter()
-
-
Method Details
-
qualify
-
initAliases
Builds the inverted alias lookup and the link index formodel. Subclasses that surface aliases must call this at the start ofexportModel(JustificationModel), after settingcurrentModelName. -
qualifiedAliasesOf
Returns the qualified original ids that were merged intoplainElementId, or an empty list when the element is not the target of any alias. RequiresinitAliases(JustificationModel)to have been called first. -
qualifiedOriginalsOf
Returns every qualified idplainElementIdwas merged from, following alias chains transitively.A composition applied to the result of another composition records a chain (
a -> merged -> unified_0) rather than a flat mapping, so a one-hop lookup (qualifiedAliasesOf(String)) stops at the intermediate and loses the id the user actually wrote. The returned list holds both the intermediates and the leaves, nearest first. -
qualifiedAuthoredOriginalsOf
Returns the qualified idsplainElementIdwas merged from that an author actually wrote: the ids as they stood in the source models. Empty when the element is not a merge product.Two kinds of id are passed over. One that was merged from further ids is skipped in favour of those, which stand closer to the source. One that unification minted (
unified_0) is skipped outright: it names a merged group by a counter and appears in no source file. The latter is not always the former, since composing the result of a composition can leave a minted id recorded as a sibling of the ids it stood for rather than as their parent, so being childless does not make an id authored. -
minimalLink
ShortensqualifiedKeyto the shortest trailing run of colon-separated segments that still designates the same element, never going belowcontainer:id.Consumers resolve a link by exact match against the link index first, then by strict segment-suffix match; a suffix designating two different elements is ambiguous and is not a valid link. Candidates are therefore checked against the very index a consumer builds from the exported model, shortest first, and
qualifiedKeyitself is returned when no shorter form is unambiguous, because a full id always resolves exactly.The 2-segment floor is a readability requirement rather than a resolution one: a bare
idwould often resolve, but a reader of the exported artefact has no way to tell what it belongs to. Keeping the owning model or source justification in front of it, asa_claim:s1rather thans1, makes the reference legible on its own. Every key starts qualified with the model name, so the floor is always reachable. -
visit
-
visit
Delegates toexportModel(JustificationModel).- Specified by:
visitin interfaceJustificationVisitor<Void>
-
visit
Delegates toexportModel(JustificationModel).- Specified by:
visitin interfaceJustificationVisitor<Void>
-
exportModel
Performs the actual serialisation ofmodel. Implementations must setcurrentModelName= model.getName()before calling any element visit methods.
-