001    /*
002     * Copyright 2002 - 2007 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: OperatorAttribute.java,v 88b901bf20fb 2008/06/07 14:12:27 maxberger $ */
018    
019    package net.sourceforge.jeuclid.elements.support.operatordict;
020    
021    import java.util.Locale;
022    
023    import net.sourceforge.jeuclid.Constants;
024    
025    /**
026     * @version $Revision: 88b901bf20fb $
027     */
028    /**
029     * @version $Revision: 88b901bf20fb $
030     */
031    public enum OperatorAttribute {
032    
033        /** */
034        FORM(OperatorDictionary.FORM_INFIX),
035        /** */
036        FENCE(Constants.FALSE),
037        /** */
038        SEPARATOR(Constants.FALSE),
039        /** */
040        LSPACE(OperatorDictionary.NAME_THICKMATHSPACE),
041        /** */
042        RSPACE(OperatorDictionary.NAME_THICKMATHSPACE),
043        /** */
044        STRETCHY(Constants.FALSE),
045        /** */
046        SYMMETRIC(Constants.TRUE),
047        /** */
048        MAXSIZE(OperatorDictionary.NAME_INFINITY),
049        /** */
050        MINSIZE("1"),
051        /** */
052        LARGEOP(Constants.FALSE),
053        /** */
054        MOVABLELIMITS(Constants.FALSE),
055        /** */
056        ACCENT(Constants.FALSE);
057    
058        private final String defaultValue;
059    
060        private OperatorAttribute(final String defValue) {
061            this.defaultValue = defValue;
062        }
063    
064        /**
065         * @return the default value for this operator attribute.
066         */
067        public String getDefaultValue() {
068            return this.defaultValue;
069        }
070    
071        /**
072         * Parses a String into an OperatorAttribute.
073         * 
074         * @param attr
075         *            the String to parse
076         * @return an operatorAttibute if possible
077         * @throws UnknownAttributeException
078         *             if the string does not represent a valid attribute.
079         */
080        public static OperatorAttribute parseOperatorAttribute(final String attr)
081                throws UnknownAttributeException {
082            try {
083                return OperatorAttribute.valueOf(attr.toUpperCase(Locale.US));
084            } catch (final IllegalArgumentException iae) {
085                throw new UnknownAttributeException(attr, iae);
086            }
087        }
088    
089    }