com.oxygenxml.validate.nvdl
Class ContextMap

java.lang.Object
  extended by com.oxygenxml.validate.nvdl.ContextMap

 class ContextMap
extends Object

Keeps modes depending on context. The structure of the context map is stores the mode for / in rootValue "" in otherValue (this is for relative paths) stores a hash with the last path elements as key and ContextMap objects as values. A path like a/b and mode x will be represented by 3 ContextMap objects ContextMap b ---> ContextMap a ---> ContextMap otherValue=x Addind also /a/b and mode y will give ContextMap b ---> ContextMap a ---> ContextMap (otherValue=x, rootValue=y) Adding a2/b and mode w will give ContextMap b ---> ContextMap a ---> ContextMap (otherValue=x, rootValue=y) a2 ---> ContextMap otherValue=w


Nested Class Summary
private static class ContextMap.Enumerator
          Creates an Enumeration implementation that enumerates all the modes stored in this context map and in the nested context maps.
 
Field Summary
private  Hashtable nameTable
          Stores a hash map with with the key the last local name and as values other ContextMap objects.
private  Object otherValue
          Stores a mode associated with a relative path.
private  Object rootValue
          Stores the mode associated with an absolute path.
 
Constructor Summary
ContextMap()
           
 
Method Summary
 boolean equals(Object obj)
          Chek that this context map is equals with a specified context map.
(package private)  Object get(Vector context)
          Get the mode matching a list of local names.
private  Object get(Vector context, int len)
          Get the mode matching a list of local names.
 int hashCode()
          Get a hashcode for this context map.
private  boolean put(boolean isRoot, Vector names, int len, Object value)
          Adds a single path (isRoot, names) and a mode to be used for this path = context.
(package private)  boolean put(boolean isRoot, Vector names, Object value)
          Adds a single path (isRoot, names) and a mode to be used for this path = context.
(package private)  Enumeration values()
          Get an enumeration with all the modes in this context map.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootValue

private Object rootValue
Stores the mode associated with an absolute path.


otherValue

private Object otherValue
Stores a mode associated with a relative path.


nameTable

private final Hashtable nameTable
Stores a hash map with with the key the last local name and as values other ContextMap objects.

Constructor Detail

ContextMap

ContextMap()
Method Detail

get

Object get(Vector context)
Get the mode matching a list of local names. A root more returned means an exact matching of the given local names with the local names from the context map. Otherwise we can get either a mode stored as otherValue or null if the given context does not match any of the stored paths.

Parameters:
context - The list of local names that represent a section context (path from root local element names from the same namespace).
Returns:
A mode or null.

put

boolean put(boolean isRoot,
            Vector names,
            Object value)
Adds a single path (isRoot, names) and a mode to be used for this path = context.

Parameters:
isRoot - True if the path starts with /
names - The local names that form the path.
value - The mode.
Returns:
true if there is no duplicate path, false otherwise.

get

private Object get(Vector context,
                   int len)
Get the mode matching a list of local names. A root more returned means an exact matching of the given local names with the local names from the context map. Otherwise we can get either a mode stored as otherValue or null if the given context does not match any of the stored paths.

Parameters:
context - The list of local names that represent a section context (path from root local element names from the same namespace).
len - The lenght we should take from the list.
Returns:
A mode or null.

put

private boolean put(boolean isRoot,
                    Vector names,
                    int len,
                    Object value)
Adds a single path (isRoot, names) and a mode to be used for this path = context.

Parameters:
isRoot - True if the path starts with /
names - The local names that form the path.
len - The length if the names vector.
value - The mode.
Returns:
true if there is no duplicate path, false otherwise.

equals

public boolean equals(Object obj)
Chek that this context map is equals with a specified context map.

Overrides:
equals in class Object

hashCode

public int hashCode()
Get a hashcode for this context map.

Overrides:
hashCode in class Object

values

Enumeration values()
Get an enumeration with all the modes in this context map.

Returns:
An enumeration containing Mode objects.