Package org.simpleframework.xml.stream
Class Indenter.Cache
java.lang.Object
org.simpleframework.xml.stream.Indenter.Cache
- Enclosing class:
Indenter
The
Cache
object is used create an indexable list
which allows the indenter to quickly acquire an indent using
a stack position. This ensures that the indenter need only
create an index once for a given stack position. The number of
indents held within this cache can also be tracked.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget
(int index) This method is used to retrieve an indent from the given position.private void
resize
(int size) Should the number of indents to be cache grows larger than the default initial size then this will increase the size of the cache.void
This method is used to add the specified indent on to the cache.int
size()
This method is used to retrieve the number of indents that have been added to the cache.
-
Field Details
-
list
This is used to track indent strings within the cache. -
count
private int countRepresents the number of indent strings held by the cache.
-
-
Constructor Details
-
Cache
public Cache(int size) Constructor for theCache
object. This creates a cache of the specified size, the specified size acts as an initial size and the cache can be expanded on demand.- Parameters:
size
- the initial number of entries in the cache
-
-
Method Details
-
size
public int size()This method is used to retrieve the number of indents that have been added to the cache. This is used to determine if an indent request is the first.- Returns:
- this returns the number of indents in the cache
-
set
This method is used to add the specified indent on to the cache. The index allows the cache to act as a stack, when the index is specified it can be used to retrieve the same indent using that index.- Parameters:
index
- this is the position to add the index totext
- this is the indent to add to the position
-
get
This method is used to retrieve an indent from the given position. This allows the indenter to use the cache as a stack, by increasing and decreasing the index as required.- Parameters:
index
- the position to retrieve the indent from- Returns:
- this is the indent retrieve from the given index
-
resize
private void resize(int size) Should the number of indents to be cache grows larger than the default initial size then this will increase the size of the cache. This ensures that the indenter can handle an arbitrary number of indents for a given output.- Parameters:
size
- this is the size to expand the cache to
-