Well ok, it doesn't actually do any conversion. The converter uses by default a map with weak references to reuse instances of strings that do not exceed a length limit. This limit is by default 38 characters to cache typical strings containing UUIDs. Only shorter strings are typically repeated more often in XML values.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | cache
A Map to store strings as long as needed to map similar strings onto the same instance and conserve memory. |
| private static final int | |
| private final int |
| Access | Constructor and Description |
|---|---|
| public | StringConverter(final Map<K, V>
the map to use for the instances to reuse (may be null to not cache at all) map, int maximum string length of a cached string, -1 to cache all, 0 to turn off the cache lengthLimit)Construct a StringConverter using a map-based cache for strings not exceeding the length limit. |
| public | StringConverter(final Map<K, V>
the map to use for the instances to reuse (may be null to not cache at all) map)Construct a StringConverter using a map-based cache for strings not exceeding 38 characters. |
| public | StringConverter(int
maximum string length of a cached string, -1 to cache all, 0 to turn off the cache lengthLimit)Construct a StringConverter using a cache with weak references for strings not exceeding the length limit. |
| public | StringConverter()
Construct a StringConverter using a cache with weak references for strings not exceeding 38 characters. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | canConvert(final Class<T>
the Class representing the object type to be converted type)Implements abstract com. Implements com. |
| public Object | fromString(final String
the String with the single value of the Object str)Implements abstract com. Implements com. |
| cache | back to summary |
|---|---|
| private final Map<K, V> cache A Map to store strings as long as needed to map similar strings onto the same instance and conserve memory. The map can be set from the outside during construction, so it can be a LRU map or a weak map, synchronised or not. | |
| LENGTH_LIMIT | back to summary |
|---|---|
| private static final int LENGTH_LIMIT | |
| lengthLimit | back to summary |
|---|---|
| private final int lengthLimit | |
| StringConverter | back to summary |
|---|---|
| public StringConverter(final Map<K, V> map, int lengthLimit) Construct a StringConverter using a map-based cache for strings not exceeding the length limit.
| |
| StringConverter | back to summary |
|---|---|
| public StringConverter(final Map<K, V> map) Construct a StringConverter using a map-based cache for strings not exceeding 38 characters.
| |
| StringConverter | back to summary |
|---|---|
| public StringConverter(int lengthLimit) Construct a StringConverter using a cache with weak references for strings not exceeding the length limit.
| |
| StringConverter | back to summary |
|---|---|
| public StringConverter() Construct a StringConverter using a cache with weak references for strings not exceeding 38 characters. | |
| canConvert | back to summary |
|---|---|
| public boolean canConvert(final Class<T> type) Implements abstract com. Implements com. Doc from com. Determines whether the converter can marshall a particular type.
| |
| fromString | back to summary |
|---|---|
| public Object fromString(final String str) Implements abstract com. Implements com. Doc from com. Unmarshals an Object from its single value representation. | |