Example usage for java.util ArrayList remove

List of usage examples for java.util ArrayList remove

Introduction

In this page you can find the example usage for java.util ArrayList remove.

Prototype

public boolean remove(Object o) 

Source Link

Document

Removes the first occurrence of the specified element from this list, if it is present.

Usage

From source file:com.arantius.tivocommander.Explore.java

protected void finishRequest() {
    if (--mRequestCount != 0) {
        return;//from w  w  w.j  av a 2  s.com
    }

    getParent().setProgressBarIndeterminateVisibility(false);

    if (mRecordingId == null) {
        for (JsonNode recording : mContent.path("recordingForContentId")) {
            String state = recording.path("state").asText();
            if ("inProgress".equals(state) || "complete".equals(state) || "scheduled".equals(state)) {
                mRecordingId = recording.path("recordingId").asText();
                mRecordingState = state;
                break;
            }
        }
    }

    // Fill mChoices based on the data we now have.
    if ("scheduled".equals(mRecordingState)) {
        mChoices.add(RecordActions.DONT_RECORD.toString());
    } else if ("inProgress".equals(mRecordingState)) {
        mChoices.add(RecordActions.RECORD_STOP.toString());
    } else if (mOfferId != null) {
        mChoices.add(RecordActions.RECORD.toString());
    }
    if (mSubscriptionId != null) {
        mChoices.add(RecordActions.SP_MODIFY.toString());
        mChoices.add(RecordActions.SP_CANCEL.toString());
    } else if (mCollectionId != null && !"movie".equals(mContent.path("collectionType").asText())
            && !mContent.has("movieYear")) {
        mChoices.add(RecordActions.SP_ADD.toString());
    }

    setContentView(R.layout.explore);

    // Show only appropriate buttons.
    findViewById(R.id.explore_btn_watch).setVisibility(
            "complete".equals(mRecordingState) || "inprogress".equals(mRecordingState) ? View.VISIBLE
                    : View.GONE);
    hideViewIfNull(R.id.explore_btn_upcoming, mCollectionId);
    if (mChoices.size() == 0) {
        findViewById(R.id.explore_btn_record).setVisibility(View.GONE);
    }
    // Delete / undelete buttons visible only if appropriate.
    findViewById(R.id.explore_btn_delete)
            .setVisibility("complete".equals(mRecordingState) ? View.VISIBLE : View.GONE);
    findViewById(R.id.explore_btn_undelete)
            .setVisibility("deleted".equals(mRecordingState) ? View.VISIBLE : View.GONE);

    // Display titles.
    String title = mContent.path("title").asText();
    String subtitle = mContent.path("subtitle").asText();
    ((TextView) findViewById(R.id.content_title)).setText(title);
    TextView subtitleView = ((TextView) findViewById(R.id.content_subtitle));
    if ("".equals(subtitle)) {
        subtitleView.setVisibility(View.GONE);
    } else {
        subtitleView.setText(subtitle);
    }

    // Display (only the proper) badges.
    if (mRecording != null && mRecording.path("episodic").asBoolean()
            && !mRecording.path("repeat").asBoolean()) {
        findViewById(R.id.badge_new).setVisibility(View.VISIBLE);
    }
    if (mRecording != null && mRecording.path("hdtv").asBoolean()) {
        findViewById(R.id.badge_hd).setVisibility(View.VISIBLE);
    }
    ImageView iconSubType = (ImageView) findViewById(R.id.icon_sub_type);
    TextView textSubType = (TextView) findViewById(R.id.text_sub_type);
    // TODO: Downloading state?
    if ("complete".equals(mRecordingState)) {
        iconSubType.setVisibility(View.GONE);
        textSubType.setVisibility(View.GONE);
    } else if ("inProgress".equals(mRecordingState)) {
        iconSubType.setImageResource(R.drawable.recording_recording);
        textSubType.setText(R.string.sub_recording);
    } else if (mSubscriptionType != null) {
        switch (mSubscriptionType) {
        case SEASON_PASS:
            iconSubType.setImageResource(R.drawable.todo_seasonpass);
            textSubType.setText(R.string.sub_season_pass);
            break;
        case SINGLE_OFFER:
            iconSubType.setImageResource(R.drawable.todo_single_offer);
            textSubType.setText(R.string.sub_single_offer);
            break;
        case WISHLIST:
            iconSubType.setImageResource(R.drawable.todo_wishlist);
            textSubType.setText(R.string.sub_wishlist);
            break;
        default:
            iconSubType.setVisibility(View.GONE);
            textSubType.setVisibility(View.GONE);
        }
    } else {
        iconSubType.setVisibility(View.GONE);
        textSubType.setVisibility(View.GONE);
    }

    // Display channel and time.
    if (mRecording != null) {
        String channelStr = "";
        JsonNode channel = mRecording.path("channel");
        if (!channel.isMissingNode()) {
            channelStr = String.format("%s %s, ", channel.path("channelNumber").asText(),
                    channel.path("callSign").asText());
        }

        // Lots of shows seem to be a few seconds short, add padding so that
        // rounding down works as expected. Magic number.
        final int minutes = (30 + mRecording.path("duration").asInt()) / 60;

        String durationStr = minutes >= 60 ? String.format(Locale.US, "%d hr", minutes / 60)
                : String.format(Locale.US, "%d min", minutes);
        if (isRecordingPartial()) {
            durationStr += " (partial)";
        }
        ((TextView) findViewById(R.id.content_chan_len)).setText(channelStr + durationStr);

        String airTime = new SimpleDateFormat("EEE MMM d, hh:mm a", Locale.US)
                .format(Utils.parseDateTimeStr(mRecording.path("actualStartTime").asText()));
        ((TextView) findViewById(R.id.content_air_time)).setText("Air time: " + airTime);
    } else {
        ((TextView) findViewById(R.id.content_chan_len)).setVisibility(View.GONE);
        ((TextView) findViewById(R.id.content_air_time)).setVisibility(View.GONE);
    }

    // Construct and display details.
    ArrayList<String> detailParts = new ArrayList<String>();
    int season = mContent.path("seasonNumber").asInt();
    int epNum = mContent.path("episodeNum").path(0).asInt();
    if (season != 0 && epNum != 0) {
        detailParts.add(String.format("Sea %d Ep %d", season, epNum));
    }
    if (mContent.has("mpaaRating")) {
        detailParts.add(mContent.path("mpaaRating").asText().toUpperCase(Locale.US));
    } else if (mContent.has("tvRating")) {
        detailParts.add("TV-" + mContent.path("tvRating").asText().toUpperCase(Locale.US));
    }
    detailParts.add(mContent.path("category").path(0).path("label").asText());
    int year = mContent.path("originalAirYear").asInt();
    if (year != 0) {
        detailParts.add(Integer.toString(year));
    }

    // Filter empty strings.
    for (int i = detailParts.size() - 1; i >= 0; i--) {
        if ("".equals(detailParts.get(i)) || null == detailParts.get(i)) {
            detailParts.remove(i);
        }
    }
    // Then format the parts into one string.
    String detail1 = "(" + Utils.join(", ", detailParts) + ") ";
    if ("() ".equals(detail1)) {
        detail1 = "";
    }

    String detail2 = mContent.path("description").asText();
    TextView detailView = ((TextView) findViewById(R.id.content_details));
    if (detail2 == null) {
        detailView.setText(detail1);
    } else {
        Spannable details = new SpannableString(detail1 + detail2);
        details.setSpan(new ForegroundColorSpan(Color.WHITE), detail1.length(), details.length(), 0);
        detailView.setText(details);
    }

    // Add credits.
    ArrayList<String> credits = new ArrayList<String>();
    for (JsonNode credit : mContent.path("credit")) {
        String role = credit.path("role").asText();
        if ("actor".equals(role) || "host".equals(role) || "guestStar".equals(role)) {
            credits.add(credit.path("first").asText() + " " + credit.path("last").asText());
        }
    }
    TextView creditsView = (TextView) findViewById(R.id.content_credits);
    creditsView.setText(Utils.join(", ", credits));

    // Find and set the banner image if possible.
    ImageView imageView = (ImageView) findViewById(R.id.content_image);
    View progressView = findViewById(R.id.content_image_progress);
    String imageUrl = Utils.findImageUrl(mContent);
    new DownloadImageTask(this, imageView, progressView).execute(imageUrl);
}

