@Override public Block createBlock(StructuralNode parent, String context, List<String> content, Map<String, Object> attributes) { return createBlock(parent, context, content, attributes, new HashMap<>()); }
@Override public PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text, Map<String, Object> attributes) { return createPhraseNode(parent, context, text, attributes, new HashMap<>()); }
@Override public Section createSection(StructuralNode parent, Map<Object, Object> options) { return createSection(parent, null, true, options); }
@Override public Cell createTableCell(Column column, Document innerDocument) { return createTableCell(column, innerDocument, new HashMap<>()); }
@Override public Block createBlock(StructuralNode parent, String context, Map<Object, Object> options) { Ruby rubyRuntime = JRubyRuntimeContext.get(parent); RubyHash convertMapToRubyHashWithSymbols = RubyHashUtil.convertMapToRubyHashWithSymbolsIfNecessary(rubyRuntime, filterBlockOptions(parent, options, "subs", ContentModel.KEY)); IRubyObject[] parameters = { ((StructuralNodeImpl) parent).getRubyObject(), RubyUtils.toSymbol(rubyRuntime, context), convertMapToRubyHashWithSymbols}; return (Block) NodeConverter.createASTNode(rubyRuntime, BLOCK_CLASS, parameters); }
@Override public Table createTable(StructuralNode parent) { return createTable(parent, new HashMap<>()); }
@Override public Column createTableColumn(Table parent, int index) { return createTableColumn(parent, index, new HashMap<>()); }
private Map<Object, Object> filterBlockOptions( StructuralNode parent, Map<Object, Object> options, String... optionNames) { final Map<Object, Object> copy = new HashMap<>(options); final Ruby ruby = JRubyRuntimeContext.get(parent); for (String optionName : optionNames) { final Object optionValue = copy.get(optionName); if (optionValue != null) { if (optionValue instanceof String) { copy.put(optionName, getRubySymbol(ruby, (String) optionValue)); } else if (optionValue instanceof List) { List valueList = (List) optionValue; List newValueList = new ArrayList(valueList.size()); for (Object v : valueList) { if (v instanceof String) { newValueList.add(getRubySymbol(ruby, (String) v)); } else { newValueList.add(v); } } copy.put(optionName, newValueList); } } } return copy; }
T instantiateProcessor(Object... args) throws IllegalAccessException, InvocationTargetException, InstantiationException { Constructor<T> constructor = findConstructorWithMostMatchingArguments(args); T processor = constructor.newInstance(Arrays.copyOf(args, constructor.getParameterTypes().length)); processor.unwrap(JRubyProcessor.class).setAsciidoctor(this.asciidoctor); return processor; }
@Override public Processor createProcessorDelegate() { return new JRubyProcessor(); }
@Override public Cell createTableCell(Column column, Document innerDocument) { return createTableCell(column, innerDocument, new HashMap<>()); }
@Override public Block createBlock(StructuralNode parent, String context, Map<Object, Object> options) { Ruby rubyRuntime = JRubyRuntimeContext.get(parent); RubyHash convertMapToRubyHashWithSymbols = RubyHashUtil.convertMapToRubyHashWithSymbolsIfNecessary(rubyRuntime, filterBlockOptions(parent, options, "subs", ContentModel.KEY)); IRubyObject[] parameters = { ((StructuralNodeImpl) parent).getRubyObject(), RubyUtils.toSymbol(rubyRuntime, context), convertMapToRubyHashWithSymbols}; return (Block) NodeConverter.createASTNode(rubyRuntime, BLOCK_CLASS, parameters); }
@Override public Table createTable(StructuralNode parent) { return createTable(parent, new HashMap<>()); }
@Override public Column createTableColumn(Table parent, int index) { return createTableColumn(parent, index, new HashMap<>()); }
private Map<Object, Object> filterBlockOptions( StructuralNode parent, Map<Object, Object> options, String... optionNames) { final Map<Object, Object> copy = new HashMap<>(options); final Ruby ruby = JRubyRuntimeContext.get(parent); for (String optionName : optionNames) { final Object optionValue = copy.get(optionName); if (optionValue != null) { if (optionValue instanceof String) { copy.put(optionName, getRubySymbol(ruby, (String) optionValue)); } else if (optionValue instanceof List) { List valueList = (List) optionValue; List newValueList = new ArrayList(valueList.size()); for (Object v : valueList) { if (v instanceof String) { newValueList.add(getRubySymbol(ruby, (String) v)); } else { newValueList.add(v); } } copy.put(optionName, newValueList); } } } return copy; }
public AbstractProcessorProxy(JRubyAsciidoctor asciidoctor, RubyClass metaClass, T processor) { super(asciidoctor.getRubyRuntime(), metaClass); this.asciidoctor = asciidoctor; processor.unwrap(JRubyProcessor.class).setAsciidoctor(asciidoctor); this.processor = processor; this.processorDelegate = processor.unwrap(JRubyProcessor.class); }
@Override public Block createBlock(StructuralNode parent, String context, String content, Map<String, Object> attributes) { return createBlock(parent, context, content, attributes, new HashMap<>()); }
@Override public Section createSection(StructuralNode parent, boolean numbered, Map<Object, Object> options) { return createSection(parent, null, numbered, options); }
@Override public PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text) { return createPhraseNode(parent, context, text, new HashMap<>()); }
@Override public Cell createTableCell(Column column, String text) { return createTableCell(column, text, new HashMap<>()); }