<commit_before>package net.hillsdon.reviki.wiki.renderer;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import net.hillsdon.reviki.wiki.MarkupRenderer;

/**
 * A class which can provide renderers based on the desired result type.
 *
 * @author msw
 */
public class RendererRegistry {
  /** The default (HTML) renderer. */
  private final HtmlRenderer _default;

  /** Renderers which produce a stream of output. */
  private final Map<String, MarkupRenderer<InputStream>> _renderers;

  /**
   * @param html The default HTML renderer.
   */
  public RendererRegistry(final HtmlRenderer html) {
    _default = html;
    _renderers = new HashMap<String, MarkupRenderer<InputStream>>();
  }

  /** Return the default (HTML) renderer. */
  public HtmlRenderer getDefaultRenderer() {
    return _default;
  }

  /** Add a new stream renderer. */
  public void addRenderer(final String ctype, final MarkupRenderer<InputStream> renderer) {
    _renderers.put(ctype, renderer);
  }

  /** Check if we have a stream renderer for the desired ctype. */
  public boolean hasRenderer(final String ctype) {
    return _renderers.containsKey(ctype);
  }

  /** Get the stream renderer for this ctype. */
  public MarkupRenderer<InputStream> getRenderer(final String ctype) {
    return _renderers.get(ctype);
  }
}<commit_msg>Change RendererRegistry to use a TreeMap, and handle nulls explicitly<commit_after>package net.hillsdon.reviki.wiki.renderer;

import java.io.InputStream;
import java.util.TreeMap;
import java.util.Map;

import net.hillsdon.reviki.wiki.MarkupRenderer;

/**
 * A class which can provide renderers based on the desired result type.
 *
 * @author msw
 */
public class RendererRegistry {
  /** The default (HTML) renderer. */
  private final HtmlRenderer _default;

  /** Renderers which produce a stream of output. */
  private final Map<String, MarkupRenderer<InputStream>> _renderers;

  /**
   * @param html The default HTML renderer.
   */
  public RendererRegistry(final HtmlRenderer html) {
    _default = html;
    _renderers = new TreeMap<String, MarkupRenderer<InputStream>>();
  }

  /** Return the default (HTML) renderer. */
  public HtmlRenderer getDefaultRenderer() {
    return _default;
  }

  /** Add a new stream renderer. */
  public void addRenderer(final String ctype, final MarkupRenderer<InputStream> renderer) {
    _renderers.put(ctype, renderer);
  }

  /** Check if we have a stream renderer for the desired ctype. */
  public boolean hasRenderer(final String ctype) {
    return (ctype == null) ? false : _renderers.containsKey(ctype);
  }

  /** Get the stream renderer for this ctype. */
  public MarkupRenderer<InputStream> getRenderer(final String ctype) {
    return (ctype == null) ? null : _renderers.get(ctype);
  }
}
{'fraction_non_alphanumeric': 0.1041890440386681, 'fraction_numerical': 0.0, 'mean_word_length': 3.8846153846153846, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5215290', 'n_tokens_mistral': 835, 'n_tokens_neox': 820, 'n_words': 255}