From source file:gate.creole.orthomatcher.OrthoMatcher.java

/** return an organization  without a designator and starting The*/
protected String normalizeOrganizationName(String annotString, Annotation annot) {

    ArrayList<Annotation> tokens = (ArrayList<Annotation>) tokensMap.get(annot.getId());

    //strip starting The first
    if (((String) tokens.get(0).getFeatures().get(TOKEN_STRING_FEATURE_NAME)).equalsIgnoreCase(THE_VALUE))
        tokens.remove(0);

    if (tokens.size() > 0) {

        // New code by A. Borthwick of Spock Networks
        // June 13, 2008
        // Strip everything on the cdg list, which now encompasses not just cdg's, but also other stopwords
        // Start from the right side so we don't mess up the arraylist
        for (int i = tokens.size() - 1; i >= 0; i--) {
            String tokenString = ((String) tokens.get(i).getFeatures().get(TOKEN_STRING_FEATURE_NAME));
            String kind = (String) tokens.get(i).getFeatures().get(TOKEN_KIND_FEATURE_NAME);
            String category = (String) tokens.get(i).getFeatures().get(TOKEN_CATEGORY_FEATURE_NAME);
            if (!caseSensitive) {
                tokenString = tokenString.toLowerCase();
            }/*  w  w  w.j  av a 2  s. com*/
            // Out.prln("tokenString: " + tokenString + " kind: " + kind + " category: " + category);
            if (kind.equals(PUNCTUATION_VALUE)
                    || ((category != null) && (category.equals("DT") || category.equals("IN")))
                    || cdg.contains(tokenString)) {
                // Out.prln("Now tagging it!");
                tokens.get(i).getFeatures().put("ortho_stop", true);
            }
        }

        // AB, Spock:  Need to check for CDG even for 1 token so we don't automatically match
        // a one-token annotation called "Company", for instance
        String compareString = (String) tokens.get(tokens.size() - 1).getFeatures()
                .get(TOKEN_STRING_FEATURE_NAME);
        if (!caseSensitive) {
            compareString = compareString.toLowerCase();
        }
        if (cdg.contains(compareString)) {
            tokens.remove(tokens.size() - 1);
        }

    }

    ArrayList<Annotation> normalizedTokens = new ArrayList<Annotation>(tokens);
    for (int j = normalizedTokens.size() - 1; j >= 0; j--) {
        if (normalizedTokens.get(j).getFeatures().containsKey("ortho_stop")) {
            normalizedTokens.remove(j);
        }
    }

    normalizedTokensMap.put(annot.getId(), normalizedTokens);

    StringBuffer newString = new StringBuffer(50);
    for (int i = 0; i < tokens.size(); i++) {
        newString.append((String) tokens.get(i).getFeatures().get(TOKEN_STRING_FEATURE_NAME));
        if (i != tokens.size() - 1)
            newString.append(" ");
    }
    // Out.prln("Strip CDG returned: " + newString + "for string " + annotString);

    if (caseSensitive)
        return newString.toString();

    return newString.toString().toLowerCase();
}

