Class Indenter.Cache

java.lang.Object
org.simpleframework.xml.stream.Indenter.Cache
Enclosing class:
Indenter

private static class Indenter.Cache extends Object
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
    Modifier and Type
    Field
    Description
    private int
    Represents the number of indent strings held by the cache.
    private String[]
    This is used to track indent strings within the cache.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Cache(int size)
    Constructor for the Cache object.
  • Method Summary

    Modifier and Type
    Method
    Description
    get(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
    set(int index, String text)
    This method is used to add the specified indent on to the cache.
    int
    This method is used to retrieve the number of indents that have been added to the cache.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • list

      private String[] list
      This is used to track indent strings within the cache.
    • count

      private int count
      Represents the number of indent strings held by the cache.
  • Constructor Details

    • Cache

      public Cache(int size)
      Constructor for the Cache 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

      public void set(int index, String text)
      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 to
      text - this is the indent to add to the position
    • get

      public String get(int index)
      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