/*
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.cache.lock;

/**
 *
 * @author Bela Ban Nov 25, 2003
 * @version $Id: IsolationLevel.java,v 1.1.2.7 2005/12/01 19:48:42 dimitris Exp $
 */
public class IsolationLevel
{
   public static final IsolationLevel NONE = new IsolationLevel("NONE");
   public static final IsolationLevel SERIALIZABLE = new IsolationLevel("SERIALIZABLE");
   public static final IsolationLevel REPEATABLE_READ = new IsolationLevel("REPEATABLE_READ");
   public static final IsolationLevel READ_COMMITTED = new IsolationLevel("READ_COMMITTED");
   public static final IsolationLevel READ_UNCOMMITTED = new IsolationLevel("READ_UNCOMMITTED");
   public static final IsolationLevel BELA = new IsolationLevel("BELA");

   private final String myName; // for debug only

   private IsolationLevel(String name)
   {
      myName = name;
   }

   public String toString()
   {
      return myName;
   }

   public static IsolationLevel stringToIsolationLevel(String level)
   {
      if (level == null) return null;
      level = level.toLowerCase().trim();
      if (level.equals("none")) return NONE;
      if (level.equals("serializable")) return SERIALIZABLE;
      if (level.equals("repeatable_read") || level.equals("repeatable-read")) return REPEATABLE_READ;
      if (level.equals("read_committed") || level.equals("read-committed")) return READ_COMMITTED;
      if (level.equals("read_uncommitted") || level.equals("read-uncommitted")) return READ_UNCOMMITTED;
      if (level.equals("bela")) return BELA;
      return null;
   }
}