From source file:extractjavadoc.TraversalFiles.java

public static void fileList(File inputFile, int node, ArrayList<String> path, String folderPath,
        boolean ifGeneral, Map<String, Boolean> libraryTypeCondition) {
    node++;//from w  w w .j  a va2 s .  c  o  m
    File[] files = inputFile.listFiles();
    if (!inputFile.exists()) {
        System.out.println("File doesn't exist!");
    } else if (inputFile.isDirectory()) {
        path.add(inputFile.getName());

        for (File f : files) {
            for (int i = 0; i < node - 1; i++) {
                System.out.print(" ");
            }
            System.out.print("|-" + f.getPath());

            String ext = FilenameUtils.getExtension(f.getName());
            if (ext.equals("html")) {
                try {
                    System.out.println(" => extracted");

                    //Get extracted file location and add it to output file name,
                    //in order to avoid files in different folder 
                    //have the same name.
                    String fileLocation = "";
                    for (String tmpPath : path) {
                        fileLocation += "-" + tmpPath;
                    }

                    String usefulJavadocFilePath = folderPath + "/" + "javadoc-" + f.getName() + fileLocation
                            + ".txt";
                    //                        String usefulJavadocFilePath = folderPath + "/" + "javadoc-" + f.getName() + ".txt";

                    //create output file for usefuljavadoc
                    File usefulJavadocFile = new File(usefulJavadocFilePath);
                    if (usefulJavadocFile.createNewFile()) {
                        System.out.println("Create successful: " + usefulJavadocFile.getName());
                    }

                    //extract useful javadoc
                    ExtractHTMLContent extractJavadoc = new ExtractHTMLContent(f, usefulJavadocFile, ifGeneral,
                            libraryTypeCondition);
                    extractJavadoc.extractHTMLContent();
                } catch (IOException ex) {
                    Logger.getLogger(TraversalFiles.class.getName()).log(Level.SEVERE, null, ex);
                }
            } else {
                //                   System.out.println(" isn't a java file or html file.");
                System.out.println(" isn't a html file.");
            }
            fileList(f, node, path, folderPath, ifGeneral, libraryTypeCondition);
        }
        path.remove(node - 1);
    }
}

