Example usage for java.util List clear

List of usage examples for java.util List clear

Introduction

In this page you can find the example usage for java.util List clear.

Prototype

void clear();

Source Link

Document

Removes all of the elements from this list (optional operation).

Usage

From source file:org.constretto.spring.EnvironmentAnnotationConfigurer.java

private List<BeanDefinition> prioritizeBeans(BeanDefinition potentialMatch,
        List<BeanDefinition> highestPriorityBeans) throws ClassNotFoundException {
    List<BeanDefinition> result = new ArrayList<BeanDefinition>();
    int matchPriority = getAutowirePriority(Class.forName(potentialMatch.getBeanClassName()));
    if (highestPriorityBeans.isEmpty()) {
        result.add(potentialMatch);//w  w  w.  j  a  va  2 s . com
    } else {
        for (BeanDefinition highestPriorityBean : highestPriorityBeans) {
            int mostSpesificPriority = getAutowirePriority(
                    Class.forName(highestPriorityBean.getBeanClassName()));
            if ((matchPriority - mostSpesificPriority) < 0) {
                result.clear();
                result.add(potentialMatch);
            } else if (((matchPriority - mostSpesificPriority) == 0)) {
                result.add(potentialMatch);
                result.add(highestPriorityBean);
            } else {
                result.add(highestPriorityBean);
            }
        }
    }
    return result;
}

From source file:com.hiperium.bo.control.impl.TaskBOImpl.java

/**
 * {@inheritDoc}//from   www  .  j  a v  a2  s. c  o  m
 */
@Override
public List<Task> updateRegisterState(@NotNull List<Task> list, boolean newState, @NotNull String sessionId)
        throws InformationException {
    this.log.debug("changeRegisterState - START");
    if (list != null && !list.isEmpty()) {
        List<Task> actualList = new ArrayList<Task>();
        for (Task task : list) {
            Task actual = super.getDaoFactory().getTaskDAO().findById(task.getId(), false, true);
            actualList.add(actual);
        }
        list.clear();
        BeanPropertyValueChangeClosure closure = new BeanPropertyValueChangeClosure("active", newState);
        CollectionUtils.forAllDo(actualList, closure);
        for (Task task : actualList) {
            Task updated = super.getDaoFactory().getTaskDAO().update(task);
            Task basic = new Task();
            BeanUtils.copyProperties(updated, basic);
            list.add(basic);
        }
    }
    this.log.debug("changeRegisterState - END");
    return list;
}

From source file:de.greenrobot.daoexample.NoteActivity.java

private void batchInsert(int count) {
    sw.start();/*from  w w w. j av a 2 s. co m*/
    List<PlayHistory> entities = new ArrayList<PlayHistory>();

    for (int i = 0; i < count; i++) {

        PlayHistory h = new PlayHistory();
        h.setId(null);
        h.setPlayId(i + "");
        entities.add(h);
        if ((i + 1) % 50000 == 0 || i == count - 1) {
            playHistoryDao.insertInTx(entities);
            sw.split();
            System.out.println("inserted " + (i + 1) + "  " + sw.toSplitString() + "  " + sw.toString());
            entities.clear();
        }
    }

    sw.split();
    System.out.println("total time " + sw.toSplitString() + "  " + sw.toString());
    sw.stop();
    sw.reset();
}

From source file:edu.missouri.bas.bluetooth.equivital.EquivitalRunnable.java

