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.commons.http;
018
019import static org.apache.juneau.commons.utils.Shorts.*;
020
021/**
022 * Represents a parsed element from an HTTP header value.
023 *
024 * <p>
025 * An element consists of a name and zero or more parameters, as defined by RFC 2616.
026 * For example, in the header value <js>"text/html;charset=UTF-8;q=0.9"</js>, the element
027 * name is <js>"text/html"</js> and the parameters are <js>"charset=UTF-8"</js> and <js>"q=0.9"</js>.
028 */
029public class HeaderElement {
030
031   private final String name;
032   private final NameValuePair[] parameters;
033
034   /**
035    * Constructor.
036    *
037    * @param name The element name.
038    * @param parameters The element parameters.
039    */
040   public HeaderElement(String name, NameValuePair... parameters) {
041      this.name = name;
042      this.parameters = parameters;
043   }
044
045   /**
046    * Returns the element name.
047    *
048    * @return The element name, never <jk>null</jk>.
049    */
050   public String getName() {
051      return name;
052   }
053
054   /**
055    * Returns the element parameters.
056    *
057    * @return The parameters array, never <jk>null</jk>.
058    */
059   public NameValuePair[] getParameters() {
060      return cp(parameters);
061   }
062}