From source file:fr.natoine.PortletAnnotation.PortletViewAnnotation.java

private void doUnColorAnnotation(ActionRequest request, ActionResponse response) {
    long _annotation_id = Long.parseLong(request.getParameter("to_uncolor"));
    List<Annotation> _annotations = (List<Annotation>) request.getPortletSession().getAttribute("annotations");
    ArrayList<HighlightSelectionHTML> _coloreds = (ArrayList<HighlightSelectionHTML>) request
            .getPortletSession().getAttribute("colored");
    ArrayList<Annotation> _coloreds_annotation = (ArrayList<Annotation>) request.getPortletSession()
            .getAttribute("colored_annotation");
    if (_coloreds != null && _annotations != null && _coloreds_annotation != null) {
        //rcuprer l'annotation  dcolorer
        Annotation _to_uncolor = null;
        for (Annotation _annotation : _annotations) {
            if (_annotation.getId() == _annotation_id) {
                _to_uncolor = _annotation;
                for (Annotation _already_colored : _coloreds_annotation) {
                    if (_to_uncolor.getId().compareTo(_already_colored.getId()) == 0) {
                        _coloreds_annotation.remove(_already_colored);
                        break;
                    }/* w  w w .j a va 2  s.  co  m*/
                }
                //System.out.println("[PortletViewAnnotation.doUnColorAnnotation] remove uncolor " + _coloreds_annotation.size() );
                break;
            }
        }
        if (_to_uncolor != null) {
            //System.out.println("[PortletViewAnnotation.doUnColorAnnotation] _to_uncolor not null");
            //pour chaque lment annot, si c'est une slection, signaler qu'il faut le dcolorer
            for (Resource _annotated : _to_uncolor.getAnnotated()) {
                if (_annotated instanceof SelectionHTML) {
                    //retrouver le HighLight correspondant
                    for (HighlightSelectionHTML _colored : _coloreds) {
                        if (_colored.getSelection().getId().compareTo(_annotated.getId()) == 0) {
                            //envoyer le highlight  dcolorer
                            sendEvent("todelete", _colored, response);
                            _coloreds.remove(_colored);
                            break;
                        }
                    }
                }
            }
        }
    }
    request.getPortletSession().setAttribute("colored", _coloreds);
    request.getPortletSession().setAttribute("colored_annotation", _coloreds_annotation);
}

From source file:de.fu_berlin.inf.dpp.net.internal.XMPPTransmitter.java

