org.cybergarage.http

## Class HTTPHeader

- java.lang.Object
- - org.cybergarage.http.HTTPHeader

-     public class HTTPHeader
      extends Object

  Represents an HTTP header field with a name and value. This class provides methods to parse, manipulate, and extract HTTP headers from various data sources including strings, byte arrays, and readers.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HTTPHeader(String lineStr)` Creates a new HTTPHeader by parsing a header line string.
    `HTTPHeader(String name, String value)` Creates a new HTTPHeader with the specified name and value.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `getIntegerValue(byte[] data, String name)` Extracts the integer value of a header with the specified name from a byte array.
    `static int` | `getIntegerValue(String data, String name)` Extracts the integer value of a header with the specified name from a string.
    `String` | `getName()` Gets the header name.
    `String` | `getValue()` Gets the header value.
    `static String` | `getValue(byte[] data, String name)` Extracts the value of a header with the specified name from a byte array.
    `static String` | `getValue(LineNumberReader reader, String name)` Reads from a LineNumberReader to find the value of a header with the specified name.
    `static String` | `getValue(String data, String name)` Extracts the value of a header with the specified name from a string.
    `boolean` | `hasName()` Checks if this header has a valid name.
    `void` | `setName(String name)` Sets the header name.
    `void` | `setValue(String value)` Sets the header value.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HTTPHeader

          public HTTPHeader(String lineStr)

      Creates a new HTTPHeader by parsing a header line string. The line should be in the format "Name: Value".
      Parameters:
        `lineStr` - the header line to parse

    - #### HTTPHeader

          public HTTPHeader(String name,
                            String value)

      Creates a new HTTPHeader with the specified name and value.
      Parameters:
        `name` - the header name
        `value` - the header value

  - ### Method Detail

    - #### getIntegerValue

          public static final int getIntegerValue(byte[] data,
                                                  String name)

      Extracts the integer value of a header with the specified name from a byte array.
      Parameters:
        `data` - the byte array containing HTTP headers
        `name` - the name of the header to find
      Returns:
        the header value as an integer, or 0 if not found or invalid

    - #### getIntegerValue

          public static final int getIntegerValue(String data,
                                                  String name)

      Extracts the integer value of a header with the specified name from a string.
      Parameters:
        `data` - the string containing HTTP headers
        `name` - the name of the header to find
      Returns:
        the header value as an integer, or 0 if not found or invalid

    - #### getName

          public String getName()

      Gets the header name.
      Returns:
        the header name

    - #### getValue

          public String getValue()

      Gets the header value.
      Returns:
        the header value

    - #### getValue

          public static final String getValue(byte[] data,
                                              String name)

      Extracts the value of a header with the specified name from a byte array. The search is case-insensitive.
      Parameters:
        `data` - the byte array containing HTTP headers
        `name` - the name of the header to find
      Returns:
        the header value, or empty string if not found

    - #### getValue

          public static final String getValue(LineNumberReader reader,
                                              String name)

      Reads from a LineNumberReader to find the value of a header with the specified name. The search is case-insensitive.
      Parameters:
        `reader` - the LineNumberReader to read from
        `name` - the name of the header to find
      Returns:
        the header value, or empty string if not found

    - #### getValue

          public static final String getValue(String data,
                                              String name)

      Extracts the value of a header with the specified name from a string. The search is case-insensitive.
      Parameters:
        `data` - the string containing HTTP headers
        `name` - the name of the header to find
      Returns:
        the header value, or empty string if not found

    - #### hasName

          public boolean hasName()

      Checks if this header has a valid name.
      Returns:
        true if the header has a non-null, non-empty name

    - #### setName

          public void setName(String name)

      Sets the header name.
      Parameters:
        `name` - the header name to set

    - #### setValue

          public void setValue(String value)

      Sets the header value.
      Parameters:
        `value` - the header value to set