本文整理汇总了Java中java.util.EmptyStackException类的典型用法代码示例。如果您正苦于以下问题:Java EmptyStackException类的具体用法?Java EmptyStackException怎么用?Java EmptyStackException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmptyStackException类属于java.util包,在下文中一共展示了EmptyStackException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanUp
import java.util.EmptyStackException; //导入依赖的package包/类
@AfterClass
public static void cleanUp()
{
resetPasswordService.setSendEmailAsynchronously(Boolean.valueOf(
globalProperties.getProperty("system.reset-password.sendEmailAsynchronously")));
resetPasswordService.setDefaultEmailSender((String) globalProperties.get("system.email.sender.default"));
AuthenticationUtil.setRunAsUserSystem();
transactionHelper.doInTransaction(() ->
{
personService.deletePerson(testPerson.userName);
return null;
});
// Restore authentication to pre-test state.
try
{
AuthenticationUtil.popAuthentication();
}
catch(EmptyStackException e)
{
// Nothing to do.
}
}
示例2: popIfFrist
import java.util.EmptyStackException; //导入依赖的package包/类
public synchronized boolean popIfFrist(T t) {
if (tStack.peek().equals(t)) {
T temp = tStack.pop();
try {
rStack.pop();
return true;
} catch (EmptyStackException e) {
tStack.push(temp);
return false;
}
}
return false;
}
示例3: startCapture
import java.util.EmptyStackException; //导入依赖的package包/类
/**
* Start capturing thread's output.
*/
public static void startCapture() {
CaptureLog log = null;
if (!reuse.isEmpty()) {
try {
log = reuse.pop();
} catch (EmptyStackException e) {
log = new CaptureLog();
}
} else {
log = new CaptureLog();
}
Stack<CaptureLog> stack = logs.get();
if (stack == null) {
stack = new Stack<CaptureLog>();
logs.set(stack);
}
stack.push(log);
}
示例4: endPrefixMapping
import java.util.EmptyStackException; //导入依赖的package包/类
/**
* Process notification that a namespace prefix is going out of scope.
*
* @param prefix Prefix that is going out of scope
*
* @exception SAXException if a parsing error is to be reported
*/
@Override
public void endPrefixMapping(String prefix) throws SAXException {
if (saxLog.isDebugEnabled()) {
saxLog.debug("endPrefixMapping(" + prefix + ")");
}
// Deregister this prefix mapping
ArrayStack<String> stack = namespaces.get(prefix);
if (stack == null) {
return;
}
try {
stack.pop();
if (stack.empty())
namespaces.remove(prefix);
} catch (EmptyStackException e) {
throw createSAXException("endPrefixMapping popped too many times");
}
}
示例5: pop
import java.util.EmptyStackException; //导入依赖的package包/类
/**
* <p>Pops (gets and removes) the top object from the stack with the given name.</p>
*
* <p><strong>Note:</strong> a stack is considered empty
* if no objects have been pushed onto it yet.</p>
*
* @param stackName the name of the stack from which the top value is to be popped
* @return the top <code>Object</code> on the stack or or null if the stack is either
* empty or has not been created yet
* @throws EmptyStackException if the named stack is empty
*
* @since 1.6
*/
public Object pop(String stackName) {
Object result = null;
ArrayStack<Object> namedStack = stacksByName.get(stackName);
if (namedStack == null) {
if (log.isDebugEnabled()) {
log.debug("Stack '" + stackName + "' is empty");
}
throw new EmptyStackException();
} else {
result = namedStack.pop();
}
return result;
}
示例6: pop
import java.util.EmptyStackException; //导入依赖的package包/类
/**
* Hide the currently displayed HUD, and show the one below it on the stack
*/
public synchronized void pop() {
Debug.d("Popping one off the HUD stack");
try {
PhoeniciaHUD previousHUD = this.hudStack.pop();
if (previousHUD != null) {
this.currentHUD.hide();
this.currentHUD.close();
this.setHudLayer(previousHUD);
this.currentHUD = previousHUD;
previousHUD.show();
}
} catch (EmptyStackException e) {
Debug.d("Nothing to pop off the stack");
return;
}
}
示例7: peek
import java.util.EmptyStackException; //导入依赖的package包/类
/**
* <p>Gets the top object from the stack with the given name.
* This method does not remove the object from the stack.
* </p>
* <p><strong>Note:</strong> a stack is considered empty
* if no objects have been pushed onto it yet.</p>
*
* @param stackName the name of the stack to be peeked
* @return the top <code>Object</code> on the stack or null if the stack is either
* empty or has not been created yet
* @throws EmptyStackException if the named stack is empty
*
* @since 1.6
*/
public Object peek(String stackName) {
Object result = null;
ArrayStack namedStack = (ArrayStack) stacksByName.get(stackName);
if (namedStack == null ) {
if (log.isDebugEnabled()) {
log.debug("Stack '" + stackName + "' is empty");
}
throw new EmptyStackException();
} else {
result = namedStack.peek();
}
return result;
}
示例8: popAt
import java.util.EmptyStackException; //导入依赖的package包/类
@Override
public T popAt(final int stackNumber) {
if (stacks.isEmpty()) {
throw new EmptyStackException();
}
if (stacks.size() <= stackNumber - 1) {
throw new IllegalArgumentException(
"Stack #" + stackNumber + " does not exists"
);
}
T item = stacks.get(stackNumber).pop();
if (stacks.get(stackNumber).isEmpty()) {
stacks.remove(stackNumber);
}
return item;
}
示例9: poa
import java.util.EmptyStackException; //导入依赖的package包/类
public POA poa(Servant self)
{
try {
return (POA)orb.peekInvocationInfo().oa();
} catch (EmptyStackException exception){
POA returnValue = factory.lookupPOA(self);
if (returnValue != null) {
return returnValue;
}
throw wrapper.noContext( exception ) ;
}
}
示例10: peek
import java.util.EmptyStackException; //导入依赖的package包/类
/**
* Returns the top item off of this stack without removing it.
*
* @return the top item on the stack
* @throws EmptyStackException if the stack is empty
*/
public E peek() throws EmptyStackException {
int n = size();
if (n <= 0) {
throw new EmptyStackException();
} else {
return get(n - 1);
}
}
示例11: pop
import java.util.EmptyStackException; //导入依赖的package包/类
public T pop()
{
if( isEmpty() )
{
throw new EmptyStackException();
}
return _list.remove( size() - 1 );
}
示例12: peek
import java.util.EmptyStackException; //导入依赖的package包/类
public Object peek() {
int len = size();
if (len == 0)
throw new EmptyStackException();
return get(len - 1);
}
示例13: dequeue
import java.util.EmptyStackException; //导入依赖的package包/类
/**
* 从该Queue中取出元素, 并把该元素删除
* @return 最早进Queue的元素
*/
Item dequeue() throws EmptyStackException {
if (sizeFirstQ == 0) {
if (sizeSecondQ > 0) {
//如果firstQ空而secondQ非空, 就将这两个Stack互换
Stack<Item> tmpQ = firstQ;
firstQ = secondQ;
secondQ = tmpQ;
sizeFirstQ = sizeSecondQ;
sizeSecondQ = 0;
} else if (sizeS > 0 && sizeS < maxCapacity) {
//如果s中元素不足maxCapacity, 就把所以的元素移进firstQ
while (!s.isEmpty()) {
sizeS--;
firstQ.push(s.pop());
sizeFirstQ++;
}
} else if(sizeS >= maxCapacity) {
//如果s中元素大于maxCapacity, 就把maxCapacity个元素移进firstQ
for (int i = 0; i < maxCapacity; i++) {
sizeS--;
firstQ.push(s.pop());
sizeFirstQ++;
}
} else {
throw new EmptyStackException();
}
}
//如果firstQ有元素那就从firstQ中取元素出来
sizeFirstQ--;
return firstQ.pop();
}
示例14: pop
import java.util.EmptyStackException; //导入依赖的package包/类
/**
* pop.
*
* @return the last element.
*/
public E pop()
{
if( mSize == 0 )
throw new EmptyStackException();
return mElements.set(--mSize, null);
}
示例15: setTop
import java.util.EmptyStackException; //导入依赖的package包/类
/**
* Sets an object at a the top of the statck
*
*
* @param val object to set at the top
* @throws EmptyStackException if this stack is empty.
*/
public void setTop(Object val)
{
try {
m_map[m_firstFree - 1] = val;
}
catch (ArrayIndexOutOfBoundsException e)
{
throw new EmptyStackException();
}
}