org.xanot.util
Class StackMap<SK,SV>

java.lang.Object
  extended by org.xanot.util.StackMap<SK,SV>

public class StackMap<SK,SV>
extends java.lang.Object

A stack that support object to object mapping.

Author:
Ferdinand Neman (newm4n _at_ gmail.com)

Nested Class Summary
(package private)  class StackMap.MapElement<K,V>
          Inner class.
 
Constructor Summary
StackMap()
           
 
Method Summary
 boolean containsKey(SK key)
          Check wether a key is already inside the stack map.
 boolean containsValue(SV value)
          Check wether a value is already inside the stack map.
 SK getKey(int idx)
          Get the key of the map at specified index.
 java.util.ArrayList<SK> getKeyPath()
          Get path of Key
 java.lang.String getStringKeyPath()
          Get key path as string path.
 SV getValue(int idx)
          Get the value of the map at specified index.
 java.util.ArrayList<SV> getValuePath()
          Get path of Value
 boolean isApplicableForPath(java.lang.String path)
           An additional method tocheck wether this stack is applicable for a specific path like data.
 SK peekParentKey()
          Get the key of map right below the top-most stack.
 SV peekParentValue()
          Get the value of map right below the top-most stack.
 StackMap.MapElement<SK,SV> pop()
          Get and remove the map on top of the stack.
 void push(SK key, SV value)
          Add new map on top of the stack.
 int size()
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StackMap

public StackMap()
Method Detail

size

public int size()
DOCUMENT ME!

Returns:
DOCUMENT ME!

isApplicableForPath

public boolean isApplicableForPath(java.lang.String path)

An additional method tocheck wether this stack is applicable for a specific path like data.

For example :


  Stack Key
  +---+---+---+-----
  | a | b | c |  <--push  -->pop
  +---+---+---+-----
  Is applicable to :
     "/a/b/c" or "../a/b/c" or
     "../b/c" or "../c"  or even just ".."
  Not applicable to :
     "/1/b/c" or "/1/a/b/c" or
     "../1/b/c" or an empty string ""
 

Parameters:
path - Path string
Returns:
True if the path is applicable to the stack. False if otherwise.

push

public void push(SK key,
                 SV value)
Add new map on top of the stack.

Parameters:
key - Key object
value - Value object

pop

public StackMap.MapElement<SK,SV> pop()
Get and remove the map on top of the stack.

Returns:
Mapped element.

getStringKeyPath

public java.lang.String getStringKeyPath()
Get key path as string path.

Returns:
Keypath through the stack.

getKeyPath

public java.util.ArrayList<SK> getKeyPath()
Get path of Key

Returns:
return key path.

getValuePath

public java.util.ArrayList<SV> getValuePath()
Get path of Value

Returns:
return value path.

getValue

public SV getValue(int idx)
Get the value of the map at specified index.

Parameters:
idx - Index.
Returns:
The value.

getKey

public SK getKey(int idx)
Get the key of the map at specified index.

Parameters:
idx - Index
Returns:
The key

peekParentValue

public SV peekParentValue()
Get the value of map right below the top-most stack.

Returns:
The value.

peekParentKey

public SK peekParentKey()
Get the key of map right below the top-most stack.

Returns:
The key.

containsKey

public boolean containsKey(SK key)
Check wether a key is already inside the stack map.

Parameters:
key - Key to check
Returns:
True if the key already exist. False if otherwise.

containsValue

public boolean containsValue(SV value)
Check wether a value is already inside the stack map.

Parameters:
value - Value to check
Returns:
True if the value already exist. False if otherwise.


Copyright 2006 null. All Rights Reserved.