当前位置: 首页>>代码示例>>Java>>正文


Java EmptyStackException类代码示例

本文整理汇总了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.
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:ResetPasswordServiceImplTest.java

示例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;
    }
 
开发者ID:XaskYSab,项目名称:xmlpullparserutil,代码行数:17,代码来源:PairStack.java

示例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);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:22,代码来源:SystemLogHandler.java

示例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");
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:29,代码来源:Digester.java

示例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;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:29,代码来源:Digester.java

示例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;
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:20,代码来源:HUDManager.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:Digester.java

示例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;
}
 
开发者ID:rostykerei,项目名称:cci,代码行数:21,代码来源:SetOfStacksFull.java

示例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 ) ;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:DelegateImpl.java

示例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);
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:15,代码来源:ArrayStack.java

示例11: pop

import java.util.EmptyStackException; //导入依赖的package包/类
public T pop()
{
  if( isEmpty() )
  {
    throw new EmptyStackException();
  }
  return _list.remove( size() - 1 );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:9,代码来源:Stack.java

示例12: peek

import java.util.EmptyStackException; //导入依赖的package包/类
public Object peek() {
int	len = size();

if (len == 0)
    throw new EmptyStackException();
return get(len - 1);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ArrayListStack.java

示例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();
}
 
开发者ID:DCMMC,项目名称:Java-Algorithms-Learning,代码行数:38,代码来源:BagsQueuesStacks.java

示例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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:Stack.java

示例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();
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:ObjectStack.java


注:本文中的java.util.EmptyStackException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。