Package net.sourceforge.plantuml.style
Class StyleIndex
java.lang.Object
net.sourceforge.plantuml.style.StyleIndex
The fast, queryable counterpart of the old
StyleStorage: every loaded Style
is indexed by its query's tags in a
StyleAtomTrie, so findMatching(StyleQuery) only ever visits
declarations that could possibly match a query, instead of the old linear scan over every
style ever loaded checking StyleSignatureBasic#matchAll one by one -- the actual fix
for the slow style resolution (StyleBuilder.getMergedStyle(net.sourceforge.plantuml.style.StyleQuery),
StyleBuilder.getMergedStyleSpecial(net.sourceforge.plantuml.style.StyleQuery, int)) this whole parser2 engine was built for.
The subset-query trie itself already replicates matchAll's semantics exactly (level,
star, SName set and stereotype set all included) -- see
net.sourceforge.plantuml.style.parser2.LevelConstraint and
net.sourceforge.plantuml.style.parser2.StyleAtom.
Immutable: withLoaded(Style) and withMuted(Collection) both return a new
index, leaving this one exactly as queryable as before, so that a StyleBuilder cached
and reused across diagrams (see StyleLoader#loadSkin) never has a later diagram's own
<style> override leak back into the shared, cached instance it was cloned from.-
Method Summary
Modifier and TypeMethodDescriptionstatic StyleIndexempty()findMatching(StyleQuery query) Every loaded style whose query is a subset ofquery's, in the order they were loaded or muted in.Every style ever loaded or muted into this index, in that same order.withLoaded(Style newStyle) The counterpart of the oldStyleBuilder#loadInternal'sstorage.get(signature)/storage.put(...)pair, called while loading a .skin file: a light-only "root { FontColor black }" and a later, dark-only "@media (dark) { root { FontColor white } }" share the exact sameStyleQueryand MUST be folded into oneStyleright here, at load time -- not left forfindMatching(net.sourceforge.plantuml.style.StyleQuery)to hand back as two separate entries.withMuted(Collection<Style> newStyles) The counterpart of the oldStyleBuilder#muteStyle: folds every style innewStylesinto a brand new index, this one left untouched -- merging each one, in turn, with whatever already shares its exact signature (either already in this index, or earlier innewStylesitself), for the same reasonwithLoaded(net.sourceforge.plantuml.style.Style)does.
-
Method Details
-
empty
-
withLoaded
The counterpart of the oldStyleBuilder#loadInternal'sstorage.get(signature)/storage.put(...)pair, called while loading a .skin file: a light-only "root { FontColor black }" and a later, dark-only "@media (dark) { root { FontColor white } }" share the exact sameStyleQueryand MUST be folded into oneStyleright here, at load time -- not left forfindMatching(net.sourceforge.plantuml.style.StyleQuery)to hand back as two separate entries. Deferring that fold to query time is unsound: a cross-selector cascade merge (say, "root" combined with a more specific "root document ganttDiagram") uses priority alone to decide the winner once both sides already carry a value (DarkString.mergeWith(net.sourceforge.plantuml.style.value.DarkString)'s final, non-combining branch), so a still-unmerged dark-only "root" entry -- whose priority is always high, since every dark declaration in a .skin file is numbered after every light one -- can beat an already-combined light+dark value from a less specific selector and silently drop that combined value's light half. Pre-merging same-signature entries here, exactly as the old code did, keeps every entry this index ever hands out fully self-consistent (both halves set whenever either declaration set either), so that later cascade folding only ever has to pick a winner between two complete values. -
withMuted
The counterpart of the oldStyleBuilder#muteStyle: folds every style innewStylesinto a brand new index, this one left untouched -- merging each one, in turn, with whatever already shares its exact signature (either already in this index, or earlier innewStylesitself), for the same reasonwithLoaded(net.sourceforge.plantuml.style.Style)does. -
findMatching
Every loaded style whose query is a subset ofquery's, in the order they were loaded or muted in. -
getAllStyles
Every style ever loaded or muted into this index, in that same order.
-