Java 8 Stack - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Stack class.

This code example shows how to use the following methods:
    public TagContext(String tagName) {
        this.tagName = tagName;
    } 
     
    public static void init() { 
        currentStack.set(new Stack<TagContext>());
        enterTag("ROOT"); 
    } 
     
    public static void enterTag(String name) {
        currentStack.get().add(new TagContext(name));
    } 
     
    public static void exitTag() { 
        currentStack.get().pop();
    } 
     
    public static TagContext current() { 
        return currentStack.get().peek();
    } 
Full Snippet Info
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
   
  @Override 
  public void startDocument() { 
    state = ParseState.EXPECT_EDITS_TAG;
    stanza = null;
    stanzaStack = new Stack<Stanza>();
    opCode = null;
    cbuf = new StringBuffer();
    nextTxId = -1;
  } 
   
  @Override 
  public void endDocument() { 
    if (state != ParseState.EXPECT_END) {
      throw new InvalidXmlException("expecting </EDITS>"); 
    } 
  } 
   
  @Override 
  public void startElement (String uri, String name,
Full Snippet Info
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: peek
 
        return variable;
    } 
 
    public static Expression getInstance() { 
        return instance.get().peek();
    } 
 
    private void pushInstance() { 
        Stack<Expression> foo = instance.get();
        if (foo == null) {
            instance.set(foo = new Stack<Expression>());
        } 
 
        foo.push(this);
    } 
 
    private void popInstance() { 
        Stack<Expression> foo = instance.get();
 
Full Snippet Info
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: push
    } 
    return large;
  } 
   
  private Stack<String> createStack() {
    Stack<String> stack = new Stack<String>();
    stack.push("1");
    stack.push("2");
    stack.push("3");
    return stack;
  } 
 
  /** Checks for emptiness of stack by peeking and popping. */ 
  private void checkEmptiness(Stack<?> s) {
    assertTrue(s.empty());
    try { 
      s.pop();
      fail("Did not throw exception on pop of checkEmptiness"); 
    } catch (EmptyStackException es) {
      try { 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: peek, pop
  public void characters(char[] chars, int start, int length) throws SAXException {
    charBuffer.append(chars, start, length);
  } 
 
  public void endElement(String uri, String localName, String qName) throws SAXException {
    Node previousNode = ((Node)nodesStack.peek());
    previousNode.setValue(charBuffer.toString());
    charBuffer.setLength(0);
    Node node = (Node)nodesStack.pop();
    node.complete();
  } 
} 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:
     
  /** Creates a new instance of XmlRecordOutput */ 
  public XmlRecordOutput(OutputStream out) {
    try { 
      stream = new PrintStream(out, true, "UTF-8");
      compoundStack = new Stack<String>();
    } catch (UnsupportedEncodingException ex) {
      throw new RuntimeException(ex);
    } 
  } 
     
  @Override 
  public void writeByte(byte b, String tag) throws IOException {
    printBeginEnvelope(tag);
    stream.print("<ex:i1>");
    stream.print(Byte.toString(b));
    stream.print("</ex:i1>");
    printEndEnvelope(tag);
  } 
     
Full Snippet Info
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: peek, pop, push, size
  } 
 
  /** Tests pop and peek. */ 
  public void testPopAndPeek() { 
    Stack<String> testStack = createStack();
    int x = testStack.size();
    Object item = testStack.peek();
    assertTrue(testStack.pop() == item);
    assertEquals(x - 1, testStack.size());
  } 
 
  /** Tests push and peek. */ 
  public void testPushAndPeek() { 
    Stack<String> testStack = createStack();
    int x = testStack.size();
    String item = "4";
    testStack.push(item);
    assertEquals(x + 1, testStack.size());
    assertTrue(testStack.peek() == item);
  } 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: push
            handler.handleSIGINT();
        } 
    } 
 
    public static void push(SIGINT handler) {
        handlers.push(handler);
    } 
 
    public static void pop() { 
        handlers.pop();
    } 
} 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: peek, size
 * 
 * <p>NOTE: nodes are added to the JDOM via the method #basicAddChild such that 
 * the nodes in the newly created JDOM are not fragmented. 
 */ 
protected void addChild(IDOMNode child) {
	if (this.fStack.size() > 0) {
		DOMNode parent = (DOMNode) this.fStack.peek();
		if (this.fBuildingCU || this.fBuildingType) {
			parent.basicAddChild(child);
		} 
	} 
} 
/** 
 * @see IDOMFactory#createCompilationUnit(String, String) 
 */ 
public IDOMCompilationUnit createCompilationUnit(char[] contents, char[] name) {
	return createCompilationUnit(new CompilationUnit(contents, name));
} 
/** 
 * @see IDOMFactory#createCompilationUnit(String, String) 
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 Stack Questions & Answers:

See Code Examples for Java 8 Stack Methods: