001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.httppart; 014 015/** 016 * Valid values for the <c>format</c> field. 017 * 018 * <h5 class='section'>See Also:</h5><ul> 019 * <li class='link'><a class="doclink" href="../../../../index.html#jm.HttpPartSerializersParsers">HTTP Part Serializers and Parsers</a> 020 * </ul> 021 */ 022public enum HttpPartFormat { 023 024 /** 025 * Signed 32 bits. 026 */ 027 INT32, 028 029 /** 030 * Signed 64 bits. 031 */ 032 INT64, 033 034 /** 035 * 32-bit floating point number. 036 */ 037 FLOAT, 038 039 /** 040 * 64-bit floating point number. 041 */ 042 DOUBLE, 043 044 /** 045 * BASE-64 encoded characters. 046 */ 047 BYTE, 048 049 /** 050 * Hexadecimal encoded octets (e.g. <js>"00FF"</js>). 051 */ 052 BINARY, 053 054 /** 055 * Spaced-separated hexadecimal encoded octets (e.g. <js>"00 FF"</js>). 056 */ 057 BINARY_SPACED, 058 059 /** 060 * An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 full-date</a>. 061 */ 062 DATE, 063 064 /** 065 * An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 date-time</a>. 066 */ 067 DATE_TIME, 068 069 /** 070 * Used to hint UIs the input needs to be obscured. 071 */ 072 PASSWORD, 073 074 /** 075 * UON notation (e.g. <js>"(foo=bar,baz=@(qux,123))"</js>). 076 */ 077 UON, 078 079 /** 080 * Not specified. 081 */ 082 NO_FORMAT; 083 084 /** 085 * Create from lowercase dashed name. 086 * 087 * @param value The enum name. 088 * @return The enum. 089 */ 090 public static HttpPartFormat fromString(String value) { 091 value = value.toUpperCase().replace('-','_'); 092 return valueOf(value); 093 } 094 095 /** 096 * Returns <jk>true</jk> if this format is in the provided list. 097 * 098 * @param list The list of formats to check against. 099 * @return <jk>true</jk> if this format is in the provided list. 100 */ 101 public boolean isOneOf(HttpPartFormat...list) { 102 for (HttpPartFormat ff : list) 103 if (this == ff) 104 return true; 105 return false; 106 } 107 108 @Override /* Object */ 109 public String toString() { 110 String s = name().toLowerCase().replace('_','-'); 111 return s; 112 } 113}