001 /*
002 * Copyright 2008 - 2008 JEuclid, http://jeuclid.sf.net
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 /* $Id: OperatorForm.java,v cae99f384592 2009/06/03 12:42:28 maxberger $ */
018
019 package net.sourceforge.jeuclid.elements.support.operatordict;
020
021 import java.util.Locale;
022
023 /**
024 * @version $Revision: cae99f384592 $
025 */
026 public enum OperatorForm {
027 /** Prefix form, e.g. +a. */
028 PREFIX,
029 /** Infix form, e.g. a+a. */
030 INFIX,
031 /** Postfix form, e.g. a+. */
032 POSTFIX;
033
034 private OperatorForm() {
035 // Empty on purpose.
036 }
037
038 /**
039 * Parse a String into an OperatorForm.
040 *
041 * @param form
042 * the string to parse
043 * @return an OperatorForm
044 */
045 public static OperatorForm parseOperatorForm(final String form) {
046 try {
047 return OperatorForm.valueOf(form.toUpperCase(Locale.US));
048 } catch (final IllegalArgumentException iae) {
049 return OperatorForm.INFIX;
050 }
051 }
052 }