001package com.hfg.xml.msofficexml.docx.wordprocessingml.style;
002
003import com.hfg.css.CSSBorderStyle;
004
005import java.util.HashMap;
006import java.util.Map;
007
008//------------------------------------------------------------------------------
009/**
010 Enumeration of line border styles.
011
012 @author J. Alex Taylor, hairyfatguy.com
013 */
014//------------------------------------------------------------------------------
015// com.hfg XML/HTML Coding Library
016//
017// This library is free software; you can redistribute it and/or
018// modify it under the terms of the GNU Lesser General Public
019// License as published by the Free Software Foundation; either
020// version 2.1 of the License, or (at your option) any later version.
021//
022// This library is distributed in the hope that it will be useful,
023// but WITHOUT ANY WARRANTY; without even the implied warranty of
024// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
025// Lesser General Public License for more details.
026//
027// You should have received a copy of the GNU Lesser General Public
028// License along with this library; if not, write to the Free Software
029// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030//
031// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
032// jataylor@hairyfatguy.com
033//------------------------------------------------------------------------------
034// Can't do this as a simple enum because of 'double'
035public class WmlLineBorderStyle
036{
037   private static final Map<String, WmlLineBorderStyle> sValueMap = new HashMap<>(25);
038
039   private String mName;
040
041   public static final WmlLineBorderStyle dashDotStroked         = new WmlLineBorderStyle("dashDotStroked");
042   public static final WmlLineBorderStyle dashed                 = new WmlLineBorderStyle("dashed");
043   public static final WmlLineBorderStyle dashSmallGap           = new WmlLineBorderStyle("dashSmallGap");
044   public static final WmlLineBorderStyle dbl                    = new WmlLineBorderStyle("double");  // Can't call it 'double' because that's a reserved word
045   public static final WmlLineBorderStyle dotDash                = new WmlLineBorderStyle("dotDash");
046   public static final WmlLineBorderStyle dotDotDash             = new WmlLineBorderStyle("dotDotDash");
047   public static final WmlLineBorderStyle dotted                 = new WmlLineBorderStyle("dotted");
048   public static final WmlLineBorderStyle doubleWave             = new WmlLineBorderStyle("doubleWave");
049   public static final WmlLineBorderStyle inset                  = new WmlLineBorderStyle("inset");
050   public static final WmlLineBorderStyle nil                    = new WmlLineBorderStyle("nil");
051   public static final WmlLineBorderStyle none                   = new WmlLineBorderStyle("none");
052   public static final WmlLineBorderStyle outset                 = new WmlLineBorderStyle("outset");
053   public static final WmlLineBorderStyle single                 = new WmlLineBorderStyle("single");
054   public static final WmlLineBorderStyle thick                  = new WmlLineBorderStyle("thick");
055   public static final WmlLineBorderStyle thickThinLargeGap      = new WmlLineBorderStyle("thickThinLargeGap");
056   public static final WmlLineBorderStyle thickThinMediumGap     = new WmlLineBorderStyle("thickThinMediumGap");
057   public static final WmlLineBorderStyle thickThinSmallGap      = new WmlLineBorderStyle("thickThinSmallGap");
058   public static final WmlLineBorderStyle thin                   = new WmlLineBorderStyle("thin");
059   public static final WmlLineBorderStyle thinThickLargeGap      = new WmlLineBorderStyle("thinThickLargeGap");
060   public static final WmlLineBorderStyle thinThickMediumGap     = new WmlLineBorderStyle("thinThickMediumGap");
061   public static final WmlLineBorderStyle thinThickSmallGap      = new WmlLineBorderStyle("thinThickSmallGap");
062   public static final WmlLineBorderStyle thinThickThinLargeGap  = new WmlLineBorderStyle("thinThickThinLargeGap");
063   public static final WmlLineBorderStyle thinThickThinMediumGap = new WmlLineBorderStyle("thinThickThinMediumGap");
064   public static final WmlLineBorderStyle thinThickThinSmallGap  = new WmlLineBorderStyle("thinThickThinSmallGap");
065   public static final WmlLineBorderStyle threeDEmboss           = new WmlLineBorderStyle("threeDEmboss");
066   public static final WmlLineBorderStyle threeDEngrave          = new WmlLineBorderStyle("threeDEngrave");
067   public static final WmlLineBorderStyle triple                 = new WmlLineBorderStyle("triple");
068   public static final WmlLineBorderStyle wave                   = new WmlLineBorderStyle("wave");
069
070
071   //---------------------------------------------------------------------------
072   private WmlLineBorderStyle(String inValue)
073   {
074      mName = inValue;
075      sValueMap.put(mName, this);
076   }
077
078   //---------------------------------------------------------------------------
079   public String name()
080   {
081      return mName;
082   }
083
084   //---------------------------------------------------------------------------
085   @Override
086   public String toString()
087   {
088      return name();
089   }
090
091   //---------------------------------------------------------------------------
092   @Override
093   public int hashCode()
094   {
095      return mName.hashCode();
096   }
097
098   //---------------------------------------------------------------------------
099   public static WmlLineBorderStyle valueOf(String inString)
100   {
101      return sValueMap.get(inString);
102   }
103
104   //---------------------------------------------------------------------------
105   public static WmlLineBorderStyle valueOf(CSSBorderStyle inCSSStyle)
106   {
107      WmlLineBorderStyle value = null;
108
109      if (inCSSStyle != null)
110      {
111         if (inCSSStyle == CSSBorderStyle.NONE)
112         {
113            value = WmlLineBorderStyle.nil;
114         }
115         else if (inCSSStyle == CSSBorderStyle.SOLID)
116         {
117            value = WmlLineBorderStyle.single;
118         }
119         else if (inCSSStyle == CSSBorderStyle.DOUBLE)
120         {
121            value = WmlLineBorderStyle.dbl;
122         }
123         else if (inCSSStyle == CSSBorderStyle.DASHED)
124         {
125            value = WmlLineBorderStyle.dashed;
126         }
127         else if (inCSSStyle == CSSBorderStyle.DOTTED)
128         {
129            value = WmlLineBorderStyle.dotted;
130         }
131         else if (inCSSStyle == CSSBorderStyle.INSET)
132         {
133            value = WmlLineBorderStyle.inset;
134         }
135         else if (inCSSStyle == CSSBorderStyle.OUTSET)
136         {
137            value = WmlLineBorderStyle.outset;
138         }
139      }
140
141      return value;
142   }
143
144}