| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| OperatorForm |
|
| 2.0;2 |
| 1 | /* | |
| 2 | * Copyright 2008 - 2008 JEuclid, http://jeuclid.sf.net | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | ||
| 17 | /* $Id: OperatorForm.java,v cae99f384592 2009/06/03 12:42:28 maxberger $ */ | |
| 18 | ||
| 19 | package net.sourceforge.jeuclid.elements.support.operatordict; | |
| 20 | ||
| 21 | import java.util.Locale; | |
| 22 | ||
| 23 | /** | |
| 24 | * @version $Revision: cae99f384592 $ | |
| 25 | */ | |
| 26 | 21823990 | public enum OperatorForm { |
| 27 | /** Prefix form, e.g. +a. */ | |
| 28 | 209 | PREFIX, |
| 29 | /** Infix form, e.g. a+a. */ | |
| 30 | 209 | INFIX, |
| 31 | /** Postfix form, e.g. a+. */ | |
| 32 | 209 | POSTFIX; |
| 33 | ||
| 34 | 627 | private OperatorForm() { |
| 35 | // Empty on purpose. | |
| 36 | 627 | } |
| 37 | ||
| 38 | /** | |
| 39 | * Parse a String into an OperatorForm. | |
| 40 | * | |
| 41 | * @param form | |
| 42 | * the string to parse | |
| 43 | * @return an OperatorForm | |
| 44 | */ | |
| 45 | public static OperatorForm parseOperatorForm(final String form) { | |
| 46 | try { | |
| 47 | 21823572 | return OperatorForm.valueOf(form.toUpperCase(Locale.US)); |
| 48 | 0 | } catch (final IllegalArgumentException iae) { |
| 49 | 0 | return OperatorForm.INFIX; |
| 50 | } | |
| 51 | } | |
| 52 | } |