001/* 002 * Copyright 2020 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright 2020 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 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.StaticUtils; 041import com.unboundid.util.ThreadSafety; 042import com.unboundid.util.ThreadSafetyLevel; 043 044 045 046/** 047 * This enum defines the output stream values that may be used in conjunction 048 * with the {@link CollectSupportDataOutputIntermediateResponse}. 049 * <BR> 050 * <BLOCKQUOTE> 051 * <B>NOTE:</B> This class, and other classes within the 052 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 053 * supported for use against Ping Identity, UnboundID, and 054 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 055 * for proprietary functionality or for external specifications that are not 056 * considered stable or mature enough to be guaranteed to work in an 057 * interoperable way with other types of LDAP servers. 058 * </BLOCKQUOTE> 059 * 060 * @see CollectSupportDataExtendedRequest 061 * @see CollectSupportDataOutputIntermediateResponse 062 */ 063@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 064public enum CollectSupportDataOutputStream 065{ 066 /** 067 * The output stream that will be used to indicate standard output. 068 */ 069 STANDARD_OUTPUT("stdout", 0), 070 071 072 073 /** 074 * The output stream that will be used to indicate standard error. 075 */ 076 STANDARD_ERROR("stderr", 1); 077 078 079 080 // The integer value for this output stream value. 081 private final int intValue; 082 083 // The name for this output stream value. 084 private final String name; 085 086 087 088 /** 089 * Creates a new collect support data output stream value with the provided 090 * information. 091 * 092 * @param name The name for this collect support data output stream 093 * value. 094 * @param intValue The integer value for this collect support data output 095 * stream value. 096 */ 097 CollectSupportDataOutputStream(final String name, final int intValue) 098 { 099 this.name = name; 100 this.intValue = intValue; 101 } 102 103 104 105 /** 106 * Retrieves the name for this collect support data output stream value. 107 * 108 * @return The name for this collect support data output stream value. 109 */ 110 public String getName() 111 { 112 return name; 113 } 114 115 116 117 /** 118 * Retrieves the integer value for this collect support data output stream 119 * value. 120 * 121 * @return The integer value for this collect support data output stream 122 * value. 123 */ 124 public int getIntValue() 125 { 126 return intValue; 127 } 128 129 130 131 /** 132 * Retrieves the collect support data output stream value with the given name. 133 * 134 * @param name The name for the output stream value to retrieve. It must 135 * not be {@code null}. 136 * 137 * @return The collect support data output stream value with the given name, 138 * or {@code null} if no output stream value is defined with the 139 * given name. 140 */ 141 public static CollectSupportDataOutputStream forName(final String name) 142 { 143 final String lowerName = StaticUtils.toLowerCase(name).replace('-', '_'); 144 switch (lowerName) 145 { 146 case "stdout": 147 case "std-out": 148 case "standardout": 149 case "standard_out": 150 case "standardoutput": 151 case "standard_output": 152 return STANDARD_OUTPUT; 153 154 case "stderr": 155 case "std-err": 156 case "standarderr": 157 case "standard_err": 158 case "standarderror": 159 case "standard_error": 160 return STANDARD_ERROR; 161 162 default: 163 return null; 164 } 165 } 166 167 168 169 /** 170 * Retrieves the collect support data output stream value with the given 171 * integer value. 172 * 173 * @param intValue The integer value for the output stream value to 174 * retrieve. It must not be {@code null}. 175 * 176 * @return The collect support data output stream value with the given 177 * integer value, or {@code null} if no output stream value is 178 * defined with the given integer value. 179 */ 180 public static CollectSupportDataOutputStream forIntValue(final int intValue) 181 { 182 for (final CollectSupportDataOutputStream os : values()) 183 { 184 if (os.intValue == intValue) 185 { 186 return os; 187 } 188 } 189 190 return null; 191 } 192 193 194 195 /** 196 * Retrieves a string representation of this collect support data output 197 * stream value. 198 * 199 * @return A string representation of this collect support data output stream 200 * value. 201 */ 202 @Override() 203 public String toString() 204 { 205 return name; 206 } 207}