001/* 002 * ==================================================================== 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 * ==================================================================== 020 * 021 * This software consists of voluntary contributions made by many 022 * individuals on behalf of the Apache Software Foundation. For more 023 * information on the Apache Software Foundation, please see 024 * <http://www.apache.org/>. 025 * 026 */ 027 028package org.apache.http; 029 030/** 031 * One element of an HTTP {@link Header header} value consisting of 032 * a name / value pair and a number of optional name / value parameters. 033 * <p> 034 * Some HTTP headers (such as the set-cookie header) have values that 035 * can be decomposed into multiple elements. Such headers must be in the 036 * following form: 037 * </p> 038 * <pre> 039 * header = [ element ] *( "," [ element ] ) 040 * element = name [ "=" [ value ] ] *( ";" [ param ] ) 041 * param = name [ "=" [ value ] ] 042 * 043 * name = token 044 * value = ( token | quoted-string ) 045 * 046 * token = 1*<any char except "=", ",", ";", <"> and 047 * white space> 048 * quoted-string = <"> *( text | quoted-char ) <"> 049 * text = any char except <"> 050 * quoted-char = "\" char 051 * </pre> 052 * <p> 053 * Any amount of white space is allowed between any part of the 054 * header, element or param and is ignored. A missing value in any 055 * element or param will be stored as the empty {@link String}; 056 * if the "=" is also missing <var>null</var> will be stored instead. 057 * 058 * @since 4.0 059 */ 060public interface HeaderElement { 061 062 /** 063 * Returns header element name. 064 * 065 * @return header element name 066 */ 067 String getName(); 068 069 /** 070 * Returns header element value. 071 * 072 * @return header element value 073 */ 074 String getValue(); 075 076 /** 077 * Returns an array of name / value pairs. 078 * 079 * @return array of name / value pairs 080 */ 081 NameValuePair[] getParameters(); 082 083 /** 084 * Returns the first parameter with the given name. 085 * 086 * @param name parameter name 087 * 088 * @return name / value pair 089 */ 090 NameValuePair getParameterByName(String name); 091 092 /** 093 * Returns the total count of parameters. 094 * 095 * @return parameter count 096 */ 097 int getParameterCount(); 098 099 /** 100 * Returns parameter with the given index. 101 * 102 * @param index index 103 * @return name / value pair 104 */ 105 NameValuePair getParameter(int index); 106 107} 108