use of java.util.Iterator in project platform_frameworks_base by android.
the class ActivityManagerService method dumpBroadcastsLocked.
void dumpBroadcastsLocked(FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, String dumpPackage) {
boolean needSep = false;
boolean onlyHistory = false;
boolean printedAnything = false;
if ("history".equals(dumpPackage)) {
if (opti < args.length && "-s".equals(args[opti])) {
dumpAll = false;
}
onlyHistory = true;
dumpPackage = null;
}
pw.println("ACTIVITY MANAGER BROADCAST STATE (dumpsys activity broadcasts)");
if (!onlyHistory && dumpAll) {
if (mRegisteredReceivers.size() > 0) {
boolean printed = false;
Iterator it = mRegisteredReceivers.values().iterator();
while (it.hasNext()) {
ReceiverList r = (ReceiverList) it.next();
if (dumpPackage != null && (r.app == null || !dumpPackage.equals(r.app.info.packageName))) {
continue;
}
if (!printed) {
pw.println(" Registered Receivers:");
needSep = true;
printed = true;
printedAnything = true;
}
pw.print(" * ");
pw.println(r);
r.dump(pw, " ");
}
}
if (mReceiverResolver.dump(pw, needSep ? "\n Receiver Resolver Table:" : " Receiver Resolver Table:", " ", dumpPackage, false, false)) {
needSep = true;
printedAnything = true;
}
}
for (BroadcastQueue q : mBroadcastQueues) {
needSep = q.dumpLocked(fd, pw, args, opti, dumpAll, dumpPackage, needSep);
printedAnything |= needSep;
}
needSep = true;
if (!onlyHistory && mStickyBroadcasts != null && dumpPackage == null) {
for (int user = 0; user < mStickyBroadcasts.size(); user++) {
if (needSep) {
pw.println();
}
needSep = true;
printedAnything = true;
pw.print(" Sticky broadcasts for user ");
pw.print(mStickyBroadcasts.keyAt(user));
pw.println(":");
StringBuilder sb = new StringBuilder(128);
for (Map.Entry<String, ArrayList<Intent>> ent : mStickyBroadcasts.valueAt(user).entrySet()) {
pw.print(" * Sticky action ");
pw.print(ent.getKey());
if (dumpAll) {
pw.println(":");
ArrayList<Intent> intents = ent.getValue();
final int N = intents.size();
for (int i = 0; i < N; i++) {
sb.setLength(0);
sb.append(" Intent: ");
intents.get(i).toShortString(sb, false, true, false, false);
pw.println(sb.toString());
Bundle bundle = intents.get(i).getExtras();
if (bundle != null) {
pw.print(" ");
pw.println(bundle.toString());
}
}
} else {
pw.println("");
}
}
}
}
if (!onlyHistory && dumpAll) {
pw.println();
for (BroadcastQueue queue : mBroadcastQueues) {
pw.println(" mBroadcastsScheduled [" + queue.mQueueName + "]=" + queue.mBroadcastsScheduled);
}
pw.println(" mHandler:");
mHandler.dump(new PrintWriterPrinter(pw), " ");
needSep = true;
printedAnything = true;
}
if (!printedAnything) {
pw.println(" (nothing)");
}
}
use of java.util.Iterator in project freeline by alibaba.
the class GroovyFileUil method getLastPlugin.
/**
* 获取最后一个插件的表达式
*
* @param buildScript
* @return
*/
public static GrExpression getLastPlugin(GroovyFile buildScript) {
Iterator var2 = getMethodCalls(buildScript, "apply").iterator();
GrExpression expression = null;
while (var2.hasNext()) {
GrMethodCall methodCall = (GrMethodCall) var2.next();
expression = methodCall.getInvokedExpression();
}
return expression;
}
use of java.util.Iterator in project jstorm by alibaba.
the class TransferDrainer method getBundleIterator.
private Iterator<TaskMessage> getBundleIterator(final ArrayList<ArrayList<TaskMessage>> bundle) {
if (null == bundle) {
return null;
}
return new Iterator<TaskMessage>() {
private int offset = 0;
private int size = 0;
{
for (ArrayList<TaskMessage> list : bundle) {
size += list.size();
}
}
private int bundleOffset = 0;
private Iterator<TaskMessage> iter = bundle.get(bundleOffset).iterator();
@Override
public boolean hasNext() {
if (offset < size) {
return true;
}
return false;
}
@Override
public TaskMessage next() {
TaskMessage msg = null;
if (iter.hasNext()) {
msg = iter.next();
} else {
bundleOffset++;
iter = bundle.get(bundleOffset).iterator();
msg = iter.next();
}
if (null != msg) {
offset++;
}
return msg;
}
@Override
public void remove() {
throw new RuntimeException("not supported");
}
};
}
use of java.util.Iterator in project Conversations by siacs.
the class DatabaseBackend method getMessagesIterable.
public Iterable<Message> getMessagesIterable(final Conversation conversation) {
return new Iterable<Message>() {
@Override
public Iterator<Message> iterator() {
class MessageIterator implements Iterator<Message> {
SQLiteDatabase db = getReadableDatabase();
String[] selectionArgs = { conversation.getUuid() };
Cursor cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION + "=?", selectionArgs, null, null, Message.TIME_SENT + " ASC", null);
public MessageIterator() {
cursor.moveToFirst();
}
@Override
public boolean hasNext() {
return !cursor.isAfterLast();
}
@Override
public Message next() {
Message message = Message.fromCursor(cursor);
cursor.moveToNext();
return message;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
}
return new MessageIterator();
}
};
}
use of java.util.Iterator in project lombok by rzwitserloot.
the class FileSystemSourceCache method sourcesForDirectory.
private Iterable<ConfigurationSource> sourcesForDirectory(final File directory, final ConfigurationProblemReporter reporter) {
return new Iterable<ConfigurationSource>() {
@Override
public Iterator<ConfigurationSource> iterator() {
return new Iterator<ConfigurationSource>() {
File currentDirectory = directory;
ConfigurationSource next;
boolean stopBubbling = false;
@Override
public boolean hasNext() {
if (next != null)
return true;
if (stopBubbling)
return false;
next = findNext();
return next != null;
}
@Override
public ConfigurationSource next() {
if (!hasNext())
throw new NoSuchElementException();
ConfigurationSource result = next;
next = null;
return result;
}
private ConfigurationSource findNext() {
while (currentDirectory != null && next == null) {
next = getSourceForDirectory(currentDirectory, reporter);
currentDirectory = currentDirectory.getParentFile();
}
if (next != null) {
Result stop = next.resolve(ConfigurationKeys.STOP_BUBBLING);
stopBubbling = (stop != null && Boolean.TRUE.equals(stop.getValue()));
}
return next;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
Aggregations