com.simonstl.moe.namespace
Class NamespaceContext

java.lang.Object
  |
  +--com.simonstl.moe.namespace.NamespaceContext
All Implemented Interfaces:
NamespaceContextI

public class NamespaceContext
extends java.lang.Object
implements NamespaceContextI

The NamespaceContextI interface is a test implementation of NamespaceContextI.

Version 0.01 is the beginning of the class.

Version:
0.01 11 December 2001
Author:
Simon St.Laurent

Field Summary
protected  int level
           
protected  boolean modified
           
protected  java.util.ArrayList namespaceStack
           
protected  java.util.HashMap nsByPrefix
           
protected  java.util.HashMap nsByURI
           
 
Constructor Summary
NamespaceContext()
           
 
Method Summary
 NamespaceContextI collectContext(CoreComponentI component)
          collectContext() builds a new namespaceContextI object by walking up the tree from the component used as a parameter.
 void declarePrefix(Namespace namespace)
          Declares a mapping between a prefix and a URI at the current tree level.
 void declarePrefix(java.lang.String prefix, java.lang.String URI)
          Declares a mapping between a prefix and a URI at the current tree level.
protected  void generateSets()
           
 java.lang.String getFullDeclaration()
          Returns a full set of namespace declarations for the current context.
 int getLevel()
          getLevel() returns the current position of the stack.
 java.util.HashMap getNamespacesByPrefixes()
          Returns an enumeration of all the prefixes and URIs in the current context, keyed to prefix.
 java.util.HashMap getNamespacesByURIs()
          Returns an enumeration of all the prefixes and URIs in the current context, keyed to URI.
 java.lang.String getPrefix(java.lang.String URI)
          Given a prefix, it returns the URI to which that prefix maps.
 java.lang.String getURI(java.lang.String prefix)
          Given a URI, it returns the first prefix it finds matching it.
 boolean isDeclared(java.lang.String prefix, java.lang.String URI)
          isDeclared() says whether a particular URI/prefix combination has been declared.
static void main(java.lang.String[] args)
           
 void popLevel()
          popLevel() is called when an element ends, and strips out old namespace declarations which no longer apply.
static void printPop(NamespaceContext subject)
           
static void printPush(NamespaceContext subject)
           
 void pushLevel()
          pushLevel() is called when an element starts, and doesn't have much to do.
protected  boolean removeNamespaces(int removeLevel)
           
 void reset()
          reset() is called when the object needs to be emptied for reuse.
 void setParent(CoreComponentI _parent)
          Not sure if this goes here or in NamespaceSetI or anywhere
static boolean test()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

level

protected int level

modified

protected boolean modified

namespaceStack

protected java.util.ArrayList namespaceStack

nsByPrefix

protected java.util.HashMap nsByPrefix

nsByURI

protected java.util.HashMap nsByURI
Constructor Detail

NamespaceContext

public NamespaceContext()
Method Detail

declarePrefix

public void declarePrefix(java.lang.String prefix,
                          java.lang.String URI)
Description copied from interface: NamespaceContextI
Declares a mapping between a prefix and a URI at the current tree level.
Specified by:
declarePrefix in interface NamespaceContextI

declarePrefix

public void declarePrefix(Namespace namespace)
Description copied from interface: NamespaceContextI
Declares a mapping between a prefix and a URI at the current tree level.
Specified by:
declarePrefix in interface NamespaceContextI

generateSets

protected void generateSets()

getURI

public java.lang.String getURI(java.lang.String prefix)
Description copied from interface: NamespaceContextI
Given a URI, it returns the first prefix it finds matching it. Because multiple namespace prefixes may be mapped to a given URI, this may not return the expected prefix.
Specified by:
getURI in interface NamespaceContextI

getPrefix

public java.lang.String getPrefix(java.lang.String URI)
Description copied from interface: NamespaceContextI
Given a prefix, it returns the URI to which that prefix maps. This is a processed set of namespaces applying to a current context, so only one URI will be returned.
Specified by:
getPrefix in interface NamespaceContextI

getNamespacesByPrefixes

public java.util.HashMap getNamespacesByPrefixes()
Description copied from interface: NamespaceContextI
Returns an enumeration of all the prefixes and URIs in the current context, keyed to prefix. This may return multiple prefixes mapped to the same URI.
Specified by:
getNamespacesByPrefixes in interface NamespaceContextI

getNamespacesByURIs

public java.util.HashMap getNamespacesByURIs()
Description copied from interface: NamespaceContextI
Returns an enumeration of all the prefixes and URIs in the current context, keyed to URI. Each URI will be mapped to only one prefix, the most recent declaration.
Specified by:
getNamespacesByURIs in interface NamespaceContextI

getFullDeclaration

public java.lang.String getFullDeclaration()
Description copied from interface: NamespaceContextI
Returns a full set of namespace declarations for the current context.
Specified by:
getFullDeclaration in interface NamespaceContextI

setParent

public void setParent(CoreComponentI _parent)
Description copied from interface: NamespaceContextI
Not sure if this goes here or in NamespaceSetI or anywhere
Specified by:
setParent in interface NamespaceContextI

isDeclared

public boolean isDeclared(java.lang.String prefix,
                          java.lang.String URI)
Description copied from interface: NamespaceContextI
isDeclared() says whether a particular URI/prefix combination has been declared.
Specified by:
isDeclared in interface NamespaceContextI

pushLevel

public void pushLevel()
Description copied from interface: NamespaceContextI
pushLevel() is called when an element starts, and doesn't have much to do.
Specified by:
pushLevel in interface NamespaceContextI

popLevel

public void popLevel()
Description copied from interface: NamespaceContextI
popLevel() is called when an element ends, and strips out old namespace declarations which no longer apply.
Specified by:
popLevel in interface NamespaceContextI

removeNamespaces

protected boolean removeNamespaces(int removeLevel)

getLevel

public int getLevel()
Description copied from interface: NamespaceContextI
getLevel() returns the current position of the stack. Mostly useful for debugging.
Specified by:
getLevel in interface NamespaceContextI

reset

public void reset()
Description copied from interface: NamespaceContextI
reset() is called when the object needs to be emptied for reuse.
Specified by:
reset in interface NamespaceContextI

collectContext

public NamespaceContextI collectContext(CoreComponentI component)
Description copied from interface: NamespaceContextI
collectContext() builds a new namespaceContextI object by walking up the tree from the component used as a parameter.
Specified by:
collectContext in interface NamespaceContextI

printPush

public static void printPush(NamespaceContext subject)

printPop

public static void printPop(NamespaceContext subject)

test

public static boolean test()

main

public static void main(java.lang.String[] args)