Code example for Deque

Methods: peek, push

0
				builder.append(" { ");
			} else { 
				builder.append("\"" + escape(name) + "\": { ");
			} 
 
			bracketStack.push(Character.valueOf('}'));
		} 
		commaStack.push(Boolean.valueOf(commaNeeded));
		commaNeeded = false;
	} 
 
	private static String escape(final String string) {
		return StringEscapeUtils.escapeJavaScript(string);
	} 
 
	@Override 
	public void endEntity() { 
		builder.append(bracketStack.pop() + " ");
		commaNeeded = commaStack.pop().booleanValue();
	} 
 
	@Override 
	public void literal(final String name, final String value) {
 
		if (commaNeeded) {
			builder.append(", ");
		} 
 
		if (inArray()) { 
			builder.append("\"" + escape(value) + "\"");
		} else { 
			builder.append("\"" + escape(name) + "\":\"" + escape(value) + "\"");
		} 
 
		commaNeeded = true;
	} 
 
	private boolean inArray() { 
		return bracketStack.peek().charValue() == ']';
	} 
 
}