package com.jscape.util.event;

import com.jscape.util.SuppressObfuscation;

import java.util.Iterator;
import java.util.List;

/**
 * @author Alex Usun
 */
@SuppressObfuscation
public interface EventContext {

    String getName();

    EventContext getEnclosedContext();

    void setEnclosedContext(EventContext context);

    <H extends Event.EventHandler> void attach(H handler, Class<? extends Event<H>> eventClass);

    <H extends Event.EventHandler> void detach(H handler, Class<? extends Event<H>> eventClass);

    <H extends Request.RequestHandler> void attach(H handler, Class<? extends Request<H>> requestClass);

    <H extends Request.RequestHandler> void detach(H handler, Class<? extends Request<H>> requestClass);

    void clearHandlers();

    void bind(Class aClass, EventHandler handler);

    void unbind(Class aClass, EventHandler handler);

    <H> List<H> getHandlers(Class aClass);

    <H extends Event.EventHandler, E extends Event<H>> E post(E event);

    <H extends Request.RequestHandler, R extends Request<H>> R post(R request)
            throws Request.RequestException;

    <T> T getAttribute(Object key);
    
    <T> T removeAttribute(Object key);

    EventContext setAttribute(Object key, Object value);

    Iterator<Object> attributes();

    void clearAttributes();

}
