Example usage for java.util ListIterator hasNext

List of usage examples for java.util ListIterator hasNext

Introduction

In this page you can find the example usage for java.util ListIterator hasNext.

Prototype

boolean hasNext();

Source Link

Document

Returns true if this list iterator has more elements when traversing the list in the forward direction.

Usage

From source file:com.adobe.acs.commons.httpcache.config.impl.HttpCacheConfigImpl.java

@Activate
protected void activate(Map<String, Object> configs) {

    // Request URIs - Whitelisted.
    requestUriPatterns = Arrays/*ww  w .jav a2s  .  c  om*/
            .asList(PropertiesUtil.toStringArray(configs.get(PROP_REQUEST_URI_PATTERNS), new String[] {}));
    requestUriPatternsAsRegEx = compileToPatterns(requestUriPatterns);

    // Request URIs - Blacklisted.
    blacklistedRequestUriPatterns = Arrays.asList(
            PropertiesUtil.toStringArray(configs.get(PROP_BLACKLISTED_REQUEST_URI_PATTERNS), new String[] {}));
    blacklistedRequestUriPatternsAsRegEx = compileToPatterns(blacklistedRequestUriPatterns);

    // Authentication requirement.
    authenticationRequirement = PropertiesUtil.toString(configs.get(PROP_AUTHENTICATION_REQUIREMENT),
            DEFAULT_AUTHENTICATION_REQUIREMENT);

    // Cache store
    cacheStore = PropertiesUtil.toString(configs.get(PROP_CACHE_STORE), DEFAULT_CACHE_STORE);

    // Cache invalidation paths.
    cacheInvalidationPathPatterns = Arrays.asList(
            PropertiesUtil.toStringArray(configs.get(PROP_CACHE_INVALIDATION_PATH_PATTERNS), new String[] {}));
    cacheInvalidationPathPatternsAsRegEx = compileToPatterns(cacheInvalidationPathPatterns);

    order = PropertiesUtil.toInteger(configs.get(PROP_ORDER), DEFAULT_ORDER);

    filterScope = FilterScope.valueOf(
            PropertiesUtil.toString(configs.get(PROP_FILTER_SCOPE), DEFAULT_FILTER_SCOPE).toUpperCase());

    // PIDs of cache handling rules.
    cacheHandlingRulesPid = new ArrayList<String>(Arrays
            .asList(PropertiesUtil.toStringArray(configs.get(PROP_CACHE_HANDLING_RULES_PID), new String[] {})));
    ListIterator<String> listIterator = cacheHandlingRulesPid.listIterator();
    while (listIterator.hasNext()) {
        String value = listIterator.next();
        if (StringUtils.isBlank(value)) {
            listIterator.remove();
        }
    }

    log.info("HttpCacheConfigImpl activated.");
}

From source file:de.codesourcery.asm.controlflow.AbstractBlock.java

@Override
public int getIndexOfSuperConstructorCall(MethodNode method) {
    if (!method.name.equals("<init>")) {
        return -1;
    }/*  w w w .ja  va  2 s  .c  o  m*/

    @SuppressWarnings("unchecked")
    final ListIterator<AbstractInsnNode> iterator = method.instructions.iterator();
    for (int index = 0; iterator.hasNext(); index++) {
        final AbstractInsnNode instruction = iterator.next();
        if (containsInstructionNum(index) && instruction.getOpcode() == Opcodes.INVOKESPECIAL) {
            final MethodInsnNode invocation = (MethodInsnNode) instruction;
            if (invocation.name.equals("<init>")) {
                return index;
            }
        }
    }
    return -1;
}

From source file:de.codesourcery.asm.controlflow.AbstractBlock.java

@Override
public String disassemble(MethodNode method, boolean includeVirtual, boolean printInsnIndices) {

    final StringBuilder builder = new StringBuilder();

    @SuppressWarnings("unchecked")
    final ListIterator<AbstractInsnNode> iterator = method.instructions.iterator();
    for (int index = 0; iterator.hasNext(); index++) {
        final AbstractInsnNode instruction = iterator.next();

        if (containsInstructionNum(index)) {
            String line = Disassembler.disassemble(instruction, method, includeVirtual, printInsnIndices);
            if (line != null) {
                if (builder.length() > 0) {
                    builder.append("\n");
                }/*from   w ww  . j  a  v  a 2 s.  c  om*/
                builder.append(line);
            }
        }
    }
    return builder.toString();
}