public boolean receiveUserListConfirmation(SarosPacketCollector collector, List<User> fromUsers,
        SubMonitor monitor) throws LocalCancellationException {

    if (isConnectionInvalid())
        return false;

    ArrayList<JID> fromUserJIDs = new ArrayList<JID>();
    for (User user : fromUsers) {
        fromUserJIDs.add(user.getJID());
    }/* ww  w . j a v  a2s.c o  m*/
    try {
        Packet result;
        JID jid;
        while (fromUserJIDs.size() > 0) {
            if (monitor.isCanceled())
                throw new LocalCancellationException();

            // Wait up to [timeout] milliseconds for a result.
            result = collector.nextResult(100);
            if (result == null)
                continue;

            jid = new JID(result.getFrom());
            if (!fromUserJIDs.remove(jid)) {
                log.warn("Buddy list confirmation from unknown buddy: " + Utils.prefix(jid));
            } else {
                log.debug("Buddy list confirmation from: " + Utils.prefix(jid));
            }
            /*
             * TODO: what if a user goes offline during the invitation? The
             * confirmation will never arrive!
             */
        }
        return true;
    } finally {
        collector.cancel();
    }
}

From source file:com.redhat.jenkins.nodesharingbackend.Api.java

/**
 * Report workload to be executed on orchestrator for particular executor master.
 *
 * The order of items from orchestrator is preserved though not guaranteed to be exactly the same as the builds ware
 * scheduled on individual executor Jenkinses.
 *//* ww w. j  ava  2s  .co m*/
@RequirePOST
public void doReportWorkload(@Nonnull final StaplerRequest req, @Nonnull final StaplerResponse rsp)
        throws IOException {
    Jenkins.getActiveInstance().checkPermission(RestEndpoint.RESERVE);

    Pool pool = Pool.getInstance();
    final ConfigRepo.Snapshot config = pool.getConfig(); // Fail early when there is no config

    final ReportWorkloadRequest request = Entity.fromInputStream(req.getInputStream(),
            ReportWorkloadRequest.class);

    final List<ReportWorkloadRequest.Workload.WorkloadItem> reportedItems = request.getWorkload().getItems();
    final ArrayList<ReservationTask> reportedTasks = new ArrayList<>(reportedItems.size());
    final ExecutorJenkins executor;
    try {
        executor = config.getJenkinsByUrl(request.getExecutorUrl());
    } catch (NoSuchElementException ex) {
        rsp.setStatus(HttpServletResponse.SC_CONFLICT);
        rsp.getWriter().println(unknownExecutor(request.getExecutorUrl(), pool.getConfigRepoUrl()));
        return;
    }

    for (ReportWorkloadRequest.Workload.WorkloadItem item : reportedItems) {
        reportedTasks.add(new ReservationTask(executor, item.getLabel(), item.getName(), item.getId()));
    }

    Queue.withLock(new Runnable() {
        @Override
        public void run() {
            Queue queue = Jenkins.getActiveInstance().getQueue();
            for (Queue.Item item : queue.getItems()) {
                if (item.task instanceof ReservationTask
                        && ((ReservationTask) item.task).getOwner().equals(executor)) {
                    // Cancel items executor is no longer interested in and keep those it cares for
                    if (!reportedTasks.contains(item.task)) {
                        queue.cancel(item);
                    }
                    reportedTasks.remove(item.task);
                }
            }

            // These might have been reported just before the build started the execution on Executor so now the
            // ReservationTask might be executing or even completed on executor, though there is no way for orchestrator
            // to know. This situation will be handled by executor rejecting the `utilizeNode` call.
            for (ReservationTask newTask : reportedTasks) {
                queue.schedule2(newTask, 0);
            }
        }
    });

    String version = this.version;
    new ReportWorkloadResponse(pool.getConfigRepoUrl(), version).toOutputStream(rsp.getOutputStream());
}

From source file:org.lokra.seaweedfs.core.Connection.java

/**
 * Fetch core server by seaweedfs Http API.
 *
 * @param masterUrl Core server url with scheme.
 * @return Cluster status.//from   ww w. j  a  v  a  2  s. c om
 */
