View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.juneau.httppart;
18  
19  /**
20   * Valid values for the <c>format</c> field.
21   *
22   * <h5 class='section'>See Also:</h5><ul>
23   * 	<li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/HttpPartSerializersParsers">HTTP Part Serializers and Parsers</a>
24   * </ul>
25   */
26  public enum HttpPartFormat {
27  
28  	/**
29  	 * Signed 32 bits.
30  	 */
31  	INT32,
32  
33  	/**
34  	 * Signed 64 bits.
35  	 */
36  	INT64,
37  
38  	/**
39  	 * 32-bit floating point number.
40  	 */
41  	FLOAT,
42  
43  	/**
44  	 * 64-bit floating point number.
45  	 */
46  	DOUBLE,
47  
48  	/**
49  	 * BASE-64 encoded characters.
50  	 */
51  	BYTE,
52  
53  	/**
54  	 * Hexadecimal encoded octets (e.g. <js>"00FF"</js>).
55  	 */
56  	BINARY,
57  
58  	/**
59  	 * Spaced-separated hexadecimal encoded octets (e.g. <js>"00 FF"</js>).
60  	 */
61  	BINARY_SPACED,
62  
63  	/**
64  	 * An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 full-date</a>.
65  	 */
66  	DATE,
67  
68  	/**
69  	 *  An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 date-time</a>.
70  	 */
71  	DATE_TIME,
72  
73  	/**
74  	 * Used to hint UIs the input needs to be obscured.
75  	 */
76  	PASSWORD,
77  
78  	/**
79  	 * UON notation (e.g. <js>"(foo=bar,baz=@(qux,123))"</js>).
80  	 */
81  	UON,
82  
83  	/**
84  	 * Email address (RFC 5321).
85  	 *
86  	 * @since 9.2.0
87  	 */
88  	EMAIL,
89  
90  	/**
91  	 * Internationalized email address (RFC 6531).
92  	 *
93  	 * @since 9.2.0
94  	 */
95  	IDN_EMAIL,
96  
97  	/**
98  	 * Internet host name (RFC 1123).
99  	 *
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 }