From source file:de.codesourcery.asm.controlflow.AbstractBlock.java

@Override
public int getByteCodeInstructionCount(MethodNode method) {

    final InsnList instructions = method.instructions;
    @SuppressWarnings("unchecked")
    final ListIterator<AbstractInsnNode> iterator = instructions.iterator();

    int count = 0;
    for (int index = 0; iterator.hasNext(); index++) {
        final AbstractInsnNode node = iterator.next();
        if (containsInstructionNum(index)) {
            final int opCode = node.getOpcode();
            if (opCode >= 0 && opCode < Printer.OPCODES.length) {
                count++;//from  w  w  w. j  av a 2  s  . c  o  m
            }
        }
    }
    return count;
}

From source file:com.caricah.iotracah.datastore.ignitecache.internal.impl.SubscriptionFilterHandler.java

public Observable<IotSubscriptionFilter> createTree(String partitionId, List<String> topicFilterTreeRoute) {

    return Observable.create(observer -> {

        try {/*  w  w  w  . ja v  a 2  s . c  om*/

            List<String> growingTitles = new ArrayList<>();
            LinkedList<Long> growingParentIds = new LinkedList<>();

            ListIterator<String> pathIterator = topicFilterTreeRoute.listIterator();

            while (pathIterator.hasNext()) {

                growingTitles.add(pathIterator.next());

                IotSubscriptionFilterKey iotSubscriptionFilterKey = keyFromList(partitionId, growingTitles);
                Observable<IotSubscriptionFilter> filterObservable = getByKeyWithDefault(
                        iotSubscriptionFilterKey, null);

                filterObservable.subscribe(internalSubscriptionFilter -> {

                    if (null == internalSubscriptionFilter) {
                        internalSubscriptionFilter = new IotSubscriptionFilter();
                        internalSubscriptionFilter.setPartitionId(partitionId);
                        internalSubscriptionFilter.setName(iotSubscriptionFilterKey.getName());
                        internalSubscriptionFilter.setId(getIdSequence().incrementAndGet());

                        if (growingParentIds.isEmpty()) {
                            internalSubscriptionFilter.setParentId(0l);
                        } else {
                            internalSubscriptionFilter.setParentId(growingParentIds.getLast());
                        }
                        save(iotSubscriptionFilterKey, internalSubscriptionFilter);
                    }

                    growingParentIds.add(internalSubscriptionFilter.getId());

                    if (growingTitles.size() == topicFilterTreeRoute.size())
                        observer.onNext(internalSubscriptionFilter);

                }, throwable -> {
                }, () -> {

                    if (!pathIterator.hasNext()) {

                        observer.onCompleted();

                    }

                });
            }

        } catch (Exception e) {
            observer.onError(e);
        }

    });
}

From source file:com.danga.camli.UploadThread.java

private void filterOutBlobRef(String blobRef) {
    // TODO: kinda lame, iterating over whole list.
    ListIterator<QueuedFile> iter = mQueue.listIterator();
    while (iter.hasNext()) {
        QueuedFile qf = iter.next();/*from  w  w  w . j a  v  a2  s.  c o m*/
        if (qf.getContentName().equals(blobRef)) {
            iter.remove();
            mService.onUploadComplete(qf, false /* not uploaded */);
        }
    }
}

From source file:org.powertac.householdcustomer.persons.Person.java

/**
 * This function fills out the vector containing the days that the person is
 * going to be sick. When a person is sick he stays in the household.
 * /*from www.  ja  va  2 s  . c o m*/
 * @param mean
 * @param dev
 * @param gen
 * @return
 */
