/**
  * Simply concatenate the serialized form of each StructuredElement contained in the given
  * container.
  *
  * @param container Container to serialize.
  * @param dispatcher Dispatcher used to call the correct serialization for each structured element
  * @return the serialized form of this container
  */
 public static String render(Container container, WikiTextElementDispatcher dispatcher) {
   String renderedContent = "";
   for (StructureElement wikiElement : container.getContent()) {
     renderedContent += dispatcher.doSwitch(wikiElement) + "\n";
   }
   return renderedContent;
 }
  /**
   * Simply concatenate the bloc prefix to the serialized form of each BlockContent contained in the
   * given bloc.
   *
   * @param wikiElement Block to serialize.
   * @param dispatcher Dispatcher used to call the correct serialization for each content
   * @param blockPrefix prefix of the bloc (example : '*' for a bulleted list)
   * @return serialized form of this block.
   */
  public static String renderWithBlocPrefix(
      Block wikiElement, WikiTextElementDispatcher dispatcher, String blockPrefix) {

    // Step 1 : We first render the Block's prefix and style
    String renderedContent = renderPrefixAndStyle(wikiElement, blockPrefix);

    // Step 2 : We update the lastBlocWasPreformatted field
    if (prefixMatchesWithPreformattedBloc(blockPrefix)) {
      renderedContent = WikiTextResourceSerializer.LINE_BREAK + renderedContent;
      lastBlocWasPreformatted = true;
    } else {
      lastBlocWasPreformatted = false;
      if (prefixMatchesWithQuote(blockPrefix)) {
        renderedContent = WikiTextResourceSerializer.LINE_BREAK + renderedContent;
      }
    }

    // Step 3 : Calling the dispatcher to print all contents.
    String lastContent = "";
    for (BlockContent blocContent : wikiElement.getContent()) {
      renderedContent += lastContent;
      lastContent = dispatcher.doSwitch(blocContent);
    }
    if (!lastContent.equals(WikiTextResourceSerializer.LINE_BREAK)) {
      renderedContent += lastContent;
    }

    return renderedContent;
  }