List of usage examples for org.apache.commons.collections.primitives LongList add
boolean add(long element);
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.//from w w w . j a va2 s .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 ww w. jav a 2 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 w w . j a va 2 s.co m return toUserList(list); }
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 ww w . jav a 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> 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()); }//w ww . j a v a 2 s.c o m } for (PollOption option : poll.getOptions()) { if (list.contains(option.getOptionId())) options.add(option); } return options; }