public static <K1, V1> Pair<K1, V1> of(K1 first, V1 second) { return new Pair<K1, V1>(first, second); }
static public boolean isCompatibleRendererType(final MutableDataHolder options, final String rendererType, final String supportedRendererType) { if (rendererType.equals(supportedRendererType)) { return true; } final List<Pair<String, String>> equivalence = RENDERER_TYPE_EQUIVALENCE.getFrom(options); for (Pair<String, String> pair : equivalence) { if (rendererType.equals(pair.getFirst())) { if (supportedRendererType.equals(pair.getSecond())) { return true; } } } return false; }
return Pair.of(headings, headingContents);
if (message == null) { Pair<T, List<ParsedOption<T>>> pair = matched.parseOption(optionValue, result, provider); result = pair.getFirst(); parsedOptions.add(new ParsedOption<T>(optionText, this, ParsedOptionStatus.VALID, null, pair.getSecond())); } else { parsedOptions.add(new ParsedOption<T>(optionText, this, ParsedOptionStatus.ERROR, new ParserMessage(optionName, ParsedOptionStatus.ERROR, message.toString()))); return new Pair<T, List<ParsedOption<T>>>(result, parsedOptions);
private void render(TocBlock node, NodeRendererContext context, HtmlWriter html) { HeadingCollectingVisitor visitor = new HeadingCollectingVisitor(); List<Heading> headings = visitor.collectAndGetHeadings(node.getDocument()); if (headings != null) { TocOptionsParser optionsParser = new TocOptionsParser(); TocOptions titleOptions = haveTitle ? this.options : this.options.withTitle(""); TocOptions options = optionsParser.parseOption(node.getStyle(), titleOptions, null).getFirst(); renderTocHeaders(context, html, node, headings, options); } }
SimTocOptionsParser optionsParser = new SimTocOptionsParser(); Pair<TocOptions, List<ParsedOption<TocOptions>>> pair = optionsParser.parseOption(block.getStyle(), TocOptions.DEFAULT, null); List<ParsedOption<TocOptions>> options = pair.getSecond(); if (!options.isEmpty()) {
if (message == null) { Pair<T, List<ParsedOption<T>>> pair = matched.parseOption(optionValue, result, provider); result = pair.getFirst(); parsedOptions.add(new ParsedOption<T>(optionText, this, ParsedOptionStatus.VALID, null, pair.getSecond())); } else { parsedOptions.add(new ParsedOption<T>(optionText, this, ParsedOptionStatus.ERROR, new ParserMessage(optionName, ParsedOptionStatus.ERROR, message.toString()))); return new Pair<T, List<ParsedOption<T>>>(result, parsedOptions);
private void render(SimTocBlock node, NodeRendererContext context, HtmlWriter html) { HeadingCollectingVisitor visitor = new HeadingCollectingVisitor(); List<Heading> headings = visitor.collectAndGetHeadings(node.getDocument()); if (headings != null) { SimTocOptionsParser optionsParser = new SimTocOptionsParser(); TocOptions options = optionsParser.parseOption(node.getStyle(), this.options, null).getFirst(); if (node.getTitle().isNotNull()) { options = options.withTitle(node.getTitle().unescape()); } renderTocHeaders(context, html, node, headings, options); } }
SimTocOptionsParser optionsParser = new SimTocOptionsParser(); Pair<TocOptions, List<ParsedOption<TocOptions>>> pair = optionsParser.parseOption(block.getStyle(), TocOptions.DEFAULT, null); List<ParsedOption<TocOptions>> options = pair.getSecond(); if (!options.isEmpty()) {
private void render(TocBlock node, NodeRendererContext context, HtmlWriter html) { HeadingCollectingVisitor visitor = new HeadingCollectingVisitor(); List<Heading> headings = visitor.collectAndGetHeadings(node.getDocument()); if (headings != null) { TocOptionsParser optionsParser = new TocOptionsParser(); TocOptions titleOptions = haveTitle ? this.options : this.options.withTitle(""); TocOptions options = optionsParser.parseOption(node.getStyle(), titleOptions, null).getFirst(); renderTocHeaders(context, html, node, headings, options); } }
return Pair.of(headings, headingContents);
static public MutableDataHolder addRenderTypeEquivalence(final MutableDataHolder options, final String rendererType, final String supportedRendererType) { if (!isCompatibleRendererType(options, rendererType, supportedRendererType)) { // need to add final List<Pair<String, String>> equivalence = RENDERER_TYPE_EQUIVALENCE.getFrom(options); final ArrayList<Pair<String, String>> newEquivalence = new ArrayList<>(equivalence); newEquivalence.add(new Pair<String, String>(rendererType, supportedRendererType)); options.set(RENDERER_TYPE_EQUIVALENCE, newEquivalence); } return options; }
static public boolean isCompatibleRendererType(final MutableDataHolder options, final String rendererType, final String supportedRendererType) { if (rendererType.equals(supportedRendererType)) { return true; } final List<Pair<String, String>> equivalence = RENDERER_TYPE_EQUIVALENCE.getFrom(options); for (Pair<String, String> pair : equivalence) { if (rendererType.equals(pair.getFirst())) { if (supportedRendererType.equals(pair.getSecond())) { return true; } } } return false; }
private void render(SimTocBlock node, NodeRendererContext context, HtmlWriter html) { HeadingCollectingVisitor visitor = new HeadingCollectingVisitor(); List<Heading> headings = visitor.collectAndGetHeadings(node.getDocument()); if (headings != null) { SimTocOptionsParser optionsParser = new SimTocOptionsParser(); TocOptions options = optionsParser.parseOption(node.getStyle(), this.options, null).getFirst(); if (node.getTitle().isNotNull()) { options = options.withTitle(node.getTitle().unescape()); } renderTocHeaders(context, html, node, headings, options); } }
@Override public Pair<Integer, Integer> getLineColumnAtIndex(final int index) { int iMax = length(); if (index < 0 || index > iMax) { throw new IllegalArgumentException("Index: " + index + " out of range [0, " + iMax + "]"); } boolean hadCr = false; boolean hadEOL = true; int line = 0; int col = 0; for (int i = 0; i < index; i++) { char c1 = charAt(i); if (c1 == '\r') { col = 0; line++; hadCr = true; } else if (c1 == '\n') { if (!hadCr) { line++; } col = 0; hadCr = false; } else { col++; } } return new Pair<>(line, col); }
private Object removingValue(int index, V v) { assert !myInKeyUpdate; myInKeyUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.removing(index, new Pair<K, V>((K)null, v)); } Object r = myKeySet.removeIndexHosted(index); myInKeyUpdate = false; return r; }
private Object removingKey(int index, K k) { assert !myInValueUpdate; myInValueUpdate = true; if (myHost != null && !myHost.skipHostUpdate()) { myHost.removing(index, new Pair<K, V>(k, null)); } Object r = myValueSet.removeIndexHosted(index); myInValueUpdate = false; return r; }
@SuppressWarnings("unchecked") @Override public Pair<T, List<ParsedOption<T>>> parseOption(BasedSequence optionText, T options, MessageProvider provider) { if (optionText.isEmpty()) { return new Pair<T, List<ParsedOption<T>>>(setOptions(options), (List<ParsedOption<T>>)Collections.<ParsedOption<T>>singletonList(new ParsedOption(optionText, this, ParsedOptionStatus.VALID))); } else { if (provider == null) provider = MessageProvider.DEFAULT; String message = provider.message(KEY_OPTION_0_PARAMETERS_1_IGNORED, OPTION_0_PARAMETERS_1_IGNORED, myOptionName, optionText); return new Pair<T, List<ParsedOption<T>>>(setOptions(options), (List<ParsedOption<T>>)Collections.<ParsedOption<T>>singletonList(new ParsedOption(optionText, this, ParsedOptionStatus.IGNORED, Collections.singletonList(new ParserMessage(optionText, ParsedOptionStatus.IGNORED, message))))); } }