Vector<Integer> createSicknessVector(double mean, double dev) {
    // Create auxiliary variables

    int days = (int) (dev * gen.nextGaussian() + mean);
    Vector<Integer> v = new Vector<Integer>(days);

    for (int i = 0; i < days; i++) {
        int x = gen.nextInt(VillageConstants.DAYS_OF_COMPETITION + VillageConstants.DAYS_OF_BOOTSTRAP) + 1;
        ListIterator<Integer> iter = v.listIterator();
        while (iter.hasNext()) {
            int temp = (int) iter.next();
            if (x == temp) {
                x = x + 1;
                iter = v.listIterator();
            }
        }
        v.add(x);
    }
    java.util.Collections.sort(v);
    return v;
}

From source file:msearch.filmlisten.MSFilmlisteSchreiben.java

private void xmlSchreibenFilmliste(ListeFilme listeFilme) throws XMLStreamException {
    //Filmliste Metadaten schreiben
    listeFilme.metaDaten[ListeFilme.FILMLISTE_VERSION_NR] = MSConst.VERSION_FILMLISTE;
    xmlSchreibenDaten(ListeFilme.FILMLISTE, ListeFilme.COLUMN_NAMES, listeFilme.metaDaten);
    // Feldinfo schreiben
    int xmlMax = DatenFilm.COLUMN_NAMES.length;
    try {// w  w  w  . j a  va  2  s .c  om
        writer.writeStartElement(DatenFilm.FELD_INFO);
        writer.writeCharacters("\n");//neue Zeile
        for (int i = 0; i < xmlMax; ++i) {
            writer.writeStartElement(DatenFilm.COLUMN_NAMES_XML[i]);
            writer.writeCharacters(DatenFilm.COLUMN_NAMES[i]);
            writer.writeEndElement();
            writer.writeCharacters("\n");//neue Zeile
        }
        writer.writeEndElement();
        writer.writeCharacters("\n");//neue Zeile
    } catch (Exception ex) {
        MSLog.fehlerMeldung(638214005, MSLog.FEHLER_ART_PROG, "IoXmlSchreiben.xmlSchreibenFeldInfo", ex);
    }
    // Filme schreiben
    ListIterator<DatenFilm> iterator;
    DatenFilm datenFilm;
    String sender = "", thema = "";
    DatenFilm datenFilmSchreiben = new DatenFilm();
    iterator = listeFilme.listIterator();
    while (iterator.hasNext()) {
        datenFilm = iterator.next();
        System.arraycopy(datenFilm.arr, 0, datenFilmSchreiben.arr, 0, datenFilm.arr.length);
        if (sender.equals(datenFilm.arr[DatenFilm.FILM_SENDER_NR])) {
            datenFilmSchreiben.arr[DatenFilm.FILM_SENDER_NR] = "";
        } else {
            sender = datenFilm.arr[DatenFilm.FILM_SENDER_NR];
        }
        if (thema.equals(datenFilm.arr[DatenFilm.FILM_THEMA_NR])) {
            datenFilmSchreiben.arr[DatenFilm.FILM_THEMA_NR] = "";
        } else {
            thema = datenFilm.arr[DatenFilm.FILM_THEMA_NR];
        }
        datenFilmSchreiben.clean();
        xmlSchreibenDaten(DatenFilm.FILME_, DatenFilm.COLUMN_NAMES_XML, datenFilmSchreiben.arr);
    }
}

From source file:es.tid.fiware.rss.service.SettlementManager.java

/**
 * Get files from path.//  w w w. ja  v  a 2 s.  c om
 * 
 * @param path
 * @return
 */
public List<RSSFile> getSettlementFilesOfPath(String path) {
    // Opening/creating the folder
    File folder = new File(path);
    List<RSSFile> rssFilesList = new ArrayList<RSSFile>();
    RSSFile rssf = new RSSFile();

    if (folder.exists() && folder.isDirectory()) {
        File[] files = folder.listFiles();
        Arrays.sort(files);

        if (files.length > 0) {
            List<File> fileList = new ArrayList<File>(Arrays.asList(files));
            ListIterator<File> lit = fileList.listIterator();

            while (lit.hasNext()) {
                File file = lit.next();
                logger.info(file.getAbsolutePath());

                if (file.isDirectory()) {
                    logger.debug("Is directory. Getting more files...");
                    File[] moreFiles = file.listFiles();
                    Arrays.sort(moreFiles);
                    if (moreFiles.length > 0) {
                        for (File f : moreFiles) {
                            lit.add(f);
                            lit.previous();
                        }
                    }
                } else {
                    rssf = new RSSFile();
                    rssf.setTxName(file.getName());
                    rssf.setTxUrl(file.getAbsolutePath());
                    rssFilesList.add(rssf);
                    logger.debug("File added");
                }
            }
        }
    }
    return rssFilesList;
}

