//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE-----------------------------
package org.huihoo.workflow.xpdl.parameter;

import org.huihoo.workflow.WorkflowSerializable;

public  class ParameterMode implements WorkflowSerializable
{
  public final static  ParameterMode MODE_IN=new ParameterMode("IN");
  
  public final static  ParameterMode MODE_OUT=new ParameterMode("OUT");
  
  public final static  ParameterMode MODE_INOUT=new ParameterMode("INOUT");
  
  private String mode;
  
  public ParameterMode(String mode)
  {
    this.mode=mode;
  }
  
  public String getMode()
  {
    return mode;
  }
  
  public static ParameterMode parse(String mode)
  {
    if("IN".equals(mode))
    {
      return MODE_IN;
    }
    else if("OUT".equals(mode))
    {
      return MODE_OUT;
    }
    else if("INOUT".equals(mode))
    {
      return MODE_INOUT;
    }
    
    //default value is MODE_IN
    
    return MODE_IN;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) 
    {
      return true;
    }

    if (obj instanceof ParameterMode) 
    {
      ParameterMode anotherPM = (ParameterMode)obj;
  
      if(anotherPM.getMode().equals(mode))
      {
        return true;
      }      
    }

    return false;
  }
  
	public String toString()
	{
		return "ParameterMode@" + mode;
	}
}
