jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/SymbolTable.java
author chegar
Sun, 17 Aug 2014 15:51:56 +0100
changeset 25868 686eef1e7a79
parent 12458 jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/SymbolTable.java@d601e4bba306
child 33349 975138b77cff
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
 * Copyright 2001-2004 The Apache Software Foundation.
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 * Licensed under the Apache License, Version 2.0 (the "License");
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * you may not use this file except in compliance with the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 * You may obtain a copy of the License at
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *     http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
 * $Id: SymbolTable.java,v 1.5 2005/09/28 13:48:16 pvedula Exp $
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
package com.sun.org.apache.xalan.internal.xsltc.compiler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
import java.util.Hashtable;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
    27
import java.util.Stack;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import java.util.StringTokenizer;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
import java.util.Vector;
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType;
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
 * @author Jacek Ambroziak
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
 * @author Santiago Pericas-Geertsen
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
 * @author Morten Jorgensen
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
final class SymbolTable {
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
    // These hashtables are used for all stylesheets
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
    private final Hashtable _stylesheets = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
    private final Hashtable _primops     = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
    // These hashtables are used for some stylesheets
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
    private Hashtable _variables = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
    private Hashtable _templates = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
    private Hashtable _attributeSets = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
    private Hashtable _aliases = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
    private Hashtable _excludedURI = null;
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
    50
    private Stack     _excludedURIStack = null;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
    private Hashtable _decimalFormats = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
    private Hashtable _keys = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
    public DecimalFormatting getDecimalFormatting(QName name) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
        if (_decimalFormats == null) return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
        return((DecimalFormatting)_decimalFormats.get(name));
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
    public void addDecimalFormatting(QName name, DecimalFormatting symbols) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
        if (_decimalFormats == null) _decimalFormats = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
        _decimalFormats.put(name, symbols);
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
    public Key getKey(QName name) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
        if (_keys == null) return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
        return (Key) _keys.get(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
    public void addKey(QName name, Key key) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
        if (_keys == null) _keys = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
        _keys.put(name, key);
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
    public Stylesheet addStylesheet(QName name, Stylesheet node) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
        return (Stylesheet)_stylesheets.put(name, node);
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
    public Stylesheet lookupStylesheet(QName name) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
        return (Stylesheet)_stylesheets.get(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
    public Template addTemplate(Template template) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
        final QName name = template.getName();
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
        if (_templates == null) _templates = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
        return (Template)_templates.put(name, template);
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
    public Template lookupTemplate(QName name) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
        if (_templates == null) return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
        return (Template)_templates.get(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
    public Variable addVariable(Variable variable) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
        if (_variables == null) _variables = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
        final String name = variable.getName().getStringRep();
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
        return (Variable)_variables.put(name, variable);
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
    public Param addParam(Param parameter) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
        if (_variables == null) _variables = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
        final String name = parameter.getName().getStringRep();
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
        return (Param)_variables.put(name, parameter);
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
    public Variable lookupVariable(QName qname) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
        if (_variables == null) return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
        final String name = qname.getStringRep();
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
        final Object obj = _variables.get(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
        return obj instanceof Variable ? (Variable)obj : null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
    public Param lookupParam(QName qname) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
        if (_variables == null) return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
        final String name = qname.getStringRep();
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
        final Object obj = _variables.get(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
        return obj instanceof Param ? (Param)obj : null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
    public SyntaxTreeNode lookupName(QName qname) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
        if (_variables == null) return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
        final String name = qname.getStringRep();
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
        return (SyntaxTreeNode)_variables.get(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
    public AttributeSet addAttributeSet(AttributeSet atts) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
        if (_attributeSets == null) _attributeSets = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
        return (AttributeSet)_attributeSets.put(atts.getName(), atts);
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
    public AttributeSet lookupAttributeSet(QName name) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
        if (_attributeSets == null) return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
        return (AttributeSet)_attributeSets.get(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
     * Add a primitive operator or function to the symbol table. To avoid
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
     * name clashes with user-defined names, the prefix <tt>PrimopPrefix</tt>
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
     * is prepended.
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
    public void addPrimop(String name, MethodType mtype) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
        Vector methods = (Vector)_primops.get(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
        if (methods == null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
            _primops.put(name, methods = new Vector());
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
        methods.addElement(mtype);
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
     * Lookup a primitive operator or function in the symbol table by
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
     * prepending the prefix <tt>PrimopPrefix</tt>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
    public Vector lookupPrimop(String name) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
        return (Vector)_primops.get(name);
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
     * This is used for xsl:attribute elements that have a "namespace"
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
     * attribute that is currently not defined using xmlns:
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
    private int _nsCounter = 0;
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
    public String generateNamespacePrefix() {
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   163
        return("ns"+(_nsCounter++));
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
     * Use a namespace prefix to lookup a namespace URI
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
    private SyntaxTreeNode _current = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
    public void setCurrentNode(SyntaxTreeNode node) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
        _current = node;
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
    public String lookupNamespace(String prefix) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
        if (_current == null) return(Constants.EMPTYSTRING);
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
        return(_current.lookupNamespace(prefix));
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
     * Adds an alias for a namespace prefix
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
    public void addPrefixAlias(String prefix, String alias) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
        if (_aliases == null) _aliases = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
        _aliases.put(prefix,alias);
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
     * Retrieves any alias for a given namespace prefix
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
    public String lookupPrefixAlias(String prefix) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
        if (_aliases == null) return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
        return (String)_aliases.get(prefix);
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
     * Register a namespace URI so that it will not be declared in the output
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
     * unless it is actually referenced in the output.
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
    public void excludeURI(String uri) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
        // The null-namespace cannot be excluded
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
        if (uri == null) return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
        // Create new hashtable of exlcuded URIs if none exists
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
        if (_excludedURI == null) _excludedURI = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
        // Register the namespace URI
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
        Integer refcnt = (Integer)_excludedURI.get(uri);
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
        if (refcnt == null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
            refcnt = new Integer(1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
        else
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
            refcnt = new Integer(refcnt.intValue() + 1);
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
        _excludedURI.put(uri,refcnt);
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
     * Exclude a series of namespaces given by a list of whitespace
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
     * separated namespace prefixes.
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
    public void excludeNamespaces(String prefixes) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
        if (prefixes != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
            StringTokenizer tokens = new StringTokenizer(prefixes);
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
            while (tokens.hasMoreTokens()) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
                final String prefix = tokens.nextToken();
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
                final String uri;
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
                if (prefix.equals("#default"))
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
                    uri = lookupNamespace(Constants.EMPTYSTRING);
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
                else
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
                    uri = lookupNamespace(prefix);
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
                if (uri != null) excludeURI(uri);
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
     * Check if a namespace should not be declared in the output (unless used)
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
    public boolean isExcludedNamespace(String uri) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
        if (uri != null && _excludedURI != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
            final Integer refcnt = (Integer)_excludedURI.get(uri);
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
            return (refcnt != null && refcnt.intValue() > 0);
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
        return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
     * Turn of namespace declaration exclusion
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
    public void unExcludeNamespaces(String prefixes) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
        if (_excludedURI == null) return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
        if (prefixes != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
            StringTokenizer tokens = new StringTokenizer(prefixes);
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
            while (tokens.hasMoreTokens()) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
                final String prefix = tokens.nextToken();
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
                final String uri;
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
                if (prefix.equals("#default"))
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
                    uri = lookupNamespace(Constants.EMPTYSTRING);
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
                else
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
                    uri = lookupNamespace(prefix);
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
                Integer refcnt = (Integer)_excludedURI.get(uri);
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
                if (refcnt != null)
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
                    _excludedURI.put(uri, new Integer(refcnt.intValue() - 1));
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
    }
12458
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   266
    /**
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   267
     * Exclusion of namespaces by a stylesheet does not extend to any stylesheet
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   268
     * imported or included by the stylesheet.  Upon entering the context of a
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   269
     * new stylesheet, a call to this method is needed to clear the current set
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   270
     * of excluded namespaces temporarily.  Every call to this method requires
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   271
     * a corresponding call to {@link #popExcludedNamespacesContext()}.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   272
     */
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   273
    public void pushExcludedNamespacesContext() {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   274
        if (_excludedURIStack == null) {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   275
            _excludedURIStack = new Stack();
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   276
        }
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   277
        _excludedURIStack.push(_excludedURI);
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   278
        _excludedURI = null;
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   279
    }
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   280
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   281
    /**
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   282
     * Exclusion of namespaces by a stylesheet does not extend to any stylesheet
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   283
     * imported or included by the stylesheet.  Upon exiting the context of a
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   284
     * stylesheet, a call to this method is needed to restore the set of
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   285
     * excluded namespaces that was in effect prior to entering the context of
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   286
     * the current stylesheet.
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   287
     */
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   288
    public void popExcludedNamespacesContext() {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   289
        _excludedURI = (Hashtable) _excludedURIStack.pop();
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   290
        if (_excludedURIStack.isEmpty()) {
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   291
            _excludedURIStack = null;
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   292
        }
d601e4bba306 7160380: Sync JDK8 with JAXP 1.4.5
joehw
parents: 12457
diff changeset
   293
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
}