001 /** 002 * Copyright (c) 2000-present Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.tools.seleniumbuilder; 016 017 import com.liferay.portal.kernel.util.StringPool; 018 019 import java.util.Stack; 020 021 /** 022 * Provides methods for stack interaction in FreeMarker. 023 * 024 * @author Michael Hashimoto 025 */ 026 public class FreeMarkerStack { 027 028 /** 029 * Returns <code>true</code> if the stack is empty. 030 * 031 * @return <code>true</code> if the stack is empty; <code>false</code> 032 * otherwise 033 */ 034 public boolean empty() { 035 return _stack.empty(); 036 } 037 038 /** 039 * Returns the object at the top of the stack, without removing it from the 040 * stack. 041 * 042 * @return the object at the top of the stack, without removing it from the 043 * stack 044 */ 045 public Object peek() { 046 return _stack.peek(); 047 } 048 049 /** 050 * Returns the object at the top of the stack, removing it from the stack. 051 * 052 * @return the object at the top of the stack 053 */ 054 public Object pop() { 055 return _stack.pop(); 056 } 057 058 /** 059 * Pushes the object onto the stack. 060 * 061 * @param object the item to be pushed onto the stack 062 * @return a blank string 063 */ 064 public Object push(Object object) { 065 _stack.push(object); 066 067 return StringPool.BLANK; 068 } 069 070 private final Stack<Object> _stack = new Stack<>(); 071 072 }