001/*
002 * Copyright 2020-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2020-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2020-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.extensions;
037
038
039
040import com.unboundid.util.NotNull;
041import com.unboundid.util.Nullable;
042import com.unboundid.util.StaticUtils;
043import com.unboundid.util.ThreadSafety;
044import com.unboundid.util.ThreadSafetyLevel;
045
046
047
048/**
049 * This enum defines the output stream values that may be used in conjunction
050 * with the {@link CollectSupportDataOutputIntermediateResponse}.
051 * <BR>
052 * <BLOCKQUOTE>
053 *   <B>NOTE:</B>  This class, and other classes within the
054 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
055 *   supported for use against Ping Identity, UnboundID, and
056 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
057 *   for proprietary functionality or for external specifications that are not
058 *   considered stable or mature enough to be guaranteed to work in an
059 *   interoperable way with other types of LDAP servers.
060 * </BLOCKQUOTE>
061 *
062 * @see  CollectSupportDataExtendedRequest
063 * @see  CollectSupportDataOutputIntermediateResponse
064 */
065@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
066public enum CollectSupportDataOutputStream
067{
068  /**
069   * The output stream that will be used to indicate standard output.
070   */
071  STANDARD_OUTPUT("stdout", 0),
072
073
074
075  /**
076   * The output stream that will be used to indicate standard error.
077   */
078  STANDARD_ERROR("stderr", 1);
079
080
081
082  // The integer value for this output stream value.
083  private final int intValue;
084
085  // The name for this output stream value.
086  @NotNull private final String name;
087
088
089
090  /**
091   * Creates a new collect support data output stream value with the provided
092   * information.
093   *
094   * @param  name      The name for this collect support data output stream
095   *                   value.
096   * @param  intValue  The integer value for this collect support data output
097   *                   stream value.
098   */
099  CollectSupportDataOutputStream(@NotNull final String name, final int intValue)
100  {
101    this.name = name;
102    this.intValue = intValue;
103  }
104
105
106
107  /**
108   * Retrieves the name for this collect support data output stream value.
109   *
110   * @return  The name for this collect support data output stream value.
111   */
112  @NotNull()
113  public String getName()
114  {
115    return name;
116  }
117
118
119
120  /**
121   * Retrieves the integer value for this collect support data output stream
122   * value.
123   *
124   * @return  The integer value for this collect support data output stream
125   *          value.
126   */
127  public int getIntValue()
128  {
129    return intValue;
130  }
131
132
133
134  /**
135   * Retrieves the collect support data output stream value with the given name.
136   *
137   * @param  name  The name for the output stream value to retrieve.  It must
138   *               not be {@code null}.
139   *
140   * @return  The collect support data output stream value with the given name,
141   *          or {@code null} if no output stream value is defined with the
142   *          given name.
143   */
144  @Nullable()
145  public static CollectSupportDataOutputStream forName(
146                     @NotNull final String name)
147  {
148    final String lowerName = StaticUtils.toLowerCase(name).replace('-', '_');
149    switch (lowerName)
150    {
151      case "stdout":
152      case "std-out":
153      case "standardout":
154      case "standard_out":
155      case "standardoutput":
156      case "standard_output":
157        return STANDARD_OUTPUT;
158
159      case "stderr":
160      case "std-err":
161      case "standarderr":
162      case "standard_err":
163      case "standarderror":
164      case "standard_error":
165        return STANDARD_ERROR;
166
167      default:
168        return null;
169    }
170  }
171
172
173
174  /**
175   * Retrieves the collect support data output stream value with the given
176   * integer value.
177   *
178   * @param  intValue  The integer value for the output stream value to
179   *                   retrieve.  It must not be {@code null}.
180   *
181   * @return  The collect support data output stream value with the given
182   *          integer value, or {@code null} if no output stream value is
183   *          defined with the given integer value.
184   */
185  @Nullable()
186  public static CollectSupportDataOutputStream forIntValue(final int intValue)
187  {
188    for (final CollectSupportDataOutputStream os : values())
189    {
190      if (os.intValue == intValue)
191      {
192        return os;
193      }
194    }
195
196    return null;
197  }
198
199
200
201  /**
202   * Retrieves a string representation of this collect support data output
203   * stream value.
204   *
205   * @return  A string representation of this collect support data output stream
206   *          value.
207   */
208  @Override()
209  @NotNull()
210  public String toString()
211  {
212    return name;
213  }
214}