Example usage for java.util ArrayList iterator

List of usage examples for java.util ArrayList iterator

Introduction

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

Prototype

public Iterator<E> iterator() 

Source Link

Document

Returns an iterator over the elements in this list in proper sequence.

Usage

From source file:eu.aliada.ckancreation.impl.CKANCreation.java

/**
 * It calculates the number of triples contained in the subsets of a dataset.
 *
 * @param sparqlEndpoint   the SPARQL endpoint of the dataset. 
 * @param user            the user name for the SPARQl endpoint.
 * @param password         the password for the SPARQl endpoint.
 * @param subsetsList      the {@link eu.aliada.ckancreation.model.Subset}
 *                     that contains information of the graphs of the subset.  
 * @return the number of triples contained in the subsets of the dataset.                 
 * @since 2.0/*from w  w  w. ja v a 2 s  .  c  o  m*/
 */
public int calculateDatasetNumTriples(String sparqlEndpoint, final String user, final String password,
        ArrayList<Subset> subsetsList) {
    int numTriples = 0;
    //Get subset graphs and get number of triples
    for (Iterator<Subset> iterSubsets = subsetsList.iterator(); iterSubsets.hasNext();) {
        Subset subset = iterSubsets.next();
        //Get number of triples of each subgraph
        final RDFStoreDAO rdfstoreDAO = new RDFStoreDAO();
        LOGGER.debug(MessageCatalog._00045_GETTING_NUM_TRIPLES, sparqlEndpoint, subset.getGraph(), user,
                password);
        subset.setGraphNumTriples(rdfstoreDAO.getNumTriples(sparqlEndpoint, subset.getGraph(), user, password));
        LOGGER.debug(MessageCatalog._00045_GETTING_NUM_TRIPLES, sparqlEndpoint, subset.getLinksGraph(), user,
                password);
        subset.setLinksGraphNumTriples(
                rdfstoreDAO.getNumTriples(sparqlEndpoint, subset.getLinksGraph(), user, password));
        numTriples = numTriples + subset.getGraphNumTriples() + subset.getLinksGraphNumTriples();
    }
    return numTriples;
}

From source file:org.archive.modules.fetcher.CookieStoreTest.java

protected void assertCookieListsEquivalent(List<Cookie> list1, List<Cookie> list2) {
    Comparator<Cookie> comparator = new Comparator<Cookie>() {
        @Override//from  w  w w. j av  a 2 s  . co m
        public int compare(Cookie o1, Cookie o2) {
            return o1.toString().compareTo(o2.toString());
        }
    };

    ArrayList<Cookie> sorted1 = new ArrayList<Cookie>(list1);
    Collections.sort(sorted1, comparator);
    ArrayList<Cookie> sorted2 = new ArrayList<Cookie>(list2);
    Collections.sort(sorted2, comparator);

    assertEquals(list1.size(), list2.size());
    assertEquals(sorted1.size(), sorted2.size());

    Iterator<Cookie> iter1 = sorted1.iterator();
    Iterator<Cookie> iter2 = sorted2.iterator();
    for (int i = 0; i < sorted1.size(); i++) {
        Cookie c1 = iter1.next();
        Cookie c2 = iter2.next();
        assertCookiesIdentical(c1, c2);
    }
}

From source file:MinMaxHeap.java

/**
 * Returns an iterator over this heap.  The elements are returned
 * in decreasing order of score.//from   w w w .  j  av a  2s .  c  o  m
 *
 * @return Iterator over this heap in decreasing order of score.
 */
@Override
public Iterator<E> iterator() {
    ArrayList<E> list = new ArrayList<E>();
    for (int i = 0; i < mNextFreeIndex; ++i)
        list.add(mHeap[i]);
    Collections.<E>sort(list, ScoredObject.reverseComparator());
    return list.iterator();
}

From source file:com.tremolosecurity.proxy.filter.HttpFilterRequestImpl.java

