Package org.jgroups.util
Class Headers
java.lang.Object
org.jgroups.util.Headers
Open addressing based implementation of a hashmap (not supporting the Map interface though) for message
headers. The keys are strings and the values Headers, and they're stored in an array in the format
key-1 | header-1 | key-2 | header-2. The array is populated from left to right, so any null slots can terminate
an interation, or signal empty slots.
It is assumed that we only have a few headers, 3-4 on average. Note that getting a header for a given key and putting a new key/header are operations with O(n) cost, so this implementation is not recommended for a large number of elements.
This class is not synchronized
It is assumed that we only have a few headers, 3-4 on average. Note that getting a header for a given key and putting a new key/header are operations with O(n) cost, so this implementation is not recommended for a large number of elements.
This class is not synchronized
- Version:
- $Id: Headers.java,v 1.11.2.5 2008/07/31 12:55:23 belaban Exp $
- Author:
- Bela Ban
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
copy()
Returns the header associated with keyObject[]
int
void
Puts a header given a key into the hashmap.putHeaderIfAbsent
(String key, Header hdr) Puts a header given a key into the map, only if the key doesn't exist yetremoveHeader
(String key) Deprecated.Use getHeader() instead.int
size()
toString()
-
Constructor Details
-
Headers
public Headers(int initial_capacity) -
Headers
-
-
Method Details
-
getRawData
-
getHeader
Returns the header associated with key- Parameters:
key
-- Returns:
-
getHeaders
-
printHeaders
-
putHeader
Puts a header given a key into the hashmap. Overwrites potential existing entry. -
putHeaderIfAbsent
Puts a header given a key into the map, only if the key doesn't exist yet- Parameters:
key
-hdr
-- Returns:
- the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)
-
removeHeader
Deprecated.Use getHeader() instead. The issue with removing a header is described in http://jira.jboss.com/jira/browse/JGRP-393- Parameters:
key
-- Returns:
- the header assoaicted with key
-
copy
-
marshalledSize
public int marshalledSize() -
size
public int size() -
capacity
public int capacity() -
printObjectHeaders
-
toString
-