@SuppressWarnings("unchecked")
private SystemClusterStatus fetchSystemClusterStatus(String masterUrl) throws IOException {
    MasterStatus leader;
    ArrayList<MasterStatus> peers;
    final HttpGet request = new HttpGet(masterUrl + RequestPathStrategy.checkClusterStatus);
    final JsonResponse jsonResponse = fetchJsonResultByRequest(request);
    Map map = objectMapper.readValue(jsonResponse.json, Map.class);

    if (map.get("Leader") != null) {
        leader = new MasterStatus((String) map.get("Leader"));
    } else {
        throw new SeaweedfsException("not found seaweedfs core leader");
    }

    peers = new ArrayList<>();

    if (map.get("Peers") != null) {
        List<String> rawPeerList = (List<String>) map.get("Peers");
        for (String url : rawPeerList) {
            MasterStatus peer = new MasterStatus(url);
            peers.add(peer);
        }
    }

    if (map.get("IsLeader") == null || !((Boolean) map.get("IsLeader"))) {
        peers.add(new MasterStatus(masterUrl.replace("http://", "")));
        peers.remove(leader);
        leader.setActive(ConnectionUtil.checkUriAlive(this.httpClient, leader.getUrl()));
        if (!leader.isActive())
            throw new SeaweedfsException("seaweedfs core leader is failover");
    } else {
        leader.setActive(true);
    }

    for (MasterStatus item : peers) {
        item.setActive(ConnectionUtil.checkUriAlive(this.httpClient, item.getUrl()));
    }

    return new SystemClusterStatus(leader, peers);

}

From source file:com.krawler.spring.crm.accountModule.crmAccountDAOImpl.java

public KwlReturnObject getAllAccounts(HashMap<String, Object> requestParams, ArrayList filter_names,
        ArrayList filter_params) throws ServiceException {
    List ll = null;/*from ww w .ja  v a  2  s  .  c o m*/
    int dl = 0;
    try {
        String Hql = "select distinct c from accountOwners ao inner join ao.account c ";
        //            String Hql = "select c from CrmAccount c ";
        String filterQuery = StringUtil.filterQuery(filter_names, "where");
        Hql += filterQuery;
        int ind = Hql.indexOf("(");
        if (ind > -1) {
            int index = Integer.valueOf(Hql.substring(ind + 1, ind + 2));
            Hql = Hql.replaceAll("(" + index + ")", filter_params.get(index).toString());
            filter_params.remove(index);
        }

        if (requestParams.containsKey("ss") && requestParams.get("ss") != null) {
            String ss = StringEscapeUtils.escapeJavaScript(requestParams.get("ss").toString());
            if (!StringUtil.isNullOrEmpty(ss)) {
                String[] searchcol = new String[] { "c.accountname" };
                StringUtil.insertParamSearchString(filter_params, ss, 1);
                String searchQuery = StringUtil.getSearchString(ss, "and", searchcol);
                Hql += searchQuery;
            }
        }

        String selectInQuery = Hql;
        boolean pagingFlag = false;
        if (requestParams.containsKey("pagingFlag") && requestParams.get("pagingFlag") != null) {
            pagingFlag = Boolean.parseBoolean(requestParams.get("pagingFlag").toString());
        }
        boolean countFlag = true;
        if (requestParams.containsKey("countFlag") && requestParams.get("countFlag") != null) {
            countFlag = Boolean.parseBoolean(requestParams.get("countFlag").toString());
        }

        ArrayList order_by = null;
        ArrayList order_type = null;
        if (requestParams.containsKey("order_by"))
            order_by = (ArrayList) requestParams.get("order_by");
        if (requestParams.containsKey("order_type"))
            order_type = (ArrayList) requestParams.get("order_type");
        String orderQuery = StringUtil.orderQuery(order_by, order_type);
        if (StringUtil.isNullOrEmpty(orderQuery)) {
            orderQuery = " order by c.accountname ";
        }
        selectInQuery += orderQuery;

        if (countFlag) {
            ll = executeQuery(selectInQuery, filter_params.toArray());
            dl = ll.size();
        }
        if (pagingFlag) {
            int start = 0;
            int limit = 25;
            if (requestParams.containsKey("start") && requestParams.containsKey("limit")) {
                start = Integer.parseInt(requestParams.get("start").toString());
                limit = Integer.parseInt(requestParams.get("limit").toString());
            }
            ll = executeQueryPaging(selectInQuery, filter_params.toArray(), new Integer[] { start, limit });
            if (!countFlag) {
                dl = ll.size();
            }
        }
    } catch (Exception e) {
        throw ServiceException.FAILURE("crmAccountDAOImpl.getAllAccounts : " + e.getMessage(), e);
    }
    return new KwlReturnObject(true, KWLErrorMsgs.S01, "", ll, dl);
}

