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

## org.pentaho.di.core.xml
Class XMLHandlerCache

    java.lang.Object
      org.pentaho.di.core.xml.XMLHandlerCache

    public class XMLHandlerCache

extends Object

Singleton to help speed up lookups in an XML DOM tree.
The theory is that you often loop over occurrences of a certain tag in a Node.
If there are 20 occurrences, you go from index 0..19.
Every time we do the following
- found node 0
- found node 0, 1
- found node 0, 1, 2
- ...
So the time to search node index 19 is 20 times larger on average then index 0.
We can solve this by caching the position of index 18 and by starting back at that position.
This class is a singleton to keep everyting 100% compatible with the rest of the codebase.

Since:
  22-Apr-2006
Author:
  Matt

Field Summary
`static int` | `MAX_NUMBER_OF_ENTRIES`

Method Summary
`void` | `clear()` Clears the cache
`int` | `getCacheHits()`
`static XMLHandlerCache` | `getInstance()`
`int` | `getLastChildNr(XMLHandlerCacheEntry entry)` Retrieve the last child were we left off...
`void` | `setCacheHits(int cacheHits)` Allows you to (re-)set the number of cache hits
`void` | `storeCache(XMLHandlerCacheEntry entry, int lastChildNr)` Store a cache entry

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MAX_NUMBER_OF_ENTRIES

    public static final int MAX_NUMBER_OF_ENTRIES

See Also:
  Constant Field Values

Method Detail

### getInstance

    public static final XMLHandlerCache getInstance()

### storeCache

    public void storeCache(XMLHandlerCacheEntry entry,
                           int lastChildNr)

  Store a cache entry

  Parameters:
    `entry` - The cache entry to store

### getLastChildNr

    public int getLastChildNr(XMLHandlerCacheEntry entry)

  Retrieve the last child were we left off...

  Parameters:
    `entry` - The cache entry to look for.
  Returns:
    the last child position or -1 if nothing was found.

### getCacheHits

    public int getCacheHits()

  Returns:
    the number of cache hits for your statistical pleasure.

### setCacheHits

    public void setCacheHits(int cacheHits)

  Allows you to (re-)set the number of cache hits

  Parameters:
    `cacheHits` - the number of cache hits.

### clear

    public void clear()

  Clears the cache

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