/*

This software is OSI Certified Open Source Software.
OSI Certified is a certification mark of the Open Source Initiative.

The license (Mozilla version 1.0) can be read at the MMBase site.
See http://www.MMBase.org/license

*/
package org.mmbase.security;

import java.util.HashMap;
/**
 * This class is somekinda enumeration of the ranks possible within
 * the security context
 * @javadoc
 * @author Eduard Witteveen
 * @version $Id: Rank.java,v 1.5 2002/06/07 12:56:55 pierre Exp $
 */
public abstract class AbstractRank {

   protected static HashMap Ranks = new HashMap();
   static {
     load();
   }
     /**
     *	Private constructor, to prevent creation of new Ranks
     */
    public AbstractRank() { }
    protected AbstractRank(int rank, String description) {
      this.rank = rank;
      this.description = description;
      Ranks.put((Object)description,(Object)this);
    }

    protected static void load () {};

    public static AbstractRank getRank(String rankDesc) {
        if(Ranks.containsKey((Object)rankDesc)) {
           return (AbstractRank) Ranks.get((Object)rankDesc);
        } else {
           return null;
        }
    }


    /**
     *	This method gives back the internal int value of the rank
     *	which can be used in switch statements
     *	@return the internal int value
     */
    public int getInt(){
        return rank;
    }

    /**
     *	@return a string containing the description of the rank
     */
    public String toString(){
        return description;
    }

    protected int rank;
    protected String description;


}