@Override
public Iterator<String> getHeaderNames() {

    ArrayList<String> headerNamesWithCase = new ArrayList<String>();

    for (String name : this.headers.keySet()) {
        headerNamesWithCase.add(this.headers.get(name).getName());
    }// w ww.ja va 2  s .  c o  m

    return headerNamesWithCase.iterator();
}

From source file:edu.harvard.mcz.imagecapture.loader.FieldLoader.java

/**
 * Setup initial conditions, construct list of known fields into which data can be put.
 *//*from   w  ww .ja v  a 2 s . co m*/
protected void init() {
    sls = new SpecimenLifeCycle();

    // Key: lower case of field, Value actual case of Field.
    knownFields = new HashMap<String, String>();
    Method[] specimenMethods = Specimen.class.getDeclaredMethods();
    for (int j = 0; j < specimenMethods.length; j++) {
        if (specimenMethods[j].getName().startsWith("set") && specimenMethods[j].getParameterTypes().length == 1
                && specimenMethods[j].getParameterTypes()[0].getName().equals(String.class.getName())) {
            knownFields.put(specimenMethods[j].getName().replaceAll("^set", "").toLowerCase(),
                    specimenMethods[j].getName().replaceAll("^set", ""));
        }
    }
    // List of input fields that will need to be parsed into relational tables
    ArrayList<String> toParseFields = new ArrayList<String>();
    toParseFields.add("collectors");
    toParseFields.add("numbers");
    Iterator<String> ipf = toParseFields.iterator();
    while (ipf.hasNext()) {
        String parseField = ipf.next();
        knownFields.put(parseField.toLowerCase(), parseField);
    }

    if (log.isDebugEnabled()) {
        Iterator<String> i = knownFields.keySet().iterator();
        while (i.hasNext()) {
            log.debug(i.next());
        }
    }

}

From source file:cn.zhouyafeng.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.java

public void execute() throws Exception {
    if (registry == null) {
        registry = Registry.getRegistry(null, null);
    }//w  ww  .  j a  va2 s.  c  o  m

    InputStream stream = (InputStream) source;

    ArrayList<ManagedBean> loadedMbeans = new ArrayList<>();
    synchronized (dLock) {
        if (digester == null) {
            digester = createDigester();
        }

        // Process the input file to configure our registry
        try {
            // Push our registry object onto the stack
            digester.push(loadedMbeans);
            digester.parse(stream);
        } catch (Exception e) {
            log.error("Error digesting Registry data", e);
            throw e;
        } finally {
            // digester.reset(); //TODO
        }

    }
    Iterator<ManagedBean> iter = loadedMbeans.iterator();
    while (iter.hasNext()) {
        registry.addManagedBean(iter.next());
    }
}

From source file:com.nubits.nubot.trading.wrappers.ComkortWrapper.java

@Override
public ApiResponse clearOrders(CurrencyPair pair) {
    ApiResponse apiResponse = new ApiResponse();
    ApiResponse openOrders = getActiveOrders();
    if (openOrders.isPositive()) {
        apiResponse.setResponseObject(true);
        ArrayList<Order> orderList = (ArrayList) openOrders.getResponseObject();
        for (Iterator<Order> order = orderList.iterator(); order.hasNext();) {
            Order thisOrder = order.next();
            ApiResponse cancel = cancelOrder(thisOrder.getId(), thisOrder.getPair());
            if (cancel.getResponseObject().equals(false)) {
                apiResponse.setResponseObject(false);
            }//from  w  w w . ja  v  a 2s. com
        }
    } else {
        apiResponse = openOrders;
    }
    return apiResponse;
}

