Openfire 3.4.1 Javadoc

org.jivesoftware.util.cache
Class CacheSizes

java.lang.Object
  extended by org.jivesoftware.util.cache.CacheSizes

public class CacheSizes
extends Object

Utility class for determining the sizes in bytes of commonly used objects. Classes implementing the Cacheable interface should use this class to determine their size.

Author:
Matt Tucker

Constructor Summary
CacheSizes()
           
 
Method Summary
static int sizeOfBoolean()
          Returns the size in bytes of a primitive boolean.
static int sizeOfChar()
          Returns the size in bytes of a primitive char.
static int sizeOfCollection(Collection list)
          Returns the size in bytes of a Collection object.
static int sizeOfDate()
          Returns the size in bytes of a Date.
static int sizeOfDouble()
          Returns the size in bytes of a primitive double.
static int sizeOfInt()
          Returns the size in bytes of a primitive int.
static int sizeOfLong()
          Returns the size in bytes of a primitive long.
static int sizeOfMap(Map map)
          Returns the size in bytes of a Map object.
static int sizeOfObject()
          Returns the size in bytes of a basic Object.
static int sizeOfString(String string)
          Returns the size in bytes of a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheSizes

public CacheSizes()
Method Detail

sizeOfObject

public static int sizeOfObject()
Returns the size in bytes of a basic Object. This method should only be used for actual Object objects and not classes that extend Object.

Returns:
the size of an Object.

sizeOfString

public static int sizeOfString(String string)
Returns the size in bytes of a String.

Parameters:
string - the String to determine the size of.
Returns:
the size of a String.

sizeOfInt

public static int sizeOfInt()
Returns the size in bytes of a primitive int.

Returns:
the size of a primitive int.

sizeOfChar

public static int sizeOfChar()
Returns the size in bytes of a primitive char.

Returns:
the size of a primitive char.

sizeOfBoolean

public static int sizeOfBoolean()
Returns the size in bytes of a primitive boolean.

Returns:
the size of a primitive boolean.

sizeOfLong

public static int sizeOfLong()
Returns the size in bytes of a primitive long.

Returns:
the size of a primitive long.

sizeOfDouble

public static int sizeOfDouble()
Returns the size in bytes of a primitive double.

Returns:
the size of a primitive double.

sizeOfDate

public static int sizeOfDate()
Returns the size in bytes of a Date.

Returns:
the size of a Date.

sizeOfMap

public static int sizeOfMap(Map map)
Returns the size in bytes of a Map object. All keys and values must be Strings.

Parameters:
map - the Map object to determine the size of.
Returns:
the size of the Map object.

sizeOfCollection

public static int sizeOfCollection(Collection list)
Returns the size in bytes of a Collection object. Elements are assumed to be Strings, Longs or Cacheable objects.

Parameters:
list - the Collection object to determine the size of.
Returns:
the size of the Collection object.

Openfire 3.4.1 Javadoc

Copyright © 2003-2007 Jive Software.