Example usage for java.util List set

List of usage examples for java.util List set

Introduction

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

Prototype

E set(int index, E element);

Source Link

Document

Replaces the element at the specified position in this list with the specified element (optional operation).

Usage

From source file:com.setronica.ucs.storage.PgCategoryStorage.java

public void open() throws Exception {
    c = ds.getConnection();/*from  w w w . ja  va 2 s .c o m*/
    if (c.getAutoCommit()) {
        c.setAutoCommit(false);
    }

    delTreePs = c.prepareStatement(
            "SET LOCAL synchronous_commit TO OFF; delete from " + tableName + " where tree_id=?; commit");
    delCatPs = c.prepareStatement("SET LOCAL synchronous_commit TO OFF; delete from " + tableName
            + " where tree_id=? and category_id=?; commit");

    insCatPs = c.prepareStatement("SET LOCAL synchronous_commit TO OFF; insert into " + tableName
            + " (owner_id, tree_id, tree_name, category_id, val) values(?, ?, ?, ?, cast(? as json)); commit");
    updateCatPs = c.prepareStatement("SET LOCAL synchronous_commit TO OFF; update " + tableName
            + " set val=cast(? as json) where tree_id=? and category_id=?; commit");

    String sql = "select owner_id, tree_id, tree_name, category_id, val from " + tableName
            + " order by owner_id, tree_id, category_id";
    logger.info("Starting populate PgCategoryStorage for table: " + tableName);
    try (Statement s = c.createStatement(); ResultSet rs = s.executeQuery(sql)) {
        while (rs.next()) {
            int treeId = rs.getInt(2);
            int index = rs.getInt(4);
            MemCategoryDAO.MemPackedCategory category = mapper.readValue(rs.getString(5),
                    MemCategoryDAO.MemPackedCategory.class);

            MemPackedTree tree = treeStorage.get(treeId);
            if (tree == null) {
                tree = new MemPackedTree();
                tree.treeId = treeId;
                tree.ownerId = rs.getInt(1);
                tree.treeName = rs.getString(3);
                tree.categories = new ArrayList<MemCategoryDAO.MemPackedCategory>();
                treeStorage.put(treeId, tree);
            }
            List<MemCategoryDAO.MemPackedCategory> categories = tree.categories;
            while (index >= categories.size()) {
                categories.add(null);
            }

            categories.set(index, category);
        }
        populateOwnerMap();
    }
}

From source file:hudson.tasks.Shell.java

public String[] buildCommandLine(FilePath script) {
    if (command.startsWith("#!")) {
        // interpreter override
        int end = command.indexOf('\n');
        if (end < 0)
            end = command.length();//  www. j  a  va 2 s  . c  o  m
        List<String> args = new ArrayList<String>();
        args.addAll(Arrays.asList(Util.tokenize(command.substring(0, end).trim())));
        args.add(script.getRemote());
        args.set(0, args.get(0).substring(2)); // trim off "#!"
        return args.toArray(new String[args.size()]);
    } else
        return new String[] { getDescriptor().getShellOrDefault(script.getChannel()), "-xe",
                script.getRemote() };
}

From source file:com.mirth.connect.util.ValueReplacer.java

/**
 * Replaces all values in a list. Uses the default context along with the connector message and
 * all available variable maps./*from w ww.j  a  va 2 s  . co  m*/
 * 
 * @return void
 */
public void replaceValuesInList(List<String> list, ConnectorMessage connectorMessage) {
    for (int i = 0; i <= list.size() - 1; i++) {
        list.set(i, replaceValues(list.get(i), connectorMessage));
    }
}

From source file:com.allinfinance.startup.init.MenuInfoUtil.java

/**
 * ????//ww  w  .  jav  a2  s . c  om
 * @param menuBean
 */
@SuppressWarnings("unchecked")
private static void addLvl2Menu(Map<String, Object> menuBean) {
    List<Object> menuLvl1List = allMenuBean.getDataList();
    for (int i = 0, n = menuLvl1List.size(); i < n; i++) {
        Map<String, Object> tmpMenuBean = (Map<String, Object>) menuLvl1List.get(i);
        //??????????
        if (tmpMenuBean.get(Constants.MENU_ID).toString().trim()
                .equals(menuBean.get(Constants.MENU_PARENT_ID).toString().trim())) {
            if (!tmpMenuBean.containsKey(Constants.MENU_CHILDREN)) {
                LinkedList<Object> menuLvl2List = new LinkedList<Object>();
                menuLvl2List.add(menuBean);
                tmpMenuBean.put(Constants.MENU_CHILDREN, menuLvl2List);
            } else {
                LinkedList<Object> menuLvl2List = (LinkedList<Object>) tmpMenuBean.get(Constants.MENU_CHILDREN);
                menuLvl2List.add(menuBean);
                tmpMenuBean.put(Constants.MENU_CHILDREN, menuLvl2List);
            }
            menuLvl1List.set(i, tmpMenuBean);
        }
    }
    allMenuBean.setDataList(menuLvl1List);
}