From source file:br.ufc.mdcc.mpos.persistence.ProfileNetworkDao.java

private ArrayList<Network> getLastResults(String sql) throws JSONException, ParseException {
    openDatabase();/*from  w ww  .j  a  va 2s  .  c o  m*/

    Cursor cursor = database.rawQuery(sql, null);

    ArrayList<Network> lista = new ArrayList<Network>(15);

    // obtem todos os indices das colunas da tabela
    int idx_loss = cursor.getColumnIndex(F_LOSS);
    int idx_jitter = cursor.getColumnIndex(F_JITTER);
    int idx_udp = cursor.getColumnIndex(F_UDP);
    int idx_tcp = cursor.getColumnIndex(F_TCP);
    int idx_down = cursor.getColumnIndex(F_DOWN);
    int idx_up = cursor.getColumnIndex(F_UP);
    int idx_net_type = cursor.getColumnIndex(F_NET_TYPE);
    int idx_endpoint_type = cursor.getColumnIndex(F_ENDPOINT_TYPE);
    int idx_date = cursor.getColumnIndex(F_DATE);

    if (cursor != null && cursor.moveToFirst()) {
        do {
            Network network = new Network();
            network.setJitter(cursor.getInt(idx_jitter));
            network.setLossPacket(cursor.getInt(idx_loss));
            network.setBandwidthDownload(cursor.getString(idx_down));
            network.setBandwidthUpload(cursor.getString(idx_up));
            network.setResultPingTcp(Network.stringToLongArray(cursor.getString(idx_tcp)));
            network.setResultPingUdp(Network.stringToLongArray(cursor.getString(idx_udp)));
            network.setEndpointType(cursor.getString(idx_endpoint_type));
            network.setNetworkType(cursor.getString(idx_net_type));
            network.setDate(simpleDateFormat.parse(cursor.getString(idx_date)));

            lista.add(network);
        } while (cursor.moveToNext());
    }

    lista.remove(0);

    cursor.close();
    closeDatabase();

    return lista;
}

From source file:ArrayUtils.java

/**
 * Merges elements found in each of a set of arrays into a single array with
 * no duplicates. For primitive types.//from  w w w .j a  v a  2 s  .  c  o  m
 * 
 * @param type
 *            The type of the result
 * @param arrays
 *            The arrays to merge
 * @return A new array containing all common elements between
 *         <code>array1</code> and <code>array2</code>
 * @throws NullPointerException
 *             If either array is null
 * @throws ArrayStoreException
 *             If elements in the arrays are incompatible with
 *             <code>type</code>
 */
public static Object mergeExclusiveP(Class<?> type, Object... arrays) {
    if (arrays.length == 0)
        return Array.newInstance(type, 0);
    java.util.ArrayList<Object> retSet = new java.util.ArrayList<Object>();
    int i, j, k;
    int len = Array.getLength(arrays[0]);
    for (j = 0; j < len; j++)
        retSet.add(Array.get(arrays[0], j));
    for (i = 1; i < arrays.length; i++) {
        for (j = 0; j < retSet.size(); j++) {
            len = Array.getLength(arrays[i]);
            boolean hasEl = false;
            for (k = 0; k < len; k++)
                if (equalsUnordered(retSet.get(j), Array.get(arrays[i], k))) {
                    hasEl = true;
                    break;
                }
            if (!hasEl) {
                retSet.remove(j);
                j--;
            }
        }
    }
    Object ret = Array.newInstance(type, retSet.size());
    for (i = 0; i < retSet.size(); i++)
        Array.set(ret, i, retSet.get(i));
    return ret;
}