Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tomcat.util.http
Class MimeHeaders

    java.lang.Object
      org.apache.tomcat.util.http.MimeHeaders

public class MimeHeaders
extends java.lang.Object

Memory-efficient repository for Mime Headers. When the object is recycled, it will keep the allocated headers[] and all the MimeHeaderField - no GC is generated. For input headers it is possible to use the MessageByte for Fileds - so no GC will be generated. The only garbage is generated when using the String for header names/values - this can't be avoided when the servlet calls header methods, but is easy to avoid inside tomcat. The goal is to use _only_ MessageByte-based Fields, and reduce to 0 the memory overhead of tomcat. TODO: XXX one-buffer parsing - for http ( other protocols don't need that ) XXX remove unused methods XXX External enumerations, with 0 GC. XXX use HeaderName ID

Author:
  dac@eng.sun.com, James Todd [gonzo@eng.sun.com], Costin Manolache, kevin seguin

Field Summary
`static int` | `DEFAULT_HEADER_SIZE` Initial size - should be == average number of headers per request XXX make it configurable ( fine-tuning of web-apps )

Constructor Summary
`MimeHeaders()` Creates a new MimeHeaders object using a default buffer size.

Method Summary
`MessageBytes` | `addValue(byte[] b, int startN, int len)` Create a new named header using un-translated byte[].
`MessageBytes` | `addValue(char[] c, int startN, int len)` Create a new named header using translated char[].
`MessageBytes` | `addValue(java.lang.String name)` Create a new named header , return the MessageBytes container for the new value
`void` | `clear()` Clears all header fields.
`int` | `findHeader(java.lang.String name, int starting)` Find the index of a header with the given name.
`java.lang.String` | `getHeader(java.lang.String name)`
`MessageBytes` | `getName(int n)` Returns the Nth header name, or null if there is no such header.
`MessageBytes` | `getValue(int n)` Returns the Nth header value, or null if there is no such header.
`MessageBytes` | `getValue(java.lang.String name)` Finds and returns a header field with the given name.
`java.util.Enumeration` | `names()` Returns an enumeration of strings representing the header field names.
`void` | `recycle()` Clears all header fields.
`void` | `removeHeader(java.lang.String name)` Removes a header field with the specified name.
`MessageBytes` | `setValue(java.lang.String name)` Allow "set" operations - return a MessageBytes container for the header value ( existing header or new if this .
`int` | `size()` Returns the current number of header fields.
`java.lang.String` | `toString()` EXPENSIVE!!!
`java.util.Enumeration` | `values(java.lang.String name)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### DEFAULT_HEADER_SIZE

    public static final int DEFAULT_HEADER_SIZE

  Initial size - should be == average number of headers per request XXX make it configurable ( fine-tuning of web-apps )

  See Also:
    Constant Field Values

Constructor Detail

### MimeHeaders

    public MimeHeaders()

  Creates a new MimeHeaders object using a default buffer size.

Method Detail

### recycle

    public void recycle()

  Clears all header fields.

### clear

    public void clear()

  Clears all header fields.

### toString

    public java.lang.String toString()

  EXPENSIVE!!! only for debugging.

### size

    public int size()

  Returns the current number of header fields.

### getName

    public MessageBytes getName(int n)

  Returns the Nth header name, or null if there is no such header. This may be used to iterate through all header fields.

### getValue

    public MessageBytes getValue(int n)

  Returns the Nth header value, or null if there is no such header. This may be used to iterate through all header fields.

### findHeader

    public int findHeader(java.lang.String name,
                          int starting)

  Find the index of a header with the given name.

### names

    public java.util.Enumeration names()

  Returns an enumeration of strings representing the header field names. Field names may appear multiple times in this enumeration, indicating that multiple fields with that name exist in this header.

### values

    public java.util.Enumeration values(java.lang.String name)

### addValue

    public MessageBytes addValue(java.lang.String name)

  Create a new named header , return the MessageBytes container for the new value

### addValue

    public MessageBytes addValue(byte[] b,
                                 int startN,
                                 int len)

  Create a new named header using un-translated byte[]. The conversion to chars can be delayed until encoding is known.

### addValue

    public MessageBytes addValue(char[] c,
                                 int startN,
                                 int len)

  Create a new named header using translated char[].

### setValue

    public MessageBytes setValue(java.lang.String name)

  Allow "set" operations - return a MessageBytes container for the header value ( existing header or new if this .

### getValue

    public MessageBytes getValue(java.lang.String name)

  Finds and returns a header field with the given name. If no such field exists, null is returned. If more than one such field is in the header, an arbitrary one is returned.

### getHeader

    public java.lang.String getHeader(java.lang.String name)

### removeHeader

    public void removeHeader(java.lang.String name)

  Removes a header field with the specified name. Does nothing if such a field could not be found.

  Parameters:
    `name` - the name of the header field to be removed

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.