org.basex.data
Class Namespaces

java.lang.Object
  extended by org.basex.data.Namespaces

public final class Namespaces
extends java.lang.Object

This class organizes the namespaces of a database.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Constructor Summary
Namespaces()
          Empty constructor.
 
Method Summary
 org.basex.data.NSNode add(byte[] pref, byte[] uri, int pre)
          Adds the specified namespace to the namespace structure of the current element.
 int add(int pre, int par, byte[] pref, byte[] uri, Data data)
          Adds a namespace for the specified pre value.
 void close(int pre)
          Closes a namespace node.
 void delete(byte[] uri)
          Deletes the specified namespace URI from the root node.
 byte[] globalNS()
          Returns the default namespace of the database, or null if several (default or prefixed) namespaces are defined.
 byte[] info()
          Returns namespace information.
 void prepare()
          Prepares the generation of new namespaces.
 int size()
          Returns the size of the uri container.
 byte[] table(int s, int e)
          Returns a tabular representation of the namespaces.
 java.lang.String toString()
           
 java.lang.String toString(int s, int e)
          Returns a string representation of the namespaces.
 int uri(byte[] uri)
          Returns a reference to the specified namespace URI, or 0 if the URI is empty or no namespace is found.
 int uri(byte[] name, boolean elem)
          Returns the namespace URI reference for the specified name, or 0 if no namespace is found.
 int uri(byte[] name, int pre, Data data)
          Returns the namespace URI reference for the specified name and pre value, or 0 if namespace cannot be found.
 byte[] uri(int id)
          Returns the specified namespace URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Namespaces

public Namespaces()
Empty constructor.

Method Detail

prepare

public void prepare()
Prepares the generation of new namespaces.


add

public org.basex.data.NSNode add(byte[] pref,
                                 byte[] uri,
                                 int pre)
Adds the specified namespace to the namespace structure of the current element.

Parameters:
pref - prefix
uri - uri
pre - pre value
Returns:
new NSNode if a new one has been created, null otherwise

close

public void close(int pre)
Closes a namespace node.

Parameters:
pre - current pre value

uri

public int uri(byte[] name,
               boolean elem)
Returns the namespace URI reference for the specified name, or 0 if no namespace is found.

Parameters:
name - tag/attribute name
elem - element flag
Returns:
namespace

size

public int size()
Returns the size of the uri container. Note that the container size does not change if namespaces are deleted. This function is basically used to decide if there are any namespaces at all, and if namespaces need to be considered in query optimizations.

Returns:
number of uri references

globalNS

public byte[] globalNS()
Returns the default namespace of the database, or null if several (default or prefixed) namespaces are defined.

Returns:
global default namespace

uri

public byte[] uri(int id)
Returns the specified namespace URI.

Parameters:
id - namespace URI reference
Returns:
prefix

uri

public int uri(byte[] name,
               int pre,
               Data data)
Returns the namespace URI reference for the specified name and pre value, or 0 if namespace cannot be found.

Parameters:
name - element/attribute name
pre - pre value
data - data reference
Returns:
namespace URI reference

delete

public void delete(byte[] uri)
Deletes the specified namespace URI from the root node.

Parameters:
uri - namespace URI reference

add

public int add(int pre,
               int par,
               byte[] pref,
               byte[] uri,
               Data data)
Adds a namespace for the specified pre value.

Parameters:
pre - pre value
par - parent value
pref - prefix
uri - uri
data - data reference
Returns:
uri reference

uri

public int uri(byte[] uri)
Returns a reference to the specified namespace URI, or 0 if the URI is empty or no namespace is found.

Parameters:
uri - namespace URI
Returns:
reference, or 0

table

public byte[] table(int s,
                    int e)
Returns a tabular representation of the namespaces.

Parameters:
s - start pre value
e - end pre value
Returns:
namespaces

info

public byte[] info()
Returns namespace information.

Returns:
info string

toString

public java.lang.String toString(int s,
                                 int e)
Returns a string representation of the namespaces.

Parameters:
s - start pre value
e - end pre value
Returns:
string

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object