/*
 * Created on 2004-6-13
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package workflow.script.core;

import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;

/**
 * @author reic
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public interface ScriptContext
{
	/**
	 * Return the ScriptConfig of the specified context, if any;
	 */
	public ScriptConfig getScriptConfig();
	
	/**
	 * Return the value of the specified context attribute, if any;
	 * otherwise return <code>null</code>.
	 *
	 * @param name Name of the context attribute to return
	 */
	public Object getAttribute(String name);

	/**
	 * Return an enumeration of the names of the context attributes
	 * associated with this context.
	 */
	public Enumeration getAttributeNames();

	/**
	 * Return the value of the specified initialization parameter, or
	 * <code>null</code> if this parameter does not exist.
	 *
	 * @param name Name of the initialization parameter to retrieve
	 */
	public String getInitParameter(final String name);

	/**
	 * Return the names of the context's initialization parameters, or an
	 * empty enumeration if the context has no initialization parameters.
	 */
	public Enumeration getInitParameterNames();

	/**
	 * Return the real path for a given virtual path, if possible; otherwise
	 * return <code>null</code>.
	 *
	 * @param path The path to the desired resource
	 */
	public String getRealPath(String path);

	/**
	 * Return the URL to the resource that is mapped to a specified path.
	 * The path must begin with a "/" and is interpreted as relative to the
	 * current context root.
	 *
	 * @param path The path to the desired resource
	 *
	 * @exception MalformedURLException if the path is not given
	 *  in the correct form
	 */
	public URL getResource(String path) throws MalformedURLException;

	/**
	 * Return the requested resource as an <code>InputStream</code>.  The
	 * path must be specified according to the rules described under
	 * <code>getResource</code>.  If no such resource can be identified,
	 * return <code>null</code>.
	 *
	 * @param path The path to the desired resource.
	 */
	public InputStream getResourceAsStream(String path);


	/**
	 * Writes the specified message to a script log file.
	 *
	 * @param message Message to be written
	 */
	public void log(String message);

	/**
	 * Writes the specified message and exception to a script log file.
	 *
	 * @param message Message to be written
	 * @param throwable Exception to be reported
	 */
	public void log(String message, Throwable throwable);

	/**
	 * Remove the context attribute with the specified name, if any.
	 *
	 * @param name Name of the context attribute to be removed
	 */
	public void removeAttribute(String name);

	/**
	 * Bind the specified value with the specified context attribute name,
	 * replacing any existing value for that name.
	 *
	 * @param name Attribute name to be bound
	 * @param value New attribute value to be bound
	 */
	public void setAttribute(String name, Object value);

}
