private Expression createFunction(String name, int noOfMembers) throws SAXPathException { if (noOfMembers == 0) { if (name.equals("position")) { Step step = stepStack.peekLast(); if (step != null) { int axis = step.axis; if (axis == Axis.SELF || ((axis == Axis.ATTRIBUTE || axis == Axis.NAMESPACE) && step.constraint instanceof QName) || step.predicateSet.getPredicate() instanceof ExactPosition) return new Literal(DataType.ONE, DataType.NUMBER); } return new Position(); } else if (name.equals("last")) { Step step = stepStack.peekLast(); if (step != null) { int axis = step.axis; if (axis == Axis.SELF || ((axis == Axis.ATTRIBUTE || axis == Axis.NAMESPACE) && step.constraint instanceof QName) || step.predicateSet.getPredicate() instanceof ExactPosition) return new Literal(DataType.ONE, DataType.NUMBER); } return new Last(); } else if (name.equals("true")) return new Literal(Boolean.TRUE, DataType.BOOLEAN); else if (name.equals("false")) return new Literal(Boolean.FALSE, DataType.BOOLEAN); } Function function = Functions.library.get(name); if (function == null) throw new SAXPathException("Unknown function: " + name); return new FunctionCall(function, noOfMembers); }
private void displayOutput(String site, String restoredAccount) { // Get a reference to the layout where the card will be displayed final LinearLayout layout = (LinearLayout) findViewById(R.id.now_layout); // Create the View for the card final CardView card = new CardView(this); // Specify layout parameters to be applied LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.setMargins(0, 20, 0, 0); // Set the internal state of the card card.setSite(site); // Show the prettier string if available if (siteNames.containsKey(site)) { card.setSiteHeaderText(siteNames.get(site)); } else { card.setSiteHeaderText(site); } // Check if account is specified or pick the most recent from the search history if not if (restoredAccount == null) { if (!searchHistory.isEmpty()) { card.setSiteAccountText("Compromised: " + searchHistory.peekLast()); } } else { card.setSiteAccountText(restoredAccount); } if (siteDescriptions.containsKey(site)) { card.setSiteDescriptionText(siteDescriptions.get(site)); } else { card.setSiteDescriptionText(getString(R.string.card_description_unavailable)); } card.setLayoutParams(lp); // Create the swipe-to-dismiss touch listener. card.setOnTouchListener( new SwipeDismissTouchListener( card, null, new SwipeDismissTouchListener.DismissCallbacks() { @Override public boolean canDismiss(Object token) { return true; } @Override public void onDismiss(View view, Object token) { layout.removeView(card); } })); layout.addView(card); }
public void run() { super.run(); long currentTime = this.bh.getTime(); if (!auctionSubmissionTimes.isEmpty() && currentTime >= auctionSubmissionTimes.peekLast()) { auctionSubmissionTimes.removeLast(); submitAuction(); } }
// undo // 从undoQueue中删除并放到redoQueue中 public String undo() { String last = undoQueue.pollLast(); if (last != null) { redoQueue.addLast(last); } return undoQueue.peekLast(); }
void handleWorkUnitComplete(WorkUnit w) { for (int depId : w.getDependencyIds()) { m_missingDependencies.remove(depId); } // slide this new stack frame drop into the right position // (before any other stack frame drops) if ((w.shouldResumeProcedure()) && (m_readyWorkUnits.peekLast() != null) && (m_readyWorkUnits.peekLast().shouldResumeProcedure())) { ArrayDeque<WorkUnit> deque = new ArrayDeque<WorkUnit>(); while ((m_readyWorkUnits.peekLast() != null) && (m_readyWorkUnits.peekLast().shouldResumeProcedure())) { deque.add(m_readyWorkUnits.pollLast()); } deque.add(w); while (deque.size() > 0) m_readyWorkUnits.add(deque.pollLast()); } else { m_readyWorkUnits.add(w); } }
/** peeks into current frame */ private Object peek() { return peekFrame.peekLast(); }
private ArrayDeque popFrame() { ArrayDeque frame = frames.pollLast(); peekFrame = frames.peekLast(); return frame; }
/** * Add a {@link Doc.Break} to the current {@link Doc.Level}. * * @param breakDoc the {@link Doc.Break} */ void breakDoc(Doc.Break breakDoc) { appendLevel = stack.peekLast(); appendLevel.add(breakDoc); }
/** Close the current {@link Doc.Level}. */ void close() { Doc.Level top = stack.removeLast(); stack.peekLast().add(top); }