From source file:com.clearcenter.mobile_demo.mdStatusActivity.java

public void updateData() {
    JSONObject json_data;/* www  . j av a 2s  .com*/

    String projection[] = new String[] { mdDeviceSamples.DATA };

    Cursor cursor = getContentResolver().query(mdDeviceSamples.CONTENT_URI, projection,
            mdDeviceSamples.NICKNAME + " = ?", new String[] { account_nickname }, null);

    int rows = 0;
    try {
        rows = cursor.getCount();
    } catch (NullPointerException e) {
    }

    Log.d(TAG, "Matches: " + rows);

    if (rows == 0) {
        Log.d(TAG, "No rows match for nickname: " + account_nickname);
        cursor.close();
        return;
    }

    cursor.moveToLast();

    String data = cursor.getString(cursor.getColumnIndex(mdDeviceSamples.DATA));

    try {
        json_data = new JSONObject(data);
        if (json_data.has("hostname"))
            hostname_textview.setText("Hostname: " + json_data.getString("hostname"));
        if (json_data.has("name") && json_data.has("release")) {
            final String release = json_data.getString("name") + " " + json_data.getString("release");
            release_textview.setText("Release: " + release);
        }
        if (json_data.has("time_locale")) {
            time_textview.setText("Clock: " + json_data.getString("time_locale"));
        }

        if (rows >= 2) {
            bw_graphview.reset();
            loadavg_graphview.reset();
            mem_graphview.reset();

            if (rows <= samples)
                cursor.moveToFirst();
            else
                cursor.move(-samples);

            long unix_time = 0;
            double bw_up = 0.0;
            double bw_down = 0.0;

            do {
                data = cursor.getString(cursor.getColumnIndex(mdDeviceSamples.DATA));

                final List<JSONObject> samples = sortedSamplesList(data);
                ListIterator<JSONObject> li = samples.listIterator();

                while (li.hasNext()) {
                    json_data = li.next();

                    if (unix_time == 0) {
                        bw_up = json_data.getDouble("bandwidth_up");
                        bw_down = json_data.getDouble("bandwidth_down");
                        unix_time = Long.valueOf(json_data.getString("time"));
                        continue;
                    }

                    long diff = Long.valueOf(json_data.getString("time")) - unix_time;

                    double rate_up = (json_data.getDouble("bandwidth_up") - bw_up) / diff;
                    double rate_down = (json_data.getDouble("bandwidth_down") - bw_down) / diff;

                    if (rate_up < 0.0)
                        rate_up = 0.0;
                    if (rate_down < 0.0)
                        rate_down = 0.0;

                    bw_graphview.addSample(bw_graph_up, unix_time, (float) rate_up);
                    bw_graphview.addSample(bw_graph_down, unix_time, (float) rate_down);

                    //                        Log.d(TAG, "time: " + diff +
                    //                            ", rate_up: " + rate_up + ", rate_down: " + rate_down);
                    bw_up = json_data.getDouble("bandwidth_up");
                    bw_down = json_data.getDouble("bandwidth_down");

                    loadavg_graphview.addSample(loadavg_graph_5min, unix_time,
                            (float) json_data.getDouble("loadavg_5min"));
                    loadavg_graphview.addSample(loadavg_graph_15min, unix_time,
                            (float) json_data.getDouble("loadavg_15min"));

                    mem_graphview.addSample(mem_graph_active, unix_time,
                            (float) json_data.getDouble("mem_active"));
                    mem_graphview.addSample(mem_graph_swap, unix_time,
                            (float) json_data.getDouble("mem_swap_used"));

                    unix_time = Long.valueOf(json_data.getString("time"));
                }
            } while (cursor.moveToNext());

            bw_graphview.update();
            loadavg_graphview.update();
            mem_graphview.update();
        }
    } catch (JSONException e) {
        Log.e(TAG, "JSONException", e);
    }

    cursor.close();
}