private void writeChestSensorDatatoCSV(String chestSensorData) {
    // TODO Auto-generated method stub
    //Toast.makeText(serviceContext,"Trying to write to the file",Toast.LENGTH_LONG).show();
    Calendar c = Calendar.getInstance();
    SimpleDateFormat curFormater = new SimpleDateFormat("MMMMM_dd");
    String dateObj = curFormater.format(c.getTime());
    String file_name = "chestsensor." + deviceName + "." + dateObj + ".txt";
    Calendar cal = Calendar.getInstance();
    cal.setTimeZone(TimeZone.getTimeZone("US/Central"));
    File f = new File(BASE_PATH, file_name);
    String dataToWrite = String.valueOf(cal.getTime()) + "," + chestSensorData;
    dataPoints.add(dataToWrite + ";");
    if (dataPoints.size() == 57) {
        List<String> subList = dataPoints.subList(0, 56);
        String data = subList.toString();
        String formattedData = data.replaceAll("[\\[\\]]", "");
        //sendDatatoServer("chestsensor"+"."+phoneAddress+"."+deviceName+"."+dateObj,formattedData);
        TransmitData transmitData = new TransmitData();
        transmitData.execute("chestsensor" + "." + phoneAddress + "." + deviceName + "." + dateObj,
                formattedData);//w w w.  j  a v  a2 s  . c  o  m
        Log.d("Equivital", "Data Point Sent");
        subList.clear();
        subList = null;
    }
    if (f != null) {
        try {
            writeToFile(f, dataToWrite);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}

From source file:gov.nih.nci.cabig.caaers.web.security.FabricatedAuthenticationFilter.java

private void filterAuthoritiesByOrganization(List<GrantedAuthority> list, int orgId) {
    Organization org = organizationRepository.getById(orgId);
    if (org != null) {
        CurrentEntityHolder.setEntity(org);
        list.clear();
        Collection<String> roles = securityFacade.getRoles(SecurityUtils.getUserLoginName(), org);
        for (String role : roles) {
            GrantedAuthority ga = new GrantedAuthorityImpl(role);
            if (!list.contains(ga)) {
                list.add(ga);/*from  w w  w. jav a2  s . co  m*/
            }
        }
        organizationRepository.evict(org);
    }
}

From source file:com.iksgmbh.sql.pojomemodb.sqlparser.SelectParser.java

private void replaceAliasInWhereConditions(final List<WhereCondition> whereConditions,
        final List<TableId> tableIdList) throws SQLException {
    final List<WhereCondition> toReturn = new ArrayList<WhereCondition>();
    for (WhereCondition whereCondition : whereConditions) {
        toReturn.add(new WhereCondition(replaceAliases(whereCondition.getColumnName(), tableIdList),
                whereCondition.getComparator(),
                replaceAliases(whereCondition.getValueAsString(), tableIdList)));
    }/*from  w  w w  .  ja v  a2 s.c  o  m*/
    whereConditions.clear();
    whereConditions.addAll(toReturn);
}

From source file:edu.cornell.med.icb.goby.modes.LastToCompactMode.java

private void writeEntries(final AlignmentWriter writer,
        final List<Alignments.AlignmentEntry.Builder> alignmentEntries) throws IOException {
    final int size = alignmentEntries.size();
    if (size > 0) {
        for (final Alignments.AlignmentEntry.Builder alignmentEntry : alignmentEntries) {
            alignmentEntry.setQueryIndexOccurrences(size);
            alignmentEntry.setAmbiguity(size);
            writer.appendEntry(alignmentEntry.build());
        }//from  w  ww. j  a v  a 2 s .c o  m
        alignmentEntries.clear();
    }
}

From source file:gov.nih.nci.cabig.caaers.web.ae.PatientDetailsTab.java

public ModelAndView removeAllPriorTherapyAgents(HttpServletRequest request, Object cmd, Errors errors) {

    AbstractExpeditedAdverseEventInputCommand command = (AbstractExpeditedAdverseEventInputCommand) cmd;
    SAEReportPriorTherapy priorTherapy = command.getAeReport().getSaeReportPriorTherapies()
            .get(command.getParentIndex());
    List<PriorTherapyAgent> priorTherapyAgents = priorTherapy.getPriorTherapyAgents();

    priorTherapyAgents.clear();

    //create the indexes in reverse order
    int size = priorTherapyAgents.size();
    Integer[] indexes = new Integer[size];
    for (int i = 0; i < size; i++) {
        indexes[i] = size - (i + 1);//  www .j av  a  2s .  c  om
    }

    ModelAndView modelAndView = new ModelAndView("ae/ajax/priorTherapyAgentFormSection");
    modelAndView.getModel().put("priorTherapyAgents", priorTherapyAgents);
    modelAndView.getModel().put("indexes", indexes);
    modelAndView.getModel().put("parentIndex", command.getParentIndex());

    return modelAndView;
}

From source file:forge.util.storage.StorageReaderFileSections.java

@Override
public Map<String, T> readAll() {
    final Map<String, T> result = createMap();

    int idx = 0;/*from   w w  w . jav a 2 s. com*/
    Iterable<String> contents = FileUtil.readFile(file);

    List<String> accumulator = new ArrayList<String>();
    String header = null;

    for (final String s : contents) {
        if (!lineContainsObject(s)) {
            continue;
        }

        if (s.charAt(0) == '[') {
            if (header != null) {
                // read previously collected item
                T item = readItem(header, accumulator, idx);
                if (item != null) {
                    result.put(keySelector.apply(item), item);
                    idx++;
                }
            }

            header = StringUtils.strip(s, "[] ");
            accumulator.clear();
        } else {
            accumulator.add(s);
        }
    }

    // store the last item
    if (!accumulator.isEmpty()) {
        T item = readItem(header, accumulator, idx);
        if (item != null) {
            String newKey = keySelector.apply(item);
            if (result.containsKey(newKey))
                System.err.println("StorageReader: Overwriting an object with key " + newKey);

            result.put(newKey, item);
        }
    }
    return result;
}