Package org.github.jamm.string

# Class StringMeter

java.lang.Object
org.github.jamm.string.StringMeter

public abstract class StringMeter extends Object
Utility to measure the value field of a `String`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final boolean`
`ENABLED`
Enable or disable string optimization through the `org.github.jamm.string.Optimize` String system property.
`static final long`
`STRING_SHALLOW_SIZE`
The String shallow size stored as a constant to have it compiled directly into the measure method.

## Constructor Summary

Constructors
Constructor
Description
`StringMeter()`

## Method Summary

Modifier and Type
Method
Description
`long`
`measureDeep(MemoryMeterStrategy strategy, String s)`
Measure the deep size of the specified String.
`protected abstract long`
`measureStringValue(MemoryMeterStrategy strategy, String s)`
Measure the size of the value of the specified String.
`static StringMeter`
`newInstance()`
Creates a new `StringMeter` instance.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### ENABLED

public static final boolean ENABLED
Enable or disable string optimization through the `org.github.jamm.string.Optimize` String system property. `true` by default.

### STRING_SHALLOW_SIZE

public static final long STRING_SHALLOW_SIZE
The String shallow size stored as a constant to have it compiled directly into the measure method.

## Constructor Details

### StringMeter

public StringMeter()

## Method Details

### measureDeep

public long measureDeep(MemoryMeterStrategy strategy, String s)
Measure the deep size of the specified String.

Parameters:
  `strategy` - the strategy to perform the measurement
  `s` - the string
Returns:
  the size of the deep string

### measureStringValue

protected abstract long measureStringValue(MemoryMeterStrategy strategy, String s)
Measure the size of the value of the specified String.

Parameters:
  `strategy` - the strategy to perform the measurement
  `s` - the string
Returns:
  the size of the string value field

### newInstance

public static StringMeter newInstance()
Creates a new `StringMeter` instance.

Returns:
  a new `StringMeter` instance.