org.apache.xerces.util

Class NamespaceSupport

Implemented Interfaces:
org.apache.xerces.xni.NamespaceContext
Known Direct Subclasses:
MultipleScopeNamespaceSupport, SchemaNamespaceSupport

public class NamespaceSupport
extends java.lang.Object
implements org.apache.xerces.xni.NamespaceContext

Namespace support for XML document handlers. This class doesn't perform any error checking and assumes that all strings passed as arguments to methods are unique symbols. The SymbolTable class can be used for this purpose.
Version:
$Id: NamespaceSupport.java 320523 2005-06-23 05:39:17Z mrglavas $
Author:
Andy Clark, IBM

Nested Class Summary

protected class
NamespaceSupport.Prefixes

Field Summary

protected int[]
fContext
Context indexes.
protected int
fCurrentContext
The current context.
protected String[]
fNamespace
Namespace binding information.
protected int
fNamespaceSize
The top of the namespace information array.
protected String[]
fPrefixes

Fields inherited from interface org.apache.xerces.xni.NamespaceContext

XMLNS_URI, XML_URI

Constructor Summary

NamespaceSupport()
Default constructor.
NamespaceSupport(org.apache.xerces.xni.NamespaceContext context)
Constructs a namespace context object and initializes it with the prefixes declared in the specified context.

Method Summary

boolean
containsPrefix(String prefix)
Checks whether a binding or unbinding for the given prefix exists in the context.
boolean
declarePrefix(String prefix, String uri)
Enumeration
getAllPrefixes()
String
getDeclaredPrefixAt(int index)
int
getDeclaredPrefixCount()
String
getPrefix(String uri)
String
getURI(String prefix)
void
popContext()
void
pushContext()
void
reset()

Field Details

fContext

protected int[] fContext
Context indexes. This array contains indexes into the namespace information array. The index at the current context is the start index of declared namespace bindings and runs to the size of the namespace information array.

fCurrentContext

protected int fCurrentContext
The current context.

fNamespace

protected String[] fNamespace
Namespace binding information. This array is composed of a series of tuples containing the namespace binding information: <prefix, uri>. The default size can be set to anything as long as it is a power of 2 greater than 1.

fNamespaceSize

protected int fNamespaceSize
The top of the namespace information array.

fPrefixes

protected String[] fPrefixes

Constructor Details

NamespaceSupport

public NamespaceSupport()
Default constructor.

NamespaceSupport

public NamespaceSupport(org.apache.xerces.xni.NamespaceContext context)
Constructs a namespace context object and initializes it with the prefixes declared in the specified context.

Method Details

containsPrefix

public boolean containsPrefix(String prefix)
Checks whether a binding or unbinding for the given prefix exists in the context.
Parameters:
prefix - The prefix to look up.
Returns:
true if the given prefix exists in the context

declarePrefix

public boolean declarePrefix(String prefix,
                             String uri)
Specified by:
declarePrefix in interface org.apache.xerces.xni.NamespaceContext
See Also:
org.apache.xerces.xni.NamespaceContext.declarePrefix(String, String)

getAllPrefixes

public Enumeration getAllPrefixes()
Specified by:
getAllPrefixes in interface org.apache.xerces.xni.NamespaceContext
See Also:
org.apache.xerces.xni.NamespaceContext.getAllPrefixes()

getDeclaredPrefixAt

public String getDeclaredPrefixAt(int index)
Specified by:
getDeclaredPrefixAt in interface org.apache.xerces.xni.NamespaceContext
See Also:
org.apache.xerces.xni.NamespaceContext.getDeclaredPrefixAt(int)

getDeclaredPrefixCount

public int getDeclaredPrefixCount()
Specified by:
getDeclaredPrefixCount in interface org.apache.xerces.xni.NamespaceContext
See Also:
org.apache.xerces.xni.NamespaceContext.getDeclaredPrefixCount()

getPrefix

public String getPrefix(String uri)
Specified by:
getPrefix in interface org.apache.xerces.xni.NamespaceContext
See Also:
org.apache.xerces.xni.NamespaceContext.getPrefix(String)

getURI

public String getURI(String prefix)
Specified by:
getURI in interface org.apache.xerces.xni.NamespaceContext
See Also:
org.apache.xerces.xni.NamespaceContext.getURI(String)

popContext

public void popContext()
Specified by:
popContext in interface org.apache.xerces.xni.NamespaceContext
See Also:
org.apache.xerces.xni.NamespaceContext.popContext()

pushContext

public void pushContext()
Specified by:
pushContext in interface org.apache.xerces.xni.NamespaceContext
See Also:
org.apache.xerces.xni.NamespaceContext.pushContext()

reset

public void reset()
Specified by:
reset in interface org.apache.xerces.xni.NamespaceContext
See Also:
org.apache.xerces.xni.NamespaceContext.reset()

Copyright B) 1999-2006 The Apache Software Foundation. All Rights Reserved.