/*
 * Copyright 2010-2015 Allette Systems (Australia)
 * http://www.allette.com.au
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.pageseeder.diffx.handler;

import org.pageseeder.diffx.action.Operator;
import org.pageseeder.diffx.event.DiffXEvent;
import org.pageseeder.diffx.format.DiffXFormatter;

import java.io.IOException;
import java.io.UncheckedIOException;

public class FormattingAdapter implements DiffHandler {

  protected final DiffXFormatter formatter;

  public FormattingAdapter(DiffXFormatter formatter) {
    this.formatter = formatter;
  }

  @Override
  public void handle(Operator operator, DiffXEvent event) throws UncheckedIOException, IllegalStateException {
    try {
      switch (operator) {
        case MATCH:
          this.formatter.format(event);
          break;
        case INS:
          this.formatter.insert(event);
          break;
        case DEL:
          this.formatter.delete(event);
          break;
        default:
          // Ignore
      }
    } catch (IOException ex) {
      throw new UncheckedIOException(ex);
    }
  }

  @Override
  public String toString() {
    return "FormattingAdapter("+this.formatter+")";
  }

}

@@ -886,201 +886,671 @@
 n;%0A%0A
-public class FormattingAdapter implements DiffHandler %7B%0A%0A  protected final DiffXFormatter formatter;%0A%0A  public FormattingAdapter(DiffXFormatter formatter) %7B%0A    this.formatter = formatter;%0A  %7D%0A
+/**%0A * A handler wrapping a formatter so that the formatter can be used in the new API.%0A *%0A * @author Christophe Lauret%0A * @version 0.9.0%0A */%0Apublic class FormattingAdapter implements DiffHandler %7B%0A%0A  /**%0A   * The target formatter protected to allow any subclasses to access it.%0A   */%0A  protected final DiffXFormatter formatter;%0A%0A  public FormattingAdapter(DiffXFormatter formatter) %7B%0A    this.formatter = formatter;%0A  %7D%0A%0A  /**%0A   * Invoke the formatter's method correspding to the operator.%0A   *%0A   * @param operator The operator%0A   * @param event    The event to handle%0A   *%0A   * @throws UncheckedIOException Wraps any IO exception thrown by the formatter%0A   */
 %0A  @
@@ -1647,31 +1647,8 @@
 tion
-, IllegalStateException
  %7B%0A 
@@ -1945,16 +1945,31 @@
 / Ignore
+ and do nothing
 %0A      %7D

Update javadoc