From source file:com.facebook.android.friendsmash.HomeActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.home);/*  w  w  w.  jav a  2  s  .  co m*/

    FragmentManager fm = getSupportFragmentManager();
    fragments[FB_LOGGED_OUT_HOME] = fm.findFragmentById(R.id.fbLoggedOutHomeFragment);
    fragments[HOME] = fm.findFragmentById(R.id.homeFragment);

    FragmentTransaction transaction = fm.beginTransaction();
    for (int i = 0; i < fragments.length; i++) {
        transaction.hide(fragments[i]);
    }
    transaction.commit();

    // Restore the logged-in user's information if it has been saved and the existing data in the application
    // has been destroyed (i.e. the app hasn't been used for a while and memory on the device is low)
    // - only do this if the session is open for the social version only
    if (FriendSmashApplication.IS_SOCIAL) {
        // loggedIn
        if (savedInstanceState != null) {
            boolean loggedInState = savedInstanceState.getBoolean(FriendSmashApplication.getLoggedInKey(),
                    false);
            ((FriendSmashApplication) getApplication()).setLoggedIn(loggedInState);

            if (((FriendSmashApplication) getApplication()).isLoggedIn()
                    && (((FriendSmashApplication) getApplication()).getFriends() == null
                            || ((FriendSmashApplication) getApplication()).getCurrentFBUser() == null)) {
                try {
                    // currentFBUser
                    String currentFBUserJSONString = savedInstanceState
                            .getString(FriendSmashApplication.getCurrentFbUserKey());
                    if (currentFBUserJSONString != null) {
                        GraphUser currentFBUser = GraphObject.Factory
                                .create(new JSONObject(currentFBUserJSONString), GraphUser.class);
                        ((FriendSmashApplication) getApplication()).setCurrentFBUser(currentFBUser);
                    }

                    // friends
                    ArrayList<String> friendsJSONStringArrayList = savedInstanceState
                            .getStringArrayList(FriendSmashApplication.getFriendsKey());
                    if (friendsJSONStringArrayList != null) {
                        ArrayList<GraphUser> friends = new ArrayList<GraphUser>();
                        Iterator<String> friendsJSONStringArrayListIterator = friendsJSONStringArrayList
                                .iterator();
                        while (friendsJSONStringArrayListIterator.hasNext()) {
                            friends.add(GraphObject.Factory.create(
                                    new JSONObject(friendsJSONStringArrayListIterator.next()),
                                    GraphUser.class));
                        }
                        ((FriendSmashApplication) getApplication()).setFriends(friends);
                    }
                } catch (JSONException e) {
                    Log.e(FriendSmashApplication.TAG, e.toString());
                }
            }
        }
    }
}

From source file:com.nubits.nubot.trading.wrappers.AltsTradeWrapper.java

@Override
public ApiResponse clearOrders(CurrencyPair pair) {
    ApiResponse apiResponse = new ApiResponse();
    ApiResponse getOrders = getActiveOrders(pair);
    if (getOrders.isPositive()) {
        ArrayList<Order> orders = (ArrayList) getOrders.getResponseObject();
        boolean allClear = true;
        for (Iterator<Order> order = orders.iterator(); order.hasNext();) {
            ApiResponse cancel = cancelOrder(order.next().getId(), pair);
            if (!cancel.isPositive()) {
                allClear = false;//from w w w. j a  va  2 s. c om
            }
        }
        apiResponse.setResponseObject(allClear);
    } else {
        apiResponse = getOrders;
    }
    return apiResponse;
}

From source file:com.nubits.nubot.trading.wrappers.ComkortWrapper.java

@Override
public ApiResponse getOrderDetail(String orderID) {
    ApiResponse apiResponse = new ApiResponse();

    ApiResponse activeOrders = getActiveOrders();
    if (activeOrders.isPositive()) {
        apiResponse.setResponseObject(new Order());
        ArrayList<Order> orderList = (ArrayList<Order>) activeOrders.getResponseObject();
        for (Iterator<Order> order = orderList.iterator(); order.hasNext();) {
            Order thisOrder = order.next();
            if (thisOrder.getId().equals(orderID)) {
                apiResponse.setResponseObject(thisOrder);
            }/*from  w ww  .j a va2s. c o m*/
        }
    } else {
        apiResponse = activeOrders;
    }
    return apiResponse;
}