List of usage examples for java.util ListIterator hasPrevious
boolean hasPrevious();
From source file:com.nettyhttpserver.server.util.HttpRequestHandler.java
private static String generateStatus() { List<ServerRequestDTO> serverRequestList = serverRequestService.getServerRequest(); List<RedirectRequestDTO> redirectRequestList = redirectRequestService.getRedirectRequest(); StringBuilder sb = new StringBuilder(); sb.append(/* ww w. j a v a2 s. co m*/ "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><head>") .append( /* * Table style */ "<head>") .append("<style>") .append("table, td {border: solid 1px grey;background-color: rgb(233, 233, 233); margin: 0 auto;") .append("}table {width:90%;text-align: left; font-size: 16pt; bont-weight: bolder;}td{padding: 10px;}") .append("</style>").append("</head>") /* * Requests count */ .append("<h3>Server request count: ").append(serverRequestService.getRequestCount()) .append("<br>Server unique requests count: ").append(serverRequestService.getUniqueRequestCount()) .append("</h3>").append("<br><h3>Open connections: ").append(allChannels.size()).append("</h3>") /* * Table of server requests */ .append("<br><table id=\"table\"><caption>Server requests(last 100 )</caption> ") .append("<thead><tr> <th>IP</th><th>Count</th>") .append("<th>Last Request</th> </tr></thead><tbody> "); for (ServerRequestDTO record : serverRequestList) { sb.append("<tr><td>").append(record.getIP()).append("</td><td>").append(record.getRequestCount()) .append("</td><td>").append(record.getLastTimestamp()).append("</td></tr>"); } sb.append("</tbody></table>"); /* * Table of redirect requests */ sb.append("<table id=\"table\"><caption>Redirect requests(last 100 )</caption> ") .append("<thead><tr><th>URL</th>").append("<th>Count</th> </tr></thead><tbody> "); for (RedirectRequestDTO record : redirectRequestList) { sb.append("<tr><td>").append(record.getUrl()).append("</td><td>").append(record.getCount()) .append("</td>"); } sb.append("</tbody></table>"); /* * Table of server connections columns src_ip, URI, timestamp, * sent_bytes, received_bytes, speed (bytes/sec) */ sb.append("<table id=\"table\"><caption>Last 16 connections").append("</caption>") .append("<tr> <th>IP</th><th>URI</th>") .append("<th>TimeStamp</th><th>Sent</th><th>Recieved</th><th>Speed</th> </tr> "); ListIterator<ConnectionInfoDTO> iterator = NettyChannelTrafficShapingHandler .getServerConnectionListIterator(); synchronized (iterator) { while (iterator.hasPrevious()) { ConnectionInfoDTO item = iterator.previous(); sb.append("<tr><td>").append(item.getIp()).append("</td><td>").append(item.getUri()) .append("</td><td>").append(item.getTimestamp().toLocalDateTime()).append("</td><td>") .append(item.getSentBytes()).append("</td><td>").append(item.getRecivedBytes()) .append("</td><td>").append(item.getSpeed()).append("</td></tr>"); } } sb.append("</table>"); return sb.toString(); }
From source file:com.psiphon3.psiphonlibrary.StatusList.java
/** * @return Returns the last non-DEBUG, non-WARN(ing) item, or null if there is none. *///from ww w .j a va 2s. co m public static StatusEntry getLastStatusEntryForDisplay() { synchronized (m_statusHistory) { ListIterator<StatusEntry> iterator = m_statusHistory.listIterator(m_statusHistory.size()); while (iterator.hasPrevious()) { StatusEntry current_item = iterator.previous(); if (current_item.priority() != Log.DEBUG && current_item.priority() != Log.WARN) { return current_item; } } return null; } }
From source file:com.qualogy.qafe.core.errorhandling.ErrorProcessor.java
private static void goBackToItemPosition(ListIterator<? extends Item> itrItem, Item targetItem, ApplicationContext context, Window window) { if (itrItem != null) { boolean found = false; while (itrItem.hasPrevious()) { Item item = itrItem.previous(); if (item == targetItem) { found = true;/*from ww w . j a va 2s.co m*/ } else if (item instanceof EventRef) { found = containsItem((EventRef) item, targetItem, context, window); } if (found) { itrItem.next(); break; } } } }
From source file:org.smssecure.smssecure.notifications.MessageNotifier.java
private static void sendSingleThreadNotification(Context context, MasterSecret masterSecret, NotificationState notificationState, int flags, boolean bundled) { if (notificationState.getNotifications().isEmpty()) { if (!bundled) cancelActiveNotifications(context); return;/*from ww w.j ava 2s.c o m*/ } SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder(context, masterSecret, SilencePreferences.getNotificationPrivacy(context)); List<NotificationItem> notifications = notificationState.getNotifications(); Recipients recipients = notifications.get(0).getRecipients(); int notificationId = (int) (SUMMARY_NOTIFICATION_ID + (bundled ? notifications.get(0).getThreadId() : 0)); builder.setThread(notifications.get(0).getRecipients()); builder.setMessageCount(notificationState.getMessageCount()); builder.setPrimaryMessageBody(recipients, notifications.get(0).getIndividualRecipient(), notifications.get(0).getText(), notifications.get(0).getSlideDeck()); builder.setContentIntent(notifications.get(0).getPendingIntent(context)); builder.setGroup(NOTIFICATION_GROUP); builder.setDeleteIntent(notificationState.getDeleteIntent(context)); long timestamp = notifications.get(0).getTimestamp(); if (timestamp != 0) builder.setWhen(timestamp); builder.addActions(masterSecret, notificationState.getMarkAsReadIntent(context, notificationId), notificationState.getQuickReplyIntent(context, notifications.get(0).getRecipients()), notificationState.getRemoteReplyIntent(context, notifications.get(0).getRecipients())); ListIterator<NotificationItem> iterator = notifications.listIterator(notifications.size()); while (iterator.hasPrevious()) { NotificationItem item = iterator.previous(); builder.addMessageBody(item.getRecipients(), item.getIndividualRecipient(), item.getText()); } if (notificationsRequested(flags)) { triggerNotificationAlarms(builder, notificationState, flags); builder.setTicker(notifications.get(0).getIndividualRecipient(), notifications.get(0).getText()); } if (!bundled) { builder.setGroupSummary(true); } NotificationManagerCompat.from(context).notify(notificationId, builder.build()); }
From source file:org.thoughtcrime.SMP.notifications.MessageNotifier.java
private static void sendMultipleThreadNotification(Context context, MasterSecret masterSecret, NotificationState notificationState, boolean signal) { List<NotificationItem> notifications = notificationState.getNotifications(); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setColor(context.getResources().getColor(R.color.textsecure_primary)); builder.setSmallIcon(R.drawable.icon_notification); builder.setContentTitle(context.getString(R.string.app_name)); builder.setSubText(context.getString(R.string.MessageNotifier_d_messages_in_d_conversations, notificationState.getMessageCount(), notificationState.getThreadCount())); builder.setContentText(context.getString(R.string.MessageNotifier_most_recent_from_s, notifications.get(0).getIndividualRecipientName())); builder.setContentIntent(//w w w .ja v a 2 s . co m PendingIntent.getActivity(context, 0, new Intent(context, ConversationListActivity.class), 0)); builder.setContentInfo(String.valueOf(notificationState.getMessageCount())); builder.setNumber(notificationState.getMessageCount()); builder.setCategory(NotificationCompat.CATEGORY_MESSAGE); long timestamp = notifications.get(0).getTimestamp(); if (timestamp != 0) builder.setWhen(timestamp); builder.setDeleteIntent( PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0)); if (masterSecret != null) { Action markAllAsReadAction = new Action(R.drawable.check, context.getString(R.string.MessageNotifier_mark_all_as_read), notificationState.getMarkAsReadIntent(context, masterSecret)); builder.addAction(markAllAsReadAction); builder.extend(new NotificationCompat.WearableExtender().addAction(markAllAsReadAction)); } InboxStyle style = new InboxStyle(); ListIterator<NotificationItem> iterator = notifications.listIterator(notifications.size()); while (iterator.hasPrevious()) { NotificationItem item = iterator.previous(); style.addLine(item.getTickerText()); if (item.getIndividualRecipient().getContactUri() != null) { builder.addPerson(item.getIndividualRecipient().getContactUri().toString()); } } builder.setStyle(style); setNotificationAlarms(context, builder, signal, notificationState.getRingtone(), notificationState.getVibrate()); if (signal) { builder.setTicker(notifications.get(0).getTickerText()); } ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, builder.build()); }
From source file:org.thoughtcrime.SMP.notifications.MessageNotifier.java
private static void sendSingleThreadNotification(Context context, MasterSecret masterSecret, NotificationState notificationState, boolean signal) { if (notificationState.getNotifications().isEmpty()) { ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).cancel(NOTIFICATION_ID); return;// w w w . j a v a 2 s . co m } List<NotificationItem> notifications = notificationState.getNotifications(); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); Recipient recipient = notifications.get(0).getIndividualRecipient(); Drawable recipientPhoto = recipient.getContactPhoto(); int largeIconTargetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size); if (recipientPhoto != null) { Bitmap recipientPhotoBitmap = BitmapUtil.createFromDrawable(recipientPhoto, largeIconTargetSize, largeIconTargetSize); if (recipientPhotoBitmap != null) builder.setLargeIcon(recipientPhotoBitmap); } builder.setSmallIcon(R.drawable.icon_notification); builder.setColor(context.getResources().getColor(R.color.textsecure_primary)); builder.setContentTitle(recipient.toShortString()); builder.setContentText(notifications.get(0).getText()); builder.setContentIntent(notifications.get(0).getPendingIntent(context)); builder.setContentInfo(String.valueOf(notificationState.getMessageCount())); builder.setPriority(NotificationCompat.PRIORITY_HIGH); builder.setNumber(notificationState.getMessageCount()); builder.setCategory(NotificationCompat.CATEGORY_MESSAGE); builder.setDeleteIntent( PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0)); if (recipient.getContactUri() != null) builder.addPerson(recipient.getContactUri().toString()); long timestamp = notifications.get(0).getTimestamp(); if (timestamp != 0) builder.setWhen(timestamp); if (masterSecret != null) { Action markAsReadAction = new Action(R.drawable.check, context.getString(R.string.MessageNotifier_mark_as_read), notificationState.getMarkAsReadIntent(context, masterSecret)); builder.addAction(markAsReadAction); builder.extend(new NotificationCompat.WearableExtender().addAction(markAsReadAction)); } SpannableStringBuilder content = new SpannableStringBuilder(); ListIterator<NotificationItem> iterator = notifications.listIterator(notifications.size()); while (iterator.hasPrevious()) { NotificationItem item = iterator.previous(); content.append(item.getBigStyleSummary()); content.append('\n'); } builder.setStyle(new BigTextStyle().bigText(content)); setNotificationAlarms(context, builder, signal, notificationState.getRingtone(), notificationState.getVibrate()); if (signal) { builder.setTicker(notifications.get(0).getTickerText()); } ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(NOTIFICATION_ID, builder.build()); }
From source file:org.xchain.framework.lifecycle.Lifecycle.java
/** * Stop all current lifecycle steps. The first step to be stopped is the last one started. *///from w w w. jav a2s.c o m private static void stopLifecycleSteps() { ListIterator<LifecycleStep> iterator = lifecycleStepList.listIterator(lifecycleStepList.size()); while (iterator.hasPrevious()) { LifecycleStep step = iterator.previous(); try { if (log.isInfoEnabled()) { log.info("Stopping Lifecycle Step '" + step.getQName() + "'."); } step.stopLifecycle(context); if (log.isInfoEnabled()) { log.info("Finished Lifecycle Step '" + step.getQName() + "'."); } } catch (Throwable t) { if (log.isWarnEnabled()) { log.warn("An exception was thrown while stopping a lifecycle exception.", t); } } } lifecycleStepList.clear(); }
From source file:com.example.app.support.service.AppUtil.java
/** * Get a valid source component from the component path. This is similar to * {@link ApplicationRegistry#getValidSourceComponent(Component)} but is able to find the source component even * when a pesky dialog is in the in way as long as the dialog had {@link #recordDialogsAncestorComponent(Dialog, Component)} * call on it.// ww w . j a v a 2s .c o m * * @param component the component to start the search on * * @return a valid source component that has an ApplicationFunction annotation. * * @throws IllegalArgumentException if a valid source component could not be found. */ @Nonnull public static Component getValidSourceComponentAcrossDialogs(Component component) { LinkedList<Component> path = new LinkedList<>(); do { path.add(component); if (component.getClientProperty(CLIENT_PROP_DIALOGS_ANCESTRY) instanceof Component) component = (Component) component.getClientProperty(CLIENT_PROP_DIALOGS_ANCESTRY); else component = component.getParent(); } while (component != null); final ListIterator<Component> listIterator = path.listIterator(path.size()); while (listIterator.hasPrevious()) { final Component previous = listIterator.previous(); if (previous.getClass().isAnnotationPresent(ApplicationFunction.class)) return previous; } throw new IllegalArgumentException("Component path does not contain an application function."); }
From source file:org.mycore.common.xml.MCRXMLFunctions.java
/** * Helper function for xslImport URI Resolver and {@link #hasNextImportStep(String)} * @param includePart substring after "xmlImport:" *///w w w .ja v a 2 s. c o m public static String nextImportStep(String includePart) { int border = includePart.indexOf(':'); String selfName = null; if (border > 0) { selfName = includePart.substring(border + 1); includePart = includePart.substring(0, border); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("get next import step for " + includePart); } // get the parameters from mycore.properties List<String> importList = Collections.emptyList(); importList = MCRConfiguration.instance().getStrings("MCR.URIResolver.xslImports." + includePart, importList); if (importList.isEmpty()) { LOGGER.info("MCR.URIResolver.xslImports." + includePart + " has no Stylesheets defined"); } else { ListIterator<String> listIterator = importList.listIterator(importList.size()); if (selfName == null && listIterator.hasPrevious()) { return listIterator.previous(); } while (listIterator.hasPrevious()) { String currentStylesheet = listIterator.previous(); if (currentStylesheet.equals(selfName)) { if (listIterator.hasPrevious()) { return listIterator.previous(); } else { LOGGER.debug("xslImport reached end of chain:" + importList); return ""; } } //continue; } LOGGER.warn("xslImport could not find " + selfName + " in " + importList); } return ""; }
From source file:edu.oregonstate.eecs.mcplan.SeriesAction.java
@Override public void undoAction(final S s) { assert (done_); final ListIterator<A> itr = actions_.listIterator(actions_.size()); while (itr.hasPrevious()) { itr.previous().undoAction(s);/*www . j a v a2 s.c o m*/ } done_ = false; }