package be.iminds.ilabt.jfed.groovy_dsl.impl.events;

import be.iminds.ilabt.jfed.groovy_dsl.DSLStreamException;
import be.iminds.ilabt.jfed.groovy_dsl.events.ClosureStartElement;

import java.io.IOException;
import java.io.Writer;

/**
 * User: twalcari
 * Date: 5/18/2015
 * Time: 09:23
 */
public class ClosureStartElementImpl extends DSLEventImpl implements ClosureStartElement {

    private final String name;

    public ClosureStartElementImpl(String name) {
        this.name = name;
    }


    @Override
    public String getName() {
        return name;
    }

    @Override
    public void write(Writer writer) throws DSLStreamException {
        try {
            writer.write(name);
            writer.write(" {\n");
        }catch(IOException ex){
            throw new DSLStreamException(ex);
        }
    }

}
