com.simonstl.moe.namespace
Interface NamespaceContextI

All Known Implementing Classes:
NamespaceContext

public interface NamespaceContextI

The NamespaceContextI interface is a replacement for the current NamespaceContextI interface. Once this stabilizes and has a real implementation, it will replace NamespaceContextI.

The NamespaceContextI interface provides an API for managing the namespace stack. It provides methods to access the current set of namespaces as well as to manage the stack. Most applications should probably use the listen(CoreComponentI component) method of the ComponentInputI interface rather than managing the stack manually, but manual management may be appropriate for applications that need to create an initial context before using it.

Version 0.01 is the foundation of the interface.

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

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.
 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.
 void popLevel()
          popLevel() is called when an element ends, and strips out old namespace declarations which no longer apply.
 void pushLevel()
          pushLevel() is called when an element starts, and doesn't have much to do.
 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
 

Method Detail

declarePrefix

public void declarePrefix(java.lang.String prefix,
                          java.lang.String URI)
Declares a mapping between a prefix and a URI at the current tree level.

declarePrefix

public void declarePrefix(Namespace namespace)
Declares a mapping between a prefix and a URI at the current tree level.

getURI

public java.lang.String getURI(java.lang.String prefix)
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.

getPrefix

public java.lang.String getPrefix(java.lang.String URI)
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.

getNamespacesByPrefixes

public java.util.HashMap getNamespacesByPrefixes()
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.

getNamespacesByURIs

public java.util.HashMap getNamespacesByURIs()
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.

getFullDeclaration

public java.lang.String getFullDeclaration()
Returns a full set of namespace declarations for the current context.

setParent

public void setParent(CoreComponentI _parent)
Not sure if this goes here or in NamespaceSetI or anywhere

pushLevel

public void pushLevel()
pushLevel() is called when an element starts, and doesn't have much to do.

popLevel

public void popLevel()
popLevel() is called when an element ends, and strips out old namespace declarations which no longer apply.

getLevel

public int getLevel()
getLevel() returns the current position of the stack. Mostly useful for debugging.

collectContext

public NamespaceContextI collectContext(CoreComponentI component)
collectContext() builds a new namespaceContextI object by walking up the tree from the component used as a parameter.

isDeclared

public boolean isDeclared(java.lang.String prefix,
                          java.lang.String URI)
isDeclared() says whether a particular URI/prefix combination has been declared.

reset

public void reset()
reset() is called when the object needs to be emptied for reuse.