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 */ 018public enum HttpPartFormat { 019 020 /** 021 * Signed 32 bits. 022 */ 023 INT32, 024 025 /** 026 * Signed 64 bits. 027 */ 028 INT64, 029 030 /** 031 * 32-bit floating point number. 032 */ 033 FLOAT, 034 035 /** 036 * 64-bit floating point number. 037 */ 038 DOUBLE, 039 040 /** 041 * BASE-64 encoded characters. 042 */ 043 BYTE, 044 045 /** 046 * Hexadecimal encoded octets (e.g. <js>"00FF"</js>). 047 */ 048 BINARY, 049 050 /** 051 * Spaced-separated hexadecimal encoded octets (e.g. <js>"00 FF"</js>). 052 */ 053 BINARY_SPACED, 054 055 /** 056 * An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 full-date</a>. 057 */ 058 DATE, 059 060 /** 061 * An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 date-time</a>. 062 */ 063 DATE_TIME, 064 065 /** 066 * Used to hint UIs the input needs to be obscured. 067 */ 068 PASSWORD, 069 070 /** 071 * UON notation (e.g. <js>"(foo=bar,baz=@(qux,123))"</js>). 072 */ 073 UON, 074 075 /** 076 * Not specified. 077 */ 078 NO_FORMAT; 079 080 /** 081 * Create from lowercase dashed name. 082 * 083 * @param value The enum name. 084 * @return The enum. 085 */ 086 public static HttpPartFormat fromString(String value) { 087 value = value.toUpperCase().replace('-','_'); 088 return valueOf(value); 089 } 090 091 /** 092 * Returns <jk>true</jk> if this format is in the provided list. 093 * 094 * @param list The list of formats to check against. 095 * @return <jk>true</jk> if this format is in the provided list. 096 */ 097 public boolean isOneOf(HttpPartFormat...list) { 098 for (HttpPartFormat ff : list) 099 if (this == ff) 100 return true; 101 return false; 102 } 103 104 @Override /* Object */ 105 public String toString() { 106 String s = name().toLowerCase().replace('_','-'); 107 return s; 108 } 109}