Package java.util

Examples of java.util.Stack


          }
        }
      }
    }

    Stack dummy = next;
    next = current;
    current = dummy;

    System.out.println("Current states");
View Full Code Here


   *
   * @param node Current node.
   */
  private void fireEvents(TreeNode node) throws SAXException
  {
    Stack stack = new Stack();

    ProductionNode previous = null;
    TreeNode next = node;
    do
    {
      while (next!=null)
      {
        stack.push(next);

        if (locatorImpl!=null)
        {
          locatorImpl.setLineNumber(next.linenumber);
          locatorImpl.setColumnNumber(next.columnnumber);
        }

        if ((!flatten) || (previous==null) || (!previous.symbol.equals(next.symbol)))
        {
          AttributesImpl atts = new AttributesImpl();
          if (localizable)
          {
            atts.addAttribute("", "line", "line", "CDATA", String.valueOf(next.linenumber));
            atts.addAttribute("", "column", "column", "CDATA", String.valueOf(next.columnnumber));
          }

          contentHandler.startElement(NS_OUTPUT, next.symbol, next.symbol, atts);
        }

        if (next instanceof ProductionNode)
        {
          ProductionNode production = (ProductionNode)next;
          previous = production;
          next = production.firstchild;
        }
        else
        {
          TokenNode token = (TokenNode)next;
          contentHandler.characters(token.text.toCharArray(), 0, token.text.length());
          next = null;
        }
      }

      next = (TreeNode)stack.pop();
      previous = stack.isEmpty() ? null : (ProductionNode)stack.peek();

      if (locatorImpl!=null)
      {
        locatorImpl.setLineNumber(next.linenumber);
        locatorImpl.setColumnNumber(next.columnnumber);
      }

      if ((!flatten) || (previous==null) || (!previous.symbol.equals(next.symbol)))
        contentHandler.endElement(NS_OUTPUT, next.symbol, next.symbol);

      next = next.nextsibling;
    }
    while (!stack.isEmpty());
  }
View Full Code Here

  /**
   * Receive notification of the beginning of a document.
   */
  public void startDocument()
  {
    stack = new Stack();

    state = STATE_OUTER;
  }
View Full Code Here

    contentHandler.startElement(NS_OUTPUT, OUTPUT, OUTPUT, new AttributesImpl());

    String symbol = grammar.getStartSymbol();
    contentHandler.startElement(NS_OUTPUT, symbol, symbol, new AttributesImpl());

    Stack stack = new Stack();
    StackNodeList next = root;
    char[] text = null;
    int position = 0;
    int lastposition = 0;
    line = 1;
    column = 1;

    if (locatorImpl!=null)
    {
      locatorImpl.setLineNumber(line);
      locatorImpl.setColumnNumber(column);
    }

    while (next!=null)
    {
      if (next.node instanceof NonterminalStackNode)
      {
        if (text!=null)
        {
          contentHandler.characters(text, position, (lastposition+1)-position);
          increasePosition(text, position, (lastposition+1)-position);

          if (locatorImpl!=null)
          {
            locatorImpl.setLineNumber(line);
            locatorImpl.setColumnNumber(column);
          }

          text = null;
        }

        NonterminalStackNode nonterminal = (NonterminalStackNode)next.node;

        AttributesImpl atts = new AttributesImpl();

        /*if (localizable)
        {
          atts.addAttribute("", "line", "line", "CDATA", String.valueOf(next.linenumber));
          atts.addAttribute("", "column", "column", "CDATA", String.valueOf(next.columnnumber));
        }*/
        contentHandler.startElement(NS_OUTPUT, next.node.pattern.getSymbol(),
                                    next.node.pattern.getSymbol(), atts);
        stack.push(next);
        next = nonterminal.definition;
      }
      else
      {
        TerminalStackNode terminal = (TerminalStackNode)next.node;
        if (text==null)
        {
          text = terminal.text;
          position = terminal.position;
        }
        else if (text!=terminal.text)
        {
          contentHandler.characters(text, position, (lastposition+1)-position);
          increasePosition(text, position, (lastposition+1)-position);

          if (locatorImpl!=null)
          {
            locatorImpl.setLineNumber(line);
            locatorImpl.setColumnNumber(column);
          }

          text = terminal.text;
          position = terminal.position;
        }

        lastposition = terminal.position;

        next = next.next;
      }

      while ((next==null) && (!stack.isEmpty()))
      {
        next = (StackNodeList)stack.pop();

        if (text!=null)
        {
          contentHandler.characters(text, position, (lastposition+1)-position);
          increasePosition(text, position, (lastposition+1)-position);
View Full Code Here

  /**
   * Receive notification of the beginning of a document.
   */
  public void startDocument()
  {
    stack = new Stack();
  }
View Full Code Here

 
  public static final Context getInstance()
  {
    synchronized(_context) {
      Stack stack = (Stack)_context.get(Thread.currentThread());
      if (stack == null || stack.isEmpty()) {
        throw new RuntimeException("Context is missing for thread: " + Thread.currentThread());
      }
      return (Context)stack.peek();
    }
  }
View Full Code Here

    synchronized(_context) {
      Iterator iter = _context.entrySet().iterator();
      while(iter.hasNext()) {
        Map.Entry entry = (Map.Entry)iter.next();
        Thread thread = (Thread)entry.getKey();
        Stack stack = (Stack)entry.getValue();
        out.println("----------- "+thread+" ---------");
        if (stack != null) {
          int i = stack.size() - 1;
          while(i >= 0) {
            Context ctx = (Context)stack.get(i);
            if (ctx != null) {
              int j = ctx.size() - 1;
              while(j>=0) {
                StackFrame frame = ctx.peek(j--);
                if (frame != null) {
View Full Code Here

 
  public static final Context getInstance(Zone zone)
  {
    synchronized(_context) {
      Thread thread = Thread.currentThread();
      Stack stack = (Stack)_context.get(thread);
      if (stack == null || stack.isEmpty()) {
        Context context = new Context(zone);
        putInstance(thread, context);
        return context;
      }
      return (Context)stack.peek();
    }
  }
View Full Code Here


  public static final Context getInstance(Thread thread)
  {
    synchronized(_context) {
      Stack stack = (Stack)_context.get(thread);
      if (stack == null || stack.isEmpty()) {
        throw new RuntimeException("Context is missing for thread: " + thread);
      }
      return (Context)stack.peek();
    }
  }
View Full Code Here

 
 
  public static final void putInstance(Thread thread, Context context)
  {
    synchronized(_context) {
      Stack stack = (Stack)_context.get(thread);
      if (stack == null) {
        _context.put(thread, stack = new Stack());
      }
      stack.push(context);
    }
  }
View Full Code Here

TOP

Related Classes of java.util.Stack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.