FileDocCategorySizeDatePackage
SymbolTable.javaAPI DocJava SE 5 API7665Fri Aug 26 14:55:36 BST 2005com.sun.org.apache.xalan.internal.xsltc.compiler

SymbolTable

public final class SymbolTable extends Object
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen
author
Morten Jorgensen

Fields Summary
private final Hashtable
_stylesheets
private final Hashtable
_primops
private Hashtable
_variables
private Hashtable
_templates
private Hashtable
_attributeSets
private Hashtable
_aliases
private Hashtable
_excludedURI
private Hashtable
_decimalFormats
private int
_nsCounter
This is used for xsl:attribute elements that have a "namespace" attribute that is currently not defined using xmlns:
private SyntaxTreeNode
_current
Use a namespace prefix to lookup a namespace URI
Constructors Summary
Methods Summary
public com.sun.org.apache.xalan.internal.xsltc.compiler.AttributeSetaddAttributeSet(com.sun.org.apache.xalan.internal.xsltc.compiler.AttributeSet atts)

	if (_attributeSets == null) _attributeSets = new Hashtable();
	return (AttributeSet)_attributeSets.put(atts.getName(), atts);
    
public voidaddDecimalFormatting(com.sun.org.apache.xalan.internal.xsltc.compiler.QName name, com.sun.org.apache.xalan.internal.xsltc.compiler.DecimalFormatting symbols)

	if (_decimalFormats == null) _decimalFormats = new Hashtable();
	_decimalFormats.put(name, symbols);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.ParamaddParam(com.sun.org.apache.xalan.internal.xsltc.compiler.Param parameter)

	if (_variables == null) _variables = new Hashtable();
	final String name = parameter.getName().getStringRep();
	return (Param)_variables.put(name, parameter);
    
public voidaddPrefixAlias(java.lang.String prefix, java.lang.String alias)
Adds an alias for a namespace prefix

	if (_aliases == null) _aliases = new Hashtable();
	_aliases.put(prefix,alias);
    
public voidaddPrimop(java.lang.String name, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType mtype)
Add a primitive operator or function to the symbol table. To avoid name clashes with user-defined names, the prefix PrimopPrefix is prepended.

	Vector methods = (Vector)_primops.get(name);
	if (methods == null) {
	    _primops.put(name, methods = new Vector());
	}
	methods.addElement(mtype);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.StylesheetaddStylesheet(com.sun.org.apache.xalan.internal.xsltc.compiler.QName name, com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet node)

	return (Stylesheet)_stylesheets.put(name, node);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.TemplateaddTemplate(com.sun.org.apache.xalan.internal.xsltc.compiler.Template template)

	final QName name = template.getName();
	if (_templates == null) _templates = new Hashtable();
	return (Template)_templates.put(name, template);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.VariableaddVariable(com.sun.org.apache.xalan.internal.xsltc.compiler.Variable variable)

	if (_variables == null) _variables = new Hashtable();
	final String name = variable.getName().getStringRep();
	return (Variable)_variables.put(name, variable);
    
public voidexcludeNamespaces(java.lang.String prefixes)
Exclude a series of namespaces given by a list of whitespace separated namespace prefixes.

	if (prefixes != null) {
	    StringTokenizer tokens = new StringTokenizer(prefixes);
	    while (tokens.hasMoreTokens()) {
		final String prefix = tokens.nextToken();
		final String uri;
		if (prefix.equals("#default"))
		    uri = lookupNamespace(Constants.EMPTYSTRING);
		else
		    uri = lookupNamespace(prefix);
		if (uri != null) excludeURI(uri);
	    }
	}
    
public voidexcludeURI(java.lang.String uri)
Register a namespace URI so that it will not be declared in the output unless it is actually referenced in the output.

	// The null-namespace cannot be excluded
	if (uri == null) return;

	// Create new hashtable of exlcuded URIs if none exists
	if (_excludedURI == null) _excludedURI = new Hashtable();

	// Register the namespace URI
	Integer refcnt = (Integer)_excludedURI.get(uri);
	if (refcnt == null)
	    refcnt = new Integer(1);
	else
	    refcnt = new Integer(refcnt.intValue() + 1);
	_excludedURI.put(uri,refcnt);
    
public java.lang.StringgenerateNamespacePrefix()


       
	return(new String("ns"+(_nsCounter++)));
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.DecimalFormattinggetDecimalFormatting(com.sun.org.apache.xalan.internal.xsltc.compiler.QName name)


        
	if (_decimalFormats == null) return null;
	return((DecimalFormatting)_decimalFormats.get(name));
    
public booleanisExcludedNamespace(java.lang.String uri)
Check if a namespace should not be declared in the output (unless used)

	if (uri != null && _excludedURI != null) {
	    final Integer refcnt = (Integer)_excludedURI.get(uri);
	    return (refcnt != null && refcnt.intValue() > 0);
	}
	return false;
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.AttributeSetlookupAttributeSet(com.sun.org.apache.xalan.internal.xsltc.compiler.QName name)

	if (_attributeSets == null) return null;
	return (AttributeSet)_attributeSets.get(name);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNodelookupName(com.sun.org.apache.xalan.internal.xsltc.compiler.QName qname)

	if (_variables == null) return null;
	final String name = qname.getStringRep();
	return (SyntaxTreeNode)_variables.get(name);
    
public java.lang.StringlookupNamespace(java.lang.String prefix)

	if (_current == null) return(Constants.EMPTYSTRING);
	return(_current.lookupNamespace(prefix));
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.ParamlookupParam(com.sun.org.apache.xalan.internal.xsltc.compiler.QName qname)

	if (_variables == null) return null;
	final String name = qname.getStringRep();
	final Object obj = _variables.get(name);
	return obj instanceof Param ? (Param)obj : null;
    
public java.lang.StringlookupPrefixAlias(java.lang.String prefix)
Retrieves any alias for a given namespace prefix

	if (_aliases == null) return null;
	return (String)_aliases.get(prefix);
    
public java.util.VectorlookupPrimop(java.lang.String name)
Lookup a primitive operator or function in the symbol table by prepending the prefix PrimopPrefix.

	return (Vector)_primops.get(name);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.StylesheetlookupStylesheet(com.sun.org.apache.xalan.internal.xsltc.compiler.QName name)

	return (Stylesheet)_stylesheets.get(name);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.TemplatelookupTemplate(com.sun.org.apache.xalan.internal.xsltc.compiler.QName name)

	if (_templates == null) return null;
	return (Template)_templates.get(name);
    
public com.sun.org.apache.xalan.internal.xsltc.compiler.VariablelookupVariable(com.sun.org.apache.xalan.internal.xsltc.compiler.QName qname)

	if (_variables == null) return null;
	final String name = qname.getStringRep();
	final Object obj = _variables.get(name);
	return obj instanceof Variable ? (Variable)obj : null;
    
public voidsetCurrentNode(com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode node)


        
	_current = node;
    
public voidunExcludeNamespaces(java.lang.String prefixes)
Turn of namespace declaration exclusion

	if (_excludedURI == null) return;
	if (prefixes != null) {
	    StringTokenizer tokens = new StringTokenizer(prefixes);
	    while (tokens.hasMoreTokens()) {
		final String prefix = tokens.nextToken();
		final String uri;
		if (prefix.equals("#default"))
		    uri = lookupNamespace(Constants.EMPTYSTRING);
		else
		    uri = lookupNamespace(prefix);
		Integer refcnt = (Integer)_excludedURI.get(uri);
		if (refcnt != null)
		    _excludedURI.put(uri, new Integer(refcnt.intValue() - 1));
	    }
	}