use of java.util.EmptyStackException in project poi by apache.
the class TestMissingArgEval method testEvaluateMissingArgs.
public void testEvaluateMissingArgs() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
HSSFSheet sheet = wb.createSheet("Sheet1");
HSSFCell cell = sheet.createRow(0).createCell(0);
cell.setCellFormula("if(true,)");
fe.clearAllCachedResultValues();
CellValue cv;
try {
cv = fe.evaluate(cell);
} catch (EmptyStackException e) {
throw new AssertionFailedError("Missing args evaluation not implemented (bug 43354");
}
// MissingArg -> BlankEval -> zero (as formula result)
assertEquals(0.0, cv.getNumberValue(), 0.0);
// MissingArg -> BlankEval -> empty string (in concatenation)
cell.setCellFormula("\"abc\"&if(true,)");
fe.clearAllCachedResultValues();
assertEquals("abc", fe.evaluate(cell).getStringValue());
}
use of java.util.EmptyStackException in project robovm by robovm.
the class NamespaceSupportTest method testPush_PopContext.
public void testPush_PopContext() {
int count;
ns = new NamespaceSupport();
count = countPrefixes();
ns.pushContext();
ns.declarePrefix("dc", "http://www.purl.org/dc#");
assertEquals("Test 1: Incorrect prefix count;", count + 1, countPrefixes());
ns.popContext();
assertEquals("Test 2: Incorrect prefix count;", count, countPrefixes());
// Check that only one context has been created by pushContext().
try {
ns.popContext();
fail("Test 3: EmptyStackException expected.");
} catch (EmptyStackException e) {
// Expected.
}
}
use of java.util.EmptyStackException in project Algorithms by wlsgussla123.
the class Main method pop.
public T pop() {
if (isEmpty())
throw new EmptyStackException();
StackNode del = top;
T data = del.data;
top = top.next;
return data;
}
use of java.util.EmptyStackException in project cytoscape-impl by cytoscape.
the class InterpreterImpl method call.
private void call() throws EmptyStackException, IllegalStateException, FunctionError {
// 1. get the function
final Object o = argumentStack.pop();
if (!(o instanceof Function))
throw new IllegalStateException("expected a column function after the CALL opcode but found \"" + o.getClass() + "\" instead.");
final Function func = (Function) o;
// 2. get and validate the argument count
final int argCount;
try {
argCount = (Integer) argumentStack.pop();
} catch (final Exception e) {
throw new IllegalStateException("invalid argument count type following a CALL opcode.");
}
final int MIN_ARG_COUNT = 0;
// This is an arbitrary limit and exists only to find bugs.
final int MAX_ARG_COUNT = 100;
// Should it prove to be too low we could easily make it much bigger.
if (argCount < MIN_ARG_COUNT || argCount > MAX_ARG_COUNT)
throw new IllegalStateException("invalid argument count type following a CALL opcode (range must be in [" + MIN_ARG_COUNT + ", " + MAX_ARG_COUNT + "]).");
// 3. collect the actual arguments
final Object[] args = new Object[argCount];
for (int argNo = 0; argNo < argCount; ++argNo) args[argNo] = argumentStack.pop();
// 4. now actually call the function
argumentStack.push(func.evaluateFunction(args));
}
use of java.util.EmptyStackException in project jsql-injection by ron190.
the class CreateAdminPageTab method execute.
@Override
public void execute() {
if (MediatorGui.tabResults() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.tabResults() in " + this.getClass());
}
String htmlSource = "";
// Fix #44641: ExceptionInInitializerError on get()
try {
// Previous test for 2xx Success and 3xx Redirection was Header only,
// now get the HTML content.
// Proxy is used by jsoup
htmlSource = Jsoup.clean(Jsoup.connect(this.url).get().html().replaceAll("<img.*>", "").replaceAll("<input.*type=\"?hidden\"?.*>", "").replaceAll("<input.*type=\"?(submit|button)\"?.*>", "<div style=\"background-color:#eeeeee;text-align:center;border:1px solid black;width:100px;\">button</div>").replaceAll("<input.*>", "<div style=\"text-align:center;border:1px solid black;width:100px;\">input</div>"), Whitelist.relaxed().addTags("center", "div", "span").addAttributes(":all", "style"));
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
} catch (ExceptionInInitializerError | NoClassDefFoundError e) {
LOGGER.warn("Jsoup not properly configured, please update jsql", e);
}
final JTextPane browser = new JTextPane();
browser.setContentType("text/html");
browser.setEditable(false);
// Fix #43220: EmptyStackException on setText()
try {
browser.setText(htmlSource);
} catch (EmptyStackException e) {
LOGGER.error(e, e);
}
final JPopupMenu menu = new JPopupMenu();
JMenuItem itemCopyUrl = new JMenuItem(I18n.valueByKey("CONTEXT_MENU_COPY_PAGE_URL"));
I18nView.addComponentForKey("CONTEXT_MENU_COPY_PAGE_URL", itemCopyUrl);
itemCopyUrl.setIcon(HelperUi.ICON_EMPTY);
JMenuItem itemCopy = new JMenuItem();
itemCopy.setAction(browser.getActionMap().get(DefaultEditorKit.copyAction));
itemCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
itemCopy.setMnemonic('C');
itemCopy.setText(I18n.valueByKey("CONTEXT_MENU_COPY"));
I18nView.addComponentForKey("CONTEXT_MENU_COPY", itemCopy);
itemCopy.setIcon(HelperUi.ICON_EMPTY);
JMenuItem itemSelectAll = new JMenuItem();
itemSelectAll.setIcon(HelperUi.ICON_EMPTY);
itemSelectAll.setAction(browser.getActionMap().get(DefaultEditorKit.selectAllAction));
itemSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
itemSelectAll.setText(I18n.valueByKey("CONTEXT_MENU_SELECT_ALL"));
I18nView.addComponentForKey("CONTEXT_MENU_SELECT_ALL", itemSelectAll);
itemSelectAll.setMnemonic('A');
menu.add(itemCopyUrl);
menu.add(new JSeparator());
menu.add(itemCopy);
menu.add(itemSelectAll);
menu.applyComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()));
itemCopyUrl.addActionListener(actionEvent -> {
StringSelection stringSelection = new StringSelection(CreateAdminPageTab.this.url);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
});
itemSelectAll.addActionListener(actionEvent -> browser.selectAll());
browser.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent arg0) {
browser.getCaret().setVisible(true);
browser.getCaret().setSelectionVisible(true);
}
});
browser.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent evt) {
browser.requestFocusInWindow();
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent(), evt.getX(), evt.getY());
}
}
@Override
public void mouseReleased(MouseEvent evt) {
if (evt.isPopupTrigger()) {
// Fix #45348: IllegalComponentStateException on show()
try {
menu.show(evt.getComponent(), evt.getX(), evt.getY());
} catch (IllegalComponentStateException e) {
LOGGER.error(e, e);
}
menu.setLocation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? evt.getXOnScreen() - menu.getWidth() : evt.getXOnScreen(), evt.getYOnScreen());
}
}
});
final LightScrollPane scroller = new LightScrollPane(1, 0, 0, 0, browser);
MediatorGui.tabResults().addTab(this.url.replaceAll(".*/", "") + " ", scroller);
// Focus on the new tab
MediatorGui.tabResults().setSelectedComponent(scroller);
// Create a custom tab header with close button
TabHeader header = new TabHeader(this.url.replaceAll(".*/", ""), HelperUi.ICON_ADMIN_SERVER);
MediatorGui.tabResults().setToolTipTextAt(MediatorGui.tabResults().indexOfComponent(scroller), "<html>" + this.url + "</html>");
// Apply the custom header to the tab
MediatorGui.tabResults().setTabComponentAt(MediatorGui.tabResults().indexOfComponent(scroller), header);
// Give focus to the admin page
browser.requestFocusInWindow();
// Get back to the top
SwingUtilities.invokeLater(() -> scroller.scrollPane.getViewport().setViewPosition(new java.awt.Point(0, 0)));
}
Aggregations