List of usage examples for java.util LinkedList isEmpty
boolean isEmpty();
From source file:org.jboss.dashboard.error.ErrorManager.java
/** * Get the error cause (if any) thrown by the application logic. */// ww w . j a v a 2s . co m public ApplicationError getApplicationErrorCause(Throwable e) { LinkedList<ApplicationError> appErrors = new LinkedList<ApplicationError>(); Throwable cause = e; while (cause != null) { if (cause instanceof ApplicationError) appErrors.add((ApplicationError) cause); cause = cause.getCause(); } if (appErrors.isEmpty()) return null; return appErrors.getLast(); }
From source file:com.espertech.esper.epl.core.ResultSetProcessorSimple.java
/** * Applies the select-clause to the given events returning the selected events. The number of events stays the * same, i.e. this method does not filter it just transforms the result set. * <p>// w w w . ja va 2 s . com * Also applies a having clause. * @param exprProcessor - processes each input event and returns output event * @param orderByProcessor - for sorting output events according to the order-by clause * @param events - input events * @param optionalHavingNode - supplies the having-clause expression * @param isNewData - indicates whether we are dealing with new data (istream) or old data (rstream) * @param isSynthesize - set to true to indicate that synthetic events are required for an iterator result set * @param exprEvaluatorContext context for expression evalauation * @return output events, one for each input event */ protected static EventBean[] getSelectEventsHaving(SelectExprProcessor exprProcessor, OrderByProcessor orderByProcessor, EventBean[] events, ExprEvaluator optionalHavingNode, boolean isNewData, boolean isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { if (events == null) { return null; } LinkedList<EventBean> result = new LinkedList<EventBean>(); List<EventBean[]> eventGenerators = null; if (orderByProcessor != null) { eventGenerators = new ArrayList<EventBean[]>(); } EventBean[] eventsPerStream = new EventBean[1]; for (EventBean theEvent : events) { eventsPerStream[0] = theEvent; Boolean passesHaving = (Boolean) optionalHavingNode.evaluate(eventsPerStream, isNewData, exprEvaluatorContext); if ((passesHaving == null) || (!passesHaving)) { continue; } result.add(exprProcessor.process(eventsPerStream, isNewData, isSynthesize, exprEvaluatorContext)); if (orderByProcessor != null) { eventGenerators.add(new EventBean[] { theEvent }); } } if (!result.isEmpty()) { if (orderByProcessor != null) { return orderByProcessor.sort(result.toArray(new EventBean[result.size()]), eventGenerators.toArray(new EventBean[eventGenerators.size()][]), isNewData, exprEvaluatorContext); } else { return result.toArray(new EventBean[result.size()]); } } else { return null; } }
From source file:fi.hsl.parkandride.back.UtilizationDao.java
@Transactional(readOnly = true, isolation = READ_COMMITTED, propagation = MANDATORY) @Override/*w w w. j a v a2 s . c om*/ public List<Utilization> findUtilizationsWithResolution(UtilizationKey utilizationKey, DateTime start, DateTime end, Minutes resolution) { ArrayList<Utilization> results = new ArrayList<>(); Optional<Utilization> first = findUtilizationAtInstant(utilizationKey, start); try (CloseableIterator<Utilization> rest = findUtilizationsBetween(utilizationKey, start, end)) { LinkedList<Utilization> utilizations = Stream .concat(StreamUtil.asStream(first), StreamUtil.asStream(rest)) .collect(Collectors.toCollection(LinkedList::new)); Utilization current = null; for (DateTime instant = start; !instant.isAfter(end); instant = instant.plus(resolution)) { while (!utilizations.isEmpty() && !utilizations.getFirst().timestamp.isAfter(instant)) { current = utilizations.removeFirst(); } if (current != null) { current.timestamp = instant; results.add(current.copy()); } } } return results; }
From source file:com.opera.core.systems.scope.services.ums.WindowManager.java
public void closeAllWindows() { logger.fine("closeAllWindows"); LinkedList<Integer> list = new LinkedList<Integer>(windows.asStack()); boolean canCloseAll = services.getExec().getActionList().contains("Close all pages"); if (canCloseAll) { services.getExec().action("Close all pages"); } else {//from w w w . j a v a2 s . c o m while (!list.isEmpty()) { closeWindow(list.removeFirst()); // BAD HACK! DELAYING CLOSE-WINDOW try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } logger.warning( "Bad hack: sleeping 10ms between closing of windows, to prevent opera from crashing!"); // BAD HACK DONE! } } }
From source file:org.eclim.plugin.jdt.command.impl.ImplCommand.java
/** * Gets the type to be edited.//from w w w .j a v a 2 s. c o m * * @param src The ICompilationUnit of the source file to edit. * @param commandLine The command line. * @return The IType to be edited. */ protected IType getType(ICompilationUnit src, CommandLine commandLine) throws Exception { IType type = null; // If a qualified name for the type being modified was supplied if (commandLine.hasOption(Options.TYPE_OPTION)) { IJavaProject javaProject = src.getJavaProject(); String typeFQN = commandLine.getValue(Options.TYPE_OPTION); int indexOfDollar = typeFQN.indexOf("$"); // If we are dealing with an anonymous inner class, findType does not work // so lets find it starting at the class containing the anonymous class. if (indexOfDollar > 0) { String primaryTypeFQN = typeFQN.substring(0, indexOfDollar); IType primaryType = javaProject.findType(primaryTypeFQN); LinkedList<IJavaElement> todo = new LinkedList<IJavaElement>(); todo.add(primaryType); while (!todo.isEmpty()) { IJavaElement element = todo.removeFirst(); if (element instanceof IType) { IType tempType = (IType) element; String name = tempType.getFullyQualifiedName(); if (name.equals(typeFQN)) { type = tempType; break; } } if (element instanceof IParent) { for (IJavaElement child : ((IParent) element).getChildren()) { todo.add(child); } } } // Else it is a normal class/interface so find works } else { type = javaProject.findType(typeFQN); } // If not, we need to find it based on the current selection } else { type = TypeUtils.getType(src, getOffset(commandLine)); } return type; }
From source file:statistic.graph.dataset.XYChartCreator.java
private void validateStatistics() { if (statistics == null) { statistics = new LinkedList<DisplayableStatistic>(); }/* www . j ava2 s .co m*/ LinkedList<DisplayableStatistic> incomplete = new LinkedList<DisplayableStatistic>(); for (DisplayableStatistic statistic : statistics) { if (!statistic.isInitialized()) { incomplete.add(statistic); } } if (!incomplete.isEmpty()) { statistics = new LinkedList<DisplayableStatistic>(statistics); for (DisplayableStatistic statistic : incomplete) { statistics.remove(statistic); } } }
From source file:io.syndesis.jsondb.impl.SqlJsonDB.java
private int deleteJsonRecords(Handle dbi, String baseDBPath, String like) { LinkedList<String> params = getAllParentPaths(baseDBPath); StringBuilder sql = new StringBuilder("DELETE from jsondb where path LIKE ?"); if (!params.isEmpty()) { sql.append(" OR path in ( ").append(String.join(", ", Collections.nCopies(params.size(), "?"))) .append(" )"); }//from ww w.j ava2 s. c o m params.addFirst(like); return dbi.update(sql.toString(), params.toArray()); }
From source file:com.espertech.esper.epl.core.ResultSetProcessorSimple.java
/** * Applies the select-clause to the given events returning the selected events. The number of events stays the * same, i.e. this method does not filter it just transforms the result set. * <p>/* ww w . j a v a 2s . c om*/ * Also applies a having clause. * @param exprProcessor - processes each input event and returns output event * @param orderByProcessor - for sorting output events according to the order-by clause * @param events - input events * @param optionalHavingNode - supplies the having-clause expression * @param isNewData - indicates whether we are dealing with new data (istream) or old data (rstream) * @param isSynthesize - set to true to indicate that synthetic events are required for an iterator result set * @param exprEvaluatorContext context for expression evalauation * @return output events, one for each input event */ protected static EventBean[] getSelectEventsHaving(SelectExprProcessor exprProcessor, OrderByProcessor orderByProcessor, Set<MultiKey<EventBean>> events, ExprEvaluator optionalHavingNode, boolean isNewData, boolean isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { if ((events == null) || (events.isEmpty())) { return null; } LinkedList<EventBean> result = new LinkedList<EventBean>(); List<EventBean[]> eventGenerators = null; if (orderByProcessor != null) { eventGenerators = new ArrayList<EventBean[]>(); } for (MultiKey<EventBean> key : events) { EventBean[] eventsPerStream = key.getArray(); Boolean passesHaving = (Boolean) optionalHavingNode.evaluate(eventsPerStream, isNewData, exprEvaluatorContext); if ((passesHaving == null) || (!passesHaving)) { continue; } EventBean resultEvent = exprProcessor.process(eventsPerStream, isNewData, isSynthesize, exprEvaluatorContext); result.add(resultEvent); if (orderByProcessor != null) { eventGenerators.add(eventsPerStream); } } if (!result.isEmpty()) { if (orderByProcessor != null) { return orderByProcessor.sort(result.toArray(new EventBean[result.size()]), eventGenerators.toArray(new EventBean[eventGenerators.size()][]), isNewData, exprEvaluatorContext); } else { return result.toArray(new EventBean[result.size()]); } } else { return null; } }
From source file:alma.acs.tmcdb.compare.TestHighLevelNodes.java
private String[] getSubNodes(DAL dal, String subnode) throws Exception { ArrayList<String> subnodes = new ArrayList<String>(); LinkedList<String> stack = new LinkedList<String>(); stack.addLast(subnode);//from w w w .ja va2 s .c om while (!stack.isEmpty()) { String parentNode = stack.removeLast().toString(); String nodes = dal.list_nodes(parentNode); if (nodes.length() > 0) { StringTokenizer tokenizer = new StringTokenizer(nodes); while (tokenizer.hasMoreTokens()) { String nodeName = tokenizer.nextToken(); if (nodeName.endsWith(".xml")) continue; String fullName = parentNode + "/" + nodeName; stack.addLast(fullName); // strip off relative path subnodes.add(fullName.substring(subnode.length() + 1)); } } } String[] retVal = new String[subnodes.size()]; subnodes.toArray(retVal); return retVal; }
From source file:bamboo.openhash.fileshare.FileShare.java
/** * Transfer wblocks from the wblocks array to the ready queue. *//*from ww w. jav a 2 s. c o m*/ public void make_parents(boolean done) { for (int l = 0; l < wblocks.size(); ++l) { logger.debug("level " + l + " of " + wblocks.size() + " size=" + wblocks.elementAt(l).size() + " done=" + done); while ((wblocks.elementAt(l).size() >= BRANCHING) || (done && (wblocks.elementAt(l).size() > 1))) { int count = min(BRANCHING, wblocks.elementAt(l).size()); logger.debug("count=" + count); for (int i = 0; i < count; ++i) { ByteBuffer bb = wblocks.elementAt(l).removeFirst(); bb.flip(); md.update(secret); md.update(bb.array(), 0, bb.limit()); byte[] dig = md.digest(); ready.addLast(new Pair<byte[], ByteBuffer>(dig, bb)); if (l + 1 >= wblocks.size()) { wblocks.setSize(max(wblocks.size(), l + 2)); wblocks.setElementAt(new LinkedList<ByteBuffer>(), l + 1); } LinkedList<ByteBuffer> next_level = wblocks.elementAt(l + 1); if (next_level.isEmpty() || (next_level.getLast().position() == 1024)) { logger.debug("adding a new block to level " + (l + 1)); next_level.addLast(ByteBuffer.wrap(new byte[1024])); next_level.getLast().putInt(l + 1); } logger.debug("adding a digest to level " + (l + 1)); next_level.getLast().put(dig); } if (done) break; } } logger.debug("make_parents done"); }