List of usage examples for org.apache.commons.collections.primitives ArrayLongList ArrayLongList
public ArrayLongList()
From source file:net.sf.sprockets.sql.Statements.java
/** * Execute the query, get the long values in the first column of the result set, and close the * statement.//w w w . j ava2s .c o m * * @param stmt * must already have parameters set * @return null if the result set is empty * @since 1.4.0 */ public static long[] allLongs(PreparedStatement stmt) throws SQLException { long[] l = null; ResultSet rs = stmt.executeQuery(); if (rs.next()) { LongList list = new ArrayLongList(); do { list.add(rs.getLong(1)); } while (rs.next()); l = list.toArray(); } stmt.close(); return l; }
From source file:architecture.ee.web.community.poll.DefaultPollManager.java
public List<User> getUserVotes(Poll poll) { List<Vote> votes = getVotes(poll); LongList list = new ArrayLongList(); for (Vote vote : votes) { if (vote.getUserId() != -1L) list.add(vote.getUserId());/*from w ww. j a v a2 s . co m*/ } return toUserList(list); }
From source file:architecture.ee.web.community.poll.DefaultPollManager.java
public List<User> getUserVotes(Poll poll, long optionId) { List<Vote> votes = getVotes(poll); LongList list = new ArrayLongList(); for (Vote vote : votes) { if (optionId == vote.getOptionId() && vote.getUserId() != -1L) list.add(vote.getUserId());/*from w ww.j a va 2s . com*/ } return toUserList(list); }
From source file:net.sf.diningout.app.ui.FriendsFragment.java
/** * Get the global IDs of users that are chosen to be followed. * * @return null if none are checked/*from w w w . j a v a2 s . co m*/ */ long[] getFollowed() { if (mGrid.getCheckedItemCount() <= 0) { return null; } ArrayLongList globalIds = null; int[] keys = SparseArrays.trueKeys(mGrid.getCheckedItemPositions()); for (int pos : keys) { EasyCursor c = (EasyCursor) mGrid.getItemAtPosition(pos); if (!c.isNull(Contacts.GLOBAL_ID)) { if (globalIds == null) { globalIds = new ArrayLongList(); } String globalId = c.getString(Contacts.GLOBAL_ID); if (globalId.indexOf(',') < 0) { globalIds.add(Long.parseLong(globalId)); } else { Elements.addAll(globalIds, Elements.toLongs(globalId.split(","))); } } } return globalIds != null ? globalIds.toArray() : null; }
From source file:architecture.ee.web.community.poll.DefaultPollManager.java
public List<PollOption> getUserVotes(Poll poll, User user) { if (user == null) throw new IllegalArgumentException("user cannot be null."); List<Vote> votes = getVotes(poll); LongList list = new ArrayLongList(); List<PollOption> options = new ArrayList<PollOption>(); for (Vote vote : votes) { if (vote.getUserId() == user.getUserId() && !list.contains(vote.getOptionId())) { list.add(vote.getOptionId()); }//from w ww . j a va 2 s .c om } for (PollOption option : poll.getOptions()) { if (list.contains(option.getOptionId())) options.add(option); } return options; }
From source file:architecture.ee.web.community.poll.DefaultPollManager.java
public List<PollOption> getAnomymousVotes(Poll poll, String username) { if (username == null) throw new IllegalArgumentException("user unique id cannot be null."); List<Vote> votes = getVotes(poll); LongList list = new ArrayLongList(); List<PollOption> options = new ArrayList<PollOption>(); for (Vote vote : votes) { if (username.equals(vote.getUniqueId()) && !list.contains(vote.getOptionId())) { list.add(vote.getOptionId()); }/*from w ww . j a v a2 s . c o m*/ } for (PollOption option : poll.getOptions()) { if (list.contains(option.getOptionId())) options.add(option); } return options; }