/*
 * See LICENSE file in distribution for copyright and licensing information.
 */
package org.yaml.snakeyaml;

import java.io.InputStream;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import org.yaml.snakeyaml.representer.Represent;

/**
 * Public YAML interface
 */
public class Yaml {
    private Dumper dumper;
    private Loader loader;

    public Yaml(DumperOptions options) {
        this.dumper = new Dumper(options);
    }

    public Yaml(Dumper dumper) {
        this(new Loader(), dumper);
    }

    public Yaml(Loader loader) {
        this(loader, new Dumper(new DumperOptions()));
    }

    public Yaml(Loader loader, Dumper dumper) {
        this.loader = loader;
        this.dumper = dumper;
    }

    public Yaml() {
        this(new Loader(), new Dumper(new DumperOptions()));
    }

    /**
     * Serialize a Java object into a YAML String.
     * 
     * @param data
     *            - Java object to be Serialized to YAML
     * @return YAML String
     */
    public String dump(final Object data) {
        final List<Object> lst = new ArrayList<Object>(1);
        lst.add(data);
        return dumpAll(lst);
    }

    /**
     * Serialize a sequence of Java objects into a YAML String.
     * 
     * @param data
     *            - Iterator with Objects
     * @return - YAML String with all the objects in proper sequence
     */
    public String dumpAll(final Iterable<Object> data) {
        final StringWriter swe = new StringWriter();
        dumpAll(data, swe);
        return swe.toString();
    }

    /**
     * Serialize a Java object into a YAML stream.
     * 
     * @param data
     *            - Java object to be Serialized to YAML
     * @param output
     *            - stream to write to
     */
    public void dump(final Object data, final Writer output) {
        final List<Object> lst = new ArrayList<Object>(1);
        lst.add(data);
        dumpAll(lst, output);
    }

    /**
     * Serialize a sequence of Java objects into a YAML stream.
     * 
     * @param data
     *            - Iterator with Objects
     * @param output
     *            - stream to write to
     */
    public void dumpAll(final Iterable<Object> data, final Writer output) {
        dumper.dump(data, output);
    }

    /**
     * Parse the first YAML document in a String and produce the corresponding
     * Java object. (Because the encoding in known BOM is not respected.)
     * 
     * @param yaml
     *            - YAML data to load from (BOM must not be present)
     * @return parsed object
     */
    public Object load(String yaml) {
        return loader.load(yaml);
    }

    /**
     * Parse the first YAML document in a stream and produce the corresponding
     * Java object.
     * 
     * @param io
     *            - data to load from (BOM is respected and ignored)
     * @return parsed object
     */
    public Object load(InputStream io) {
        return loader.load(io);
    }

    /**
     * Parse all YAML documents in a String and produce corresponding Java
     * objects. (Because the encoding in known BOM is not respected.)
     * 
     * @param yaml
     *            - YAML data to load from (BOM must not be present)
     * @return an iterator over the parsed Java objects in this String in proper
     *         sequence
     */
    public Iterable<Object> loadAll(String yaml) {
        return loader.loadAll(yaml);
    }

    /**
     * Parse all YAML documents in a stream and produce corresponding Java
     * objects.
     * 
     * @param yaml
     *            - YAML data to load from (BOM is respected and ignored)
     * @return an iterator over the parsed Java objects in this stream in proper
     *         sequence
     */
    public Iterable<Object> loadAll(InputStream yaml) {
        return loader.loadAll(yaml);
    }

    // Customisers

    /**
     * Add a representer for the given type. Multi-representer is accepting an
     * instance of the given data type or subtype and producing the
     * corresponding representation node.
     * 
     * @param clazz
     * @param representer
     */
    @SuppressWarnings("unchecked")
    public void addMultiRepresenter(Class clazz, Represent representer) {
        throw new UnsupportedOperationException();
    }

    /**
     * Add an implicit scalar detector. If an implicit scalar value matches the
     * given regexp, the corresponding tag is assigned to the scalar. first is a
     * sequence of possible initial characters or None.
     * 
     * @param tag
     *            - tag to assign to the node
     * @param regexp
     *            - regular expression to match against
     * @param first
     *            - a sequence of possible initial characters or None
     */
    public void addImplicitResolver(String tag, Pattern regexp, String first) {
        throw new UnsupportedOperationException();
    }

    /**
     * Add a path based resolver for the given tag. A path is a list of keys
     * that forms a path to a node in the representation tree. Keys can be
     * string values, integers, or None.
     * 
     * @param tag
     * @param path
     * @param kind
     */
    public void addPathResolver(String tag, List<Object> path, Object kind) {
        throw new UnsupportedOperationException();
    }
}

@@ -240,90 +240,8 @@
 ist;
-%0Aimport java.util.regex.Pattern;%0A%0Aimport org.yaml.snakeyaml.representer.Represent;
 %0A%0A/*
@@ -1033,38 +1033,32 @@
 data) %7B%0A        
-final 
 List%3CObject%3E lst
@@ -1428,22 +1428,16 @@
         
-final 
 StringWr
@@ -1441,19 +1441,22 @@
 gWriter 
-swe
+buffer
  = new S
@@ -1492,19 +1492,22 @@
 l(data, 
-swe
+buffer
 );%0A     
@@ -1520,11 +1520,14 @@
 urn 
-swe
+buffer
 .toS
@@ -1824,22 +1824,16 @@
         
-final 
 List%3CObj
@@ -3765,32 +3765,32 @@
 tStream yaml) %7B%0A
+
         return l
@@ -3819,1472 +3819,7 @@
    %7D
-%0A%0A    // Customisers%0A%0A    /**%0A     * Add a representer for the given type. Multi-representer is accepting an%0A     * instance of the given data type or subtype and producing the%0A     * corresponding representation node.%0A     * %0A     * @param clazz%0A     * @param representer%0A     */%0A    @SuppressWarnings(%22unchecked%22)%0A    public void addMultiRepresenter(Class clazz, Represent representer) %7B%0A        throw new UnsupportedOperationException();%0A    %7D%0A%0A    /**%0A     * Add an implicit scalar detector. If an implicit scalar value matches the%0A     * given regexp, the corresponding tag is assigned to the scalar. first is a%0A     * sequence of possible initial characters or None.%0A     * %0A     * @param tag%0A     *            - tag to assign to the node%0A     * @param regexp%0A     *            - regular expression to match against%0A     * @param first%0A     *            - a sequence of possible initial characters or None%0A     */%0A    public void addImplicitResolver(String tag, Pattern regexp, String first) %7B%0A        throw new UnsupportedOperationException();%0A    %7D%0A%0A    /**%0A     * Add a path based resolver for the given tag. A path is a list of keys%0A     * that forms a path to a node in the representation tree. Keys can be%0A     * string values, integers, or None.%0A     * %0A     * @param tag%0A     * @param path%0A     * @param kind%0A     */%0A    public void addPathResolver(String tag, List%3CObject%3E path, Object kind) %7B%0A        throw new UnsupportedOperationException();%0A    %7D
 %0A%7D%0A

remove unused methods from public interface