From source file:au.org.ala.delta.intkey.WriteOnceIntkeyItemsFile.java

public void changeCharacterType(int characterNumber, int newType) {
    int record = _header.getRpSpec();
    List<Integer> charTypes = readIntegerList(record, _header.getNChar());

    charTypes.set(characterNumber - 1, newType);
    overwriteRecord(record, charTypes);/*www . ja  v  a 2 s  . c  o  m*/
}

From source file:com.evolveum.midpoint.provisioning.impl.manual.TestSemiManual.java

private void replaceInCsv(String[] data) throws IOException {
    List<String> lines = Files.readAllLines(Paths.get(CSV_TARGET_FILE.getPath()));
    for (int i = 0; i < lines.size(); i++) {
        String line = lines.get(i);
        String[] cols = line.split(",");
        if (cols[0].matches("\"" + data[0] + "\"")) {
            lines.set(i, formatCsvLine(data));
        }/*w  ww. j a  v  a2 s.c om*/
    }
    Files.write(Paths.get(CSV_TARGET_FILE.getPath()), lines, StandardOpenOption.WRITE);
}

From source file:com.bitranger.parknshop.common.service.ads.ItemAdService.java

public List<PsPromotItem> randomReduce(List<PsPromotItem> src, int limit) {
    if (src.size() > limit) {
        ThreadLocalRandom rand = ThreadLocalRandom.current();
        int idx = rand.nextInt(limit);
        int nidx = rand.nextInt(limit, src.size());
        src.set(idx, src.get(nidx));
        return new ArrayList<>(src.subList(0, limit));
    } else {//from ww  w . ja va 2  s . com
        return src;
    }
}

From source file:eu.udig.style.advanced.utils.Utilities.java

/**
 * Sets the offset in a symbolizer./*from  www .j  av  a  2 s.co m*/
 * 
 * @param symbolizer the symbolizer.
 * @param text the text representing the offsets in the CSV form.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void setOffset(Symbolizer symbolizer, String text) {
    if (text.indexOf(',') == -1) {
        return;
    }
    String[] split = text.split(",");
    if (split.length != 2) {
        return;
    }
    double xOffset = Double.parseDouble(split[0]);
    double yOffset = Double.parseDouble(split[1]);

    Expression geometry = symbolizer.getGeometry();
    if (geometry != null) {
        if (geometry instanceof FilterFunction_offset) {
            FilterFunction_offset offsetFunction = (FilterFunction_offset) geometry;
            List parameters = offsetFunction.getParameters();
            parameters.set(1, ff.literal(xOffset));
            parameters.set(2, ff.literal(yOffset));
        }
    } else {
        Function function = ff.function("offset", ff.property("the_geom"), ff.literal(xOffset),
                ff.literal(yOffset));
        symbolizer.setGeometry(function);
    }
}

From source file:models.ACLRole.java

public List<String> getFunctionalitiesBasenameList() {
    List<String> f_list = getFunctionalitiesList();
    UAFunctionalityContext functionality;
    for (int pos = 0; pos < f_list.size(); pos++) {
        functionality = UAManager.getByName(f_list.get(pos));
        if (functionality == null) {
            continue;
        }/*from w  w w  .j av a  2s.c o  m*/
        f_list.set(pos, functionality.getMessageBaseName());
    }
    return f_list;
}

From source file:techtonic.WellBoreListenerOnView.java

public void superImposGraph(List<WitsmlTrajectory> trajectorys) {
    int ct = 0;// w  w w .  j  a v a  2s.c  o  m
    XYSeriesCollection data = new XYSeriesCollection();
    for (WitsmlTrajectory trajectory : trajectorys) {

        List<WitsmlTrajectoryStation> stationsAsList = Arrays
                .asList(new WitsmlTrajectoryStation[trajectory.getStations().size()]);
        for (WitsmlTrajectoryStation s : trajectory.getStations()) {
            stationsAsList.set(s.getStationNo(), s);
        }

        XYSeries series = new XYSeries(trajectory.getName());
        // add data to Dataset (here assume data is in ArrayLists x and y

        for (WitsmlTrajectoryStation station : stationsAsList) {

            Value tvd = station.getTvd();

            if (tvd == null) {
                continue;
            }
            Value md = station.getNorth();
            if (md == null) {
                continue;
            }
            //  System.out.println(count + " : ===>> tvd : "+tvd.getValue()+ "; md "+md.getValue());
            series.add(md.getValue(), tvd.getValue());

        }

        data.addSeries(series);
        ct++;
    }
    // create a chart using the createYLineChart method...
    JFreeChart chart = ChartFactory.createXYLineChart("Trajectory: True Vertical Depth Against North", // chart title
            "North", "Depth", // x and y axis labels
            data); // data

    ChartPanel cp = new ChartPanel(chart);
    //            JFrame fr = new JFrame();
    //            fr.add(cp);
    //            fr.pack();
    //            fr.setVisible(true);
    cp.setMouseZoomable(true, true);
    Techtonic.setFreeChart(chart);
    Techtonic.setDisplayArea(cp);

}