/*
(non-Javadoc)

@see io.pkts.packet.sip.SipPacket#getHeader(java.lang.String)
541388
@Override
    public Optional<SipHeader> getHeader(final String headerName) throws SipPacketParseException {
        return this.msg.getHeader(headerName);
    }
1323269
public <R> R getHeader(String name, R defaultValue) {
        if (headers().contains(name)) {
            return getHeader(name);
        } else {
            return defaultValue;
        }
    }
537210
public HeaderEntry getHeader(String name) {
        for (HeaderEntry headerField : getHeaderEntries()) {
            if (headerField.getName().equals(name)) {
                return headerField;
            }
        }
        return null;
    }
1351905
public String getHeaderField(String fieldName) {
        // headers map is null for all regular response calls except when made as a batch request
        if (this.headers == null) {
            if (this.connection != null) {
                return this.connection.getHeaderField(fieldName);
            } else {
                return null;
            }
        } else {
            return this.headers.get(fieldName);
        }
    }
1374231
@Nullable
  public String getHeader (@Nullable final String sName)
  {
    final ICommonsOrderedSet <String> aSet = m_aHeaders.get (_unifyHeaderName (sName));
    return aSet == null ? null : aSet.getFirst ();
  }
744738
public java.lang.String getHeaderClass() {
        return (java.lang.String) getStateHelper().eval(PropertyKeys.headerClass);

    }
278807
public String getHeader(String headerName) {
        List<String> headers = null;
        for (String h : headers().keySet()) {
            if (headerName.equalsIgnoreCase(h)) {
                headers = headers().get(h);
                break;
            }
        }
        if (headers == null || headers.isEmpty()) {
            return null;
        }
        return headers.get(0);
    }
1126491
@Override
    public String getHeader(String header) {
        if (isSystemBundleProvider) {
            if (FeatureDefinitionUtils.IBM_API_PACKAGE.equals(header))
                return generateHeaderFromDefinitions("IBM-MergedApiPackage", sysPkgApiHeader);
            if (FeatureDefinitionUtils.IBM_SPI_PACKAGE.equals(header))
                return generateHeaderFromDefinitions("IBM-MergedSpiPackage", sysPkgSpiHeader);
        }
        return super.getHeader(header);
    }
414473
@SuppressWarnings("unchecked")
	public Address getAddressHeader(String name) throws ServletParseException {
		if (name == null)
			throw new NullPointerException();

		String hName = getFullHeaderName(name);

		if (logger.isDebugEnabled())
			logger.debug("Fetching address header for name [" + hName + "]");

//		if (!isAddressTypeHeader(hName)) {
//			logger.error("Header of name [" + hName
//					+ "] is not address type header!!!");
//			throw new ServletParseException("Header of type [" + hName
//					+ "] cant be parsed to address, wrong content type!!!");
//		}
		String nameToSearch = getCorrectHeaderName(hName);
		ListIterator<Header> headers = (ListIterator<Header>) this.message
				.getHeaders(nameToSearch);
		ListIterator<Header> lit = headers;

		if (lit != null && lit.hasNext()) {
			Header first = lit.next();
			if (first instanceof HeaderAddress) {
				try {
					if(this.isCommitted()) {
						return new AddressImpl((HeaderAddress) first, ModifiableRule.NotModifiable);
					} else {
						return new AddressImpl((HeaderAddress) first, getModifiableRule(hName));
					}
				} catch (ParseException e) {
					throw new ServletParseException("Bad address " + first);
				}
			} else {
				Parameterable parametrable = createParameterable(first, first.getName(), message instanceof Request);
				try {
					logger.debug("parametrable Value " + parametrable.getValue());
					if(this.isCommitted()) {
						return new AddressImpl(SipFactoryImpl.addressFactory.createAddress(parametrable.getValue()), ((ParameterableHeaderImpl)parametrable).getInternalParameters(), ModifiableRule.NotModifiable);
					} else {
						return new AddressImpl(SipFactoryImpl.addressFactory.createAddress(parametrable.getValue()), ((ParameterableHeaderImpl)parametrable).getInternalParameters(), getModifiableRule(hName));
					}
				} catch (ParseException e) {
					throw new ServletParseException("Impossible to parse the following header " + name + " as an address.", e);
				}
			}
		}
		return null;

	}
102285
public Address getTo() {
		ToHeader to = (ToHeader) this.message
			.getHeader(getCorrectHeaderName(ToHeader.NAME));
		// return new AddressImpl(to.getAddress(), AddressImpl.getParameters((Parameters)to), ModifiableRule.To);
		// https://code.google.com/p/sipservlets/issues/detail?id=245
		try {
            return new AddressImpl(to, ModifiableRule.From);
        } catch (ParseException e) {
            throw new IllegalArgumentException("Couldn't parse From Header " + to, e);
        }
	}
363508
@Override
    public int getHeaderLength() {
        try {
            final byte b = this.headers.getByte(0);
            // length is encoded as the number of 32-bit words, so to get number of bytes we must multiply by 4
            return (b & 0x0F) * 4;
        } catch (final IOException e) {
            throw new RuntimeException("unable to get the header length of the IP packet due to IOException", e);
        }
    }
1182605
public Object getFirstHeader( String name )
    {
        List foundHeaders = ( List ) _headers.get( name );
        return ! foundHeaders.isEmpty() ? foundHeaders.get( 0 ) : null;
    }
733059
@Override public final String getHeaderField(int position) {
    try {
      return getHeaders().value(position);
    } catch (IOException e) {
      return null;
    }
  }
674580
@Nullable
    public String getHeader(String name) {
        requireNonNull(name);
        List<String> values = lazyMap.get().get(name.toLowerCase());
        if (values == null) {
            return null;
        }
        return values.get(0);
    }
601522
public String getHeader()
    {
        if (this.header == null)
        {
            if (this.headerKeys == null)
            {
                this.headerKeys = new String[2];
                this.headerKeys[0] = getPropertyName() + ".header";
                this.headerKeys[1] = getPropertyName();
            }
            this.header = ValkyrieRepository.getInstance().getApplicationConfig().messageResolver().getMessage(new DefaultMessageSourceResolvable(this.headerKeys, null,
                    this.headerKeys[this.headerKeys.length - 1]));
        }
        // JTableHeader has a reusable defaultHeaderRenderer on which the default height must be correct.
        // when painting, the columns headers are processed in order and height is being calculated, 
        // if label is null or empty string header height is 4 and thus leaves us with a very small
        // table-header, fix this by returning a space (-> font-size is incorporated)
        return "".equals(this.header) ? " " : this.header;
    }
803974
function GetHeadersPacket(locator, stop) {
  if (!(this instanceof GetHeadersPacket))
    return new GetHeadersPacket(locator, stop);

  GetBlocksPacket.call(this, locator, stop);
}
735201
public java.lang.String getHttpHeader() {
    java.lang.Object ref = httpHeader_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      httpHeader_ = s;
      return s;
    }
  }