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

## org.jivesoftware.util.cache
Class CacheSizes

    java.lang.Object
      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` | `sizeOfAnything(Object object)` Returns the size of an object in bytes.
`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)
                         throws CannotCalculateSizeException

  Returns the size in bytes of a Map object.

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

### sizeOfCollection

    public static int sizeOfCollection(Collection list)
                                throws CannotCalculateSizeException

  Returns the size in bytes of a Collection object. Elements are assumed to be `String`s, `Long`s or `Cacheable` objects.

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

### sizeOfAnything

    public static int sizeOfAnything(Object object)
                              throws CannotCalculateSizeException

  Returns the size of an object in bytes. Determining size by serialization is only used as a last resort.

  Returns:
    the size of an object in bytes.
  Throws:
    `CannotCalculateSizeException`

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

Copyright © 2003-2008 Jive Software.