File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/main/java/org/idpf/epubcheck/util/css Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 3939import static org .idpf .epubcheck .util .css .CssToken .Matchers .MATCH_STAR_PIPE ;
4040import static org .idpf .epubcheck .util .css .CssTokenList .Filters .FILTER_NONE ;
4141
42+ import java .util .Arrays ;
4243import java .util .List ;
4344import java .util .Locale ;
4445import java .util .Map ;
46+ import java .util .stream .Collectors ;
4547
4648import org .idpf .epubcheck .util .css .CssExceptions .CssErrorCode ;
4749import org .idpf .epubcheck .util .css .CssExceptions .CssException ;
4850import org .idpf .epubcheck .util .css .CssExceptions .CssGrammarException ;
51+ import org .idpf .epubcheck .util .css .CssGrammar .CssComposedConstruct ;
52+ import org .idpf .epubcheck .util .css .CssGrammar .CssConstruct ;
4953import org .idpf .epubcheck .util .css .CssParser .ContextRestrictions ;
5054import org .idpf .epubcheck .util .css .CssTokenList .CssTokenIterator ;
5155
6670public class CssGrammar
6771{
6872
73+ /**
74+ * Utility methodd to flatten a nested construct in a list
75+ * of its atomic components
76+ */
77+ public static List <CssConstruct > flatten (CssConstruct construct )
78+ {
79+ if (construct instanceof CssComposedConstruct )
80+ {
81+ return ((CssComposedConstruct ) construct ).getComponents ().stream ()
82+ .flatMap (c -> flatten (c ).stream ()).collect (Collectors .toList ());
83+ }
84+ else
85+ {
86+ return Arrays .asList (construct );
87+ }
88+ }
89+
6990 /**
7091 * Abstract base for all CssConstructs.
7192 */
You can’t perform that action at this time.
0 commit comments