コード例 #1
0
 /** Create a new Namespace context. */
 Context2(Context2 parent) {
   if (parent == null) {
     prefixTable = new Hashtable();
     uriTable = new Hashtable();
     elementNameTable = null;
     attributeNameTable = null;
   } else setParent(parent);
 }
コード例 #2
0
  /**
   * Start a new Namespace context.
   *
   * <p>Normally, you should push a new context at the beginning of each XML element: the new
   * context will automatically inherit the declarations of its parent context, but it will also
   * keep track of which declarations were made within this context.
   *
   * <p>The Namespace support object always starts with a base context already in force: in this
   * context, only the "xml" prefix is declared.
   *
   * @see #popContext
   */
  public void pushContext() {
    // JJK: Context has a parent pointer.
    // That means we don't need a stack to pop.
    // We may want to retain for reuse, but that can be done via
    // a child pointer.

    Context2 parentContext = currentContext;
    currentContext = parentContext.getChild();
    if (currentContext == null) {
      currentContext = new Context2(parentContext);
    } else {
      // JJK: This will wipe out any leftover data
      // if we're reusing a previously allocated Context.
      currentContext.setParent(parentContext);
    }
  }