001/*
002 * Copyright 2009-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2009-2018 Ping Identity Corporation
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.util;
022
023
024
025/**
026 * This enum defines a set of output formats that may be used in conjunction
027 * with the {@link ColumnFormatter} when formatting data.
028 */
029@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
030public enum OutputFormat
031{
032  /**
033   * Indicates that the output should be formatted in columns.
034   */
035  COLUMNS,
036
037
038
039  /**
040   * Indicates that the output should be formatted as tab-delimited text.
041   */
042  TAB_DELIMITED_TEXT,
043
044
045
046  /**
047   * Indicates that the output should be formatted as comma-separated values.
048   */
049  CSV;
050
051
052
053  /**
054   * Retrieves the output format value with the specified name.
055   *
056   * @param  name  The name of the output format value to retrieve.  It must not
057   *               be {@code null}.
058   *
059   * @return  The requested output format value, or {@code null} if no such
060   *          format is defined.
061   */
062  public static OutputFormat forName(final String name)
063  {
064    switch (StaticUtils.toLowerCase(name))
065    {
066      case "columns":
067        return COLUMNS;
068      case "tabdelimitedtext":
069      case "tab-delimited-text":
070      case "tab_delimited_text":
071        return TAB_DELIMITED_TEXT;
072      case "csv":
073        return CSV;
074      default:
075        return null;
076    }
077  }
078}