/*********************************************
* Open and Survivable Embedded Systems (OASES)
*
* Structured Policy Command Language (SPCL)
*
*
* This software is provided as is without any
* warranty or guarantee of merchantibility
* or fitness for a particular purpose. This
* software is released under the terms of the
* GNU General Public License (GPL).
*
* Last updated: May 8, 2003
*
***********************************************/


package spcl.data;

import java.util.*;

/**
 * A regular expression denoting the variations
 * on a command that a Principal can take wrt
 * a particular Object.
 *
 * actions{
      action a = "GET /~locasto/docs/*.html";
	  a.meta_action = notify mom;
	  you notify principals and
	  you log to objects
   }
 *
 * @author locasto@cs.columbia.edu
 *
*/

public class Action{

	public static final int NULL_META_ACTION = 5;
	public static final int LOG_META_ACTION = 10;
	public static final int NOTIFY_META_ACTION = 20;

	private int meta_action = Action.NULL_META_ACTION;
	private String meta_action_target;

	private String regular_expression;
	private SystemObject sysObj;
	private String name;
	
	public Action( String name ){
		this.name = name;
	}

	public String getName(){
		return name;
	}

	public String getActionPattern(){
		return regular_expression;
	}
	
	public void setActionPattern( String regex ){
		regular_expression = regex;
	}

	public void setObject( SystemObject sysObj ){
		this.sysObj = sysObj;
	}
	
	public SystemObject getObject(){
		return sysObj;
	}

	public void setMetaActionTarget( String target ){
		meta_action_target=target;
	}

	public String getMetaActionTarget(){
		return meta_action_target;
	}

	public int getMetaAction(){
		return meta_action;
	}

	public void setMetaAction( int t ){
		switch( t ){
			case Action.LOG_META_ACTION: this.meta_action = t; break;
			case Action.NOTIFY_META_ACTION: this.meta_action = t; break;
			default: this.meta_action = Action.NULL_META_ACTION;
		}
	}


}
