001    package org.apache.myfaces.tobago.layout;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more
005     * contributor license agreements.  See the NOTICE file distributed with
006     * this work for additional information regarding copyright ownership.
007     * The ASF licenses this file to You under the Apache License, Version 2.0
008     * (the "License"); you may not use this file except in compliance with
009     * the License.  You may obtain a copy of the License at
010     *
011     *      http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing, software
014     * distributed under the License is distributed on an "AS IS" BASIS,
015     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016     * See the License for the specific language governing permissions and
017     * limitations under the License.
018     */
019    
020    
021    import java.util.HashMap;
022    import java.util.Map;
023    
024    
025    public enum TextAlign {
026    
027      LEFT("left"),
028      RIGHT("right"),
029      CENTER("center"),
030      JUSTIFY("justify");
031    
032      public static final String STRING_LEFT = "left";
033      public static final String STRING_RIGHT = "right";
034      public static final String STRING_CENTER = "center";
035      public static final String STRING_JUSTIFY = "justify";
036    
037      private String value;
038    
039      TextAlign(String value) {
040        this.value = value;
041      }
042    
043      public String getValue() {
044        return value;
045      }
046    
047      private static final Map<String, TextAlign> MAPPING;
048    
049      static {
050        MAPPING = new HashMap<String, TextAlign>();
051    
052        for (TextAlign textAlign : TextAlign.values()) {
053          MAPPING.put(textAlign.getValue(), textAlign);
054        }
055      }
056    
057      public static TextAlign parse(String string) {
058        if (string == null) {
059          return null;
060        }
061        TextAlign value = MAPPING.get(string);
062        if (value != null) {
063          return value;
064        } else {
065          throw new IllegalArgumentException("Unknown value for TextAlign: '" + string + "'");
066        }
067      }
068    
069    }