001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.httppart; 018 019/** 020 * Valid values for the <c>format</c> field. 021 * 022 * <h5 class='section'>See Also:</h5><ul> 023 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/HttpPartSerializersParsers">HTTP Part Serializers and Parsers</a> 024 * </ul> 025 */ 026public enum HttpPartFormat { 027 028 /** 029 * Signed 32 bits. 030 */ 031 INT32, 032 033 /** 034 * Signed 64 bits. 035 */ 036 INT64, 037 038 /** 039 * 32-bit floating point number. 040 */ 041 FLOAT, 042 043 /** 044 * 64-bit floating point number. 045 */ 046 DOUBLE, 047 048 /** 049 * BASE-64 encoded characters. 050 */ 051 BYTE, 052 053 /** 054 * Hexadecimal encoded octets (e.g. <js>"00FF"</js>). 055 */ 056 BINARY, 057 058 /** 059 * Spaced-separated hexadecimal encoded octets (e.g. <js>"00 FF"</js>). 060 */ 061 BINARY_SPACED, 062 063 /** 064 * An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 full-date</a>. 065 */ 066 DATE, 067 068 /** 069 * An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 date-time</a>. 070 */ 071 DATE_TIME, 072 073 /** 074 * Used to hint UIs the input needs to be obscured. 075 */ 076 PASSWORD, 077 078 /** 079 * UON notation (e.g. <js>"(foo=bar,baz=@(qux,123))"</js>). 080 */ 081 UON, 082 083 /** 084 * Email address (RFC 5321). 085 * 086 * @since 9.2.0 087 */ 088 EMAIL, 089 090 /** 091 * Internationalized email address (RFC 6531). 092 * 093 * @since 9.2.0 094 */ 095 IDN_EMAIL, 096 097 /** 098 * Internet host name (RFC 1123). 099 * 100 * @since 9.2.0 101 */ 102 HOSTNAME, 103 104 /** 105 * Internationalized host name (RFC 5890). 106 * 107 * @since 9.2.0 108 */ 109 IDN_HOSTNAME, 110 111 /** 112 * IPv4 address (RFC 2673). 113 * 114 * @since 9.2.0 115 */ 116 IPV4, 117 118 /** 119 * IPv6 address (RFC 4291). 120 * 121 * @since 9.2.0 122 */ 123 IPV6, 124 125 /** 126 * Universal Resource Identifier (RFC 3986). 127 * 128 * @since 9.2.0 129 */ 130 URI, 131 132 /** 133 * URI Reference (RFC 3986). 134 * 135 * @since 9.2.0 136 */ 137 URI_REFERENCE, 138 139 /** 140 * Internationalized Resource Identifier (RFC 3987). 141 * 142 * @since 9.2.0 143 */ 144 IRI, 145 146 /** 147 * IRI Reference (RFC 3987). 148 * 149 * @since 9.2.0 150 */ 151 IRI_REFERENCE, 152 153 /** 154 * Universally Unique Identifier (RFC 4122). 155 * 156 * @since 9.2.0 157 */ 158 UUID, 159 160 /** 161 * URI Template (RFC 6570). 162 * 163 * @since 9.2.0 164 */ 165 URI_TEMPLATE, 166 167 /** 168 * JSON Pointer (RFC 6901). 169 * 170 * @since 9.2.0 171 */ 172 JSON_POINTER, 173 174 /** 175 * Relative JSON Pointer. 176 * 177 * @since 9.2.0 178 */ 179 RELATIVE_JSON_POINTER, 180 181 /** 182 * Regular expression (ECMA-262). 183 * 184 * @since 9.2.0 185 */ 186 REGEX, 187 188 /** 189 * Duration (RFC 3339 Appendix A). 190 * 191 * @since 9.2.0 192 */ 193 DURATION, 194 195 /** 196 * Time (RFC 3339). 197 * 198 * @since 9.2.0 199 */ 200 TIME, 201 202 /** 203 * Date and time with time zone (RFC 3339). 204 * 205 * @since 9.2.0 206 */ 207 DATE_TIME_ZONE, 208 209 /** 210 * Not specified. 211 */ 212 NO_FORMAT; 213 214 /** 215 * Create from lowercase dashed name. 216 * 217 * @param value The enum name. 218 * @return The enum. 219 */ 220 public static HttpPartFormat fromString(String value) { 221 value = value.toUpperCase().replace('-', '_'); 222 return valueOf(value); 223 } 224 225 /** 226 * Returns <jk>true</jk> if this format is in the provided list. 227 * 228 * @param list The list of formats to check against. 229 * @return <jk>true</jk> if this format is in the provided list. 230 */ 231 public boolean isOneOf(HttpPartFormat...list) { 232 for (var ff : list) 233 if (this == ff) 234 return true; 235 return false; 236 } 237 238 @Override /* Overridden from Object */ 239 public String toString() { 240 String s = name().toLowerCase().replace('_', '-'); 241 return s; 242 } 243}