/**
   * Get the DataContentHandler for this DataHandler:
   *
   * <p>If a DataContentHandlerFactory is set, use it. Otherwise look for an object to serve DCH in
   * the following order:
   *
   * <p>1) if a factory is set, use it
   *
   * <p>2) if a CommandMap is set, use it
   *
   * <p>3) use the default CommandMap
   *
   * <p>In any case, wrap the real DataContentHandler with one of our own to handle any missing
   * cases, fill in defaults, and to ensure that we always have a non-null DataContentHandler.
   *
   * @return the requested DataContentHandler
   */
  private synchronized DataContentHandler getDataContentHandler() {

    // make sure the factory didn't change
    if (factory != oldFactory) {
      oldFactory = factory;
      factoryDCH = null;
      dataContentHandler = null;
      transferFlavors = emptyFlavors;
    }

    if (dataContentHandler != null) return dataContentHandler;

    String simpleMT = getBaseType();

    if (factoryDCH == null && factory != null)
      factoryDCH = factory.createDataContentHandler(simpleMT);

    if (factoryDCH != null) dataContentHandler = factoryDCH;

    if (dataContentHandler == null) {
      if (dataSource != null)
        dataContentHandler = getCommandMap().createDataContentHandler(simpleMT, dataSource);
      else dataContentHandler = getCommandMap().createDataContentHandler(simpleMT);
    }

    // getDataContentHandler always uses these 'wrapper' handlers
    // to make sure it returns SOMETHING meaningful...
    if (dataSource != null)
      dataContentHandler = new DataSourceDataContentHandler(dataContentHandler, dataSource);
    else
      dataContentHandler = new ObjectDataContentHandler(dataContentHandler, object, objectMimeType);
    return dataContentHandler;
  }