com.sun.jini.jeri.internal.http
Class Header

java.lang.Object
  extended by com.sun.jini.jeri.internal.http.Header

 class Header
extends Object

Class representing HTTP message header.

Author:
Sun Microsystems, Inc.

Nested Class Summary
private static class Header.FieldKey
          Field lookup key.
 
Field Summary
private static SimpleDateFormat dateFormat
           
private  Map fields
           
 
Constructor Summary
Header()
          Creates new header with no field entries.
Header(InputStream in)
          Reads in new header from the given input stream.
 
Method Summary
private  void addField(String name, String value)
          Associates additional value with named field.
(package private)  boolean containsValue(String name, String value, boolean ignoreCase)
          Returns true if named field's associated value either contains (as an element of a comma-separated list) or is equal to the given value.
(package private) static String getDateString(long time)
          Returns formatted date string for given time.
(package private)  String getField(String name)
          Returns value associated with named field, or null if field not present in this header.
private static boolean isSpaceOrTab(char c)
           
(package private)  void merge(Header header)
          If given header is non-null, adds its field entries to this header.
(package private)  void setField(String name, String value)
          If given value is non-null, enters it as value of named field; otherwise, removes field (if present) from this header.
(package private)  int size()
          Returns number of field entries in header.
(package private)  void write(OutputStream out)
          Writes header to given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dateFormat

private static final SimpleDateFormat dateFormat

fields

private Map fields
Constructor Detail

Header

Header()
Creates new header with no field entries.


Header

Header(InputStream in)
 throws IOException
Reads in new header from the given input stream.

Throws:
IOException
Method Detail

getField

String getField(String name)
Returns value associated with named field, or null if field not present in this header.


setField

void setField(String name,
              String value)
If given value is non-null, enters it as value of named field; otherwise, removes field (if present) from this header.


containsValue

boolean containsValue(String name,
                      String value,
                      boolean ignoreCase)
Returns true if named field's associated value either contains (as an element of a comma-separated list) or is equal to the given value.


size

int size()
Returns number of field entries in header.


merge

void merge(Header header)
If given header is non-null, adds its field entries to this header. Any overlapping field values are appended to the values in this header with a comma in between.


write

void write(OutputStream out)
     throws IOException
Writes header to given output stream.

Throws:
IOException

getDateString

static String getDateString(long time)
Returns formatted date string for given time.


isSpaceOrTab

private static boolean isSpaceOrTab(char c)

addField

private void addField(String name,
                      String value)
Associates additional value with named field. If the field is already present in this header, the field's value is set to the given value appended to the old value with a comma in between.



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.