junit.extensions.xml
Class XMLObjectCache

java.lang.Object
  extended byjunit.extensions.xml.XMLObjectCache
Direct Known Subclasses:
XMLPropertyCache

public class XMLObjectCache
extends java.lang.Object

Title: XMLObjectCache

Description: Multi level hashmap to contain name value pairs. A parent level can be explicitly accessed by prefixing the name with "../" otherwise the parent level will only be searched if the object does not exist at the current level.

Copyright: Copyright (c) 2003

Company: jfcunit project

Version:
1.0
Author:
Kevin Wilson

Field Summary
private  java.util.HashMap m_map
          Internal hashmap used to hold the property/procedure mappings.
private  XMLObjectCache m_parent
          The parent XMLObjectCache.
 
Constructor Summary
XMLObjectCache()
          Empty contructor.
XMLObjectCache(XMLObjectCache parent)
          Constructor.
 
Method Summary
 void clear()
          Clear the cache.
 java.lang.Object get(java.lang.String name)
          Get a object from the cache.
 java.lang.String getName(java.lang.Object value)
          Do a reverse lookup of a mapping.
 java.lang.String[] getNames()
          Get all of the names of the objects currently in the cache.
 XMLObjectCache getParent()
          Get the parent object cache.
 void put(java.lang.String name, java.lang.Object value)
          Put a new mapping into the cache.
 void remove(java.lang.String name)
          Remove the object from the cache.
 void setParent(XMLObjectCache parent)
          Set the parent object cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_map

private final java.util.HashMap m_map
Internal hashmap used to hold the property/procedure mappings.


m_parent

private XMLObjectCache m_parent
The parent XMLObjectCache.

Constructor Detail

XMLObjectCache

public XMLObjectCache()
Empty contructor. Parent is assumed to be null. It can be set at a later time.


XMLObjectCache

public XMLObjectCache(XMLObjectCache parent)
Constructor.

Parameters:
parent - Parent object cache to be set.
Method Detail

getName

public final java.lang.String getName(java.lang.Object value)
Do a reverse lookup of a mapping. Return the name of a object based upon the value.

Parameters:
value - Value to return the name for.
Returns:
The first matching name is returned.

getNames

public final java.lang.String[] getNames()
Get all of the names of the objects currently in the cache. Parent objects will be prefixed with the ../

Returns:
list of names.

setParent

public final void setParent(XMLObjectCache parent)
Set the parent object cache.

Parameters:
parent - Parent object cache to be traversed by get and explicitly traversed by put/remove.

getParent

public final XMLObjectCache getParent()
Get the parent object cache.

Returns:
Parent object cache.

clear

public final void clear()
Clear the cache.


put

public final void put(java.lang.String name,
                      java.lang.Object value)
Put a new mapping into the cache. If the name starts with ../ then place the object in the parent cache.

Parameters:
name - Name of the property or procedure.
value - Value of the property or procedure.

remove

public final void remove(java.lang.String name)
Remove the object from the cache. If the name starts with ../ then propagate the remove to the parent.

Parameters:
name - Name of the object in the cache.

get

public java.lang.Object get(java.lang.String name)
Get a object from the cache. If the object does not exist in the cache then try the parent cache. If a parent cache does not exist then try the System properties.

Parameters:
name - Name of the value to be retrieved.
Returns:
Return the value.


Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999