org.exist.dom
Class SymbolTable

java.lang.Object
  extended by org.exist.dom.SymbolTable

public class SymbolTable
extends Object

Maintains a global symbol table shared by a database instance. The symbol table maps namespace URIs and node names to unique, numeric ids. Internally, the db does not store node QNames in clear text. Instead, it uses the numeric ids maintained here. The global SymbolTable singleton can be retrieved from BrokerPool.getSymbols(). It is saved into the database file "symbols.dbx".

Author:
wolf

Field Summary
static short FILE_FORMAT_VERSION_ID
           
static String FILE_NAME
           
static int LENGTH_LOCAL_NAME
           
static int LENGTH_NS_URI
           
 
Constructor Summary
SymbolTable(BrokerPool pool, Configuration config)
           
 
Method Summary
 void backupSymbolsTo(OutputStream os)
           
 String[] defaultPrefixList()
          Returns a list of default prefixes registered.
 void flush()
           
 String getDefaultNamespace(String prefix)
          Returns a namespace URI for the given prefix if there's a default mapping.
 File getFile()
           
static String getFileName()
           
 String getMimeType(int id)
           
 int getMimeTypeId(String mimeType)
           
 String getName(short id)
          Returns the local name registered for the id or null if the name is not known.
 String getNamespace(short id)
          Returns the namespace URI registered for the id or null if the namespace URI is not known.
 short getNSSymbol(String ns)
          Returns a unique id for the specified namespace URI.
 QName getQName(short type, String namespaceURI, String localName, String prefix)
          Retrieve a shared QName instance from the temporary pool.
 short getSymbol(Attr attr)
          Return a unique id for the local node name of the specified attribute.
 short getSymbol(Element element)
          Return a unique id for the local node name of the specified element.
 short getSymbol(String name)
          Returns a unique id for the specified local name.
 boolean hasChanged()
          Returns true if the symbol table needs to be saved to persistent storage.
 void loadSymbols()
          Read the global symbol table.
 void read(VariableByteInput istream)
          Read the symbol table.
 void saveSymbols()
          Save the global symbol table.
 void write(VariableByteOutputStream ostream)
          Write the symbol table to persistent storage.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_NAME

public static final String FILE_NAME
See Also:
Constant Field Values

FILE_FORMAT_VERSION_ID

public static final short FILE_FORMAT_VERSION_ID
See Also:
Constant Field Values

LENGTH_LOCAL_NAME

public static int LENGTH_LOCAL_NAME

LENGTH_NS_URI

public static int LENGTH_NS_URI
Constructor Detail

SymbolTable

public SymbolTable(BrokerPool pool,
                   Configuration config)
            throws EXistException
Throws:
EXistException
Method Detail

getFileName

public static String getFileName()

getQName

public QName getQName(short type,
                      String namespaceURI,
                      String localName,
                      String prefix)
Retrieve a shared QName instance from the temporary pool. TODO: make the namePool thread-local to avoid synchronization.

Parameters:
namespaceURI -
localName -
prefix -

getSymbol

public short getSymbol(Element element)
Return a unique id for the local node name of the specified element.

Parameters:
element -

getSymbol

public short getSymbol(Attr attr)
Return a unique id for the local node name of the specified attribute.

Parameters:
attr -

getSymbol

public short getSymbol(String name)
Returns a unique id for the specified local name. If the name is the local name of an attribute, it should start with a '@' character.

Parameters:
name -

getNSSymbol

public short getNSSymbol(String ns)
Returns a unique id for the specified namespace URI.

Parameters:
ns -

getNamespace

public String getNamespace(short id)
Returns the namespace URI registered for the id or null if the namespace URI is not known. Returns the empty string if the namespace is empty.

Parameters:
id -

hasChanged

public boolean hasChanged()
Returns true if the symbol table needs to be saved to persistent storage.


getName

public String getName(short id)
Returns the local name registered for the id or null if the name is not known.

Parameters:
id -

getDefaultNamespace

public String getDefaultNamespace(String prefix)
Returns a namespace URI for the given prefix if there's a default mapping.

Parameters:
prefix -

defaultPrefixList

public String[] defaultPrefixList()
Returns a list of default prefixes registered.


getMimeTypeId

public int getMimeTypeId(String mimeType)

getMimeType

public String getMimeType(int id)

write

public void write(VariableByteOutputStream ostream)
           throws IOException
Write the symbol table to persistent storage.

Parameters:
ostream -
Throws:
IOException

read

public void read(VariableByteInput istream)
          throws IOException
Read the symbol table.

Parameters:
istream -
Throws:
IOException

getFile

public File getFile()

saveSymbols

public void saveSymbols()
                 throws EXistException
Save the global symbol table. The global symbol table stores QNames and namespace/prefix mappings.

Throws:
EXistException

loadSymbols

public void loadSymbols()
                 throws EXistException
Read the global symbol table. The global symbol table stores QNames and namespace/prefix mappings.

Throws:
EXistException

backupSymbolsTo

public void backupSymbolsTo(OutputStream os)
                     throws IOException
Throws:
IOException

flush

public void flush()
           throws EXistException
Throws:
EXistException


Copyright (C) Wolfgang Meier. All rights reserved.