Example usage for java.util ArrayList set

List of usage examples for java.util ArrayList set

Introduction

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

Prototype

public E set(int index, E element) 

Source Link

Document

Replaces the element at the specified position in this list with the specified element.

Usage

From source file:net.opentsdb.tree.Leaf.java

/**
 * Attempts to parse the leaf from the given column, optionally loading the
 * UID names. This is used by the branch loader when scanning an entire row.
 * <b>Note:</b> The column better have a qualifier that starts with "leaf:" or
 * we're likely to throw a parsing exception.
 * @param tsdb The TSDB to use for storage access
 * @param column Column to parse a leaf from
 * @param load_uids Whether or not to load UID names from the TSD
 * @return The parsed leaf if successful
 * @throws IllegalArgumentException if the column was missing data
 * @throws NoSuchUniqueId If any of the UID name mappings do not exist
 * @throws HBaseException if there was an issue
 * @throws JSONException if the object could not be serialized
 *///from   w  w w  .  ja v  a  2s . c  o m
public static Deferred<Leaf> parseFromStorage(final TSDB tsdb, final KeyValue column, final boolean load_uids) {
    if (column.value() == null) {
        throw new IllegalArgumentException("Leaf column value was null");
    }

    // qualifier has the TSUID in the format  "leaf:<display_name.hashCode()>"
    // and we should only be here if the qualifier matched on "leaf:"
    final Leaf leaf = JSON.parseToObject(column.value(), Leaf.class);

    // if there was an error with the data and the tsuid is missing, dump it
    if (leaf.tsuid == null || leaf.tsuid.isEmpty()) {
        LOG.warn("Invalid leaf object in row: " + Branch.idToString(column.key()));
        return Deferred.fromResult(null);
    }

    // if we don't need to load UIDs, then return now
    if (!load_uids) {
        return Deferred.fromResult(leaf);
    }

    // split the TSUID to get the tags
    final List<byte[]> parsed_tags = UniqueId.getTagsFromTSUID(leaf.tsuid);

    // initialize the with empty objects, otherwise the "set" operations in 
    // the callback won't work.
    final ArrayList<String> tags = new ArrayList<String>(parsed_tags.size());
    for (int i = 0; i < parsed_tags.size(); i++) {
        tags.add("");
    }

    // setup an array of deferreds to wait on so we can return the leaf only
    // after all of the name fetches have completed
    final ArrayList<Deferred<Object>> uid_group = new ArrayList<Deferred<Object>>(parsed_tags.size() + 1);

    /**
     * Callback executed after the UID name has been retrieved successfully.
     * The {@code index} determines where the result is stored: -1 means metric, 
     * >= 0 means tag
     */
    final class UIDNameCB implements Callback<Object, String> {
        final int index;

        public UIDNameCB(final int index) {
            this.index = index;
        }

        @Override
        public Object call(final String name) throws Exception {
            if (index < 0) {
                leaf.metric = name;
            } else {
                tags.set(index, name);
            }
            return null;
        }

    }

    // fetch the metric name first
    final byte[] metric_uid = UniqueId.stringToUid(leaf.tsuid.substring(0, TSDB.metrics_width() * 2));
    uid_group.add(tsdb.getUidName(UniqueIdType.METRIC, metric_uid).addCallback(new UIDNameCB(-1)));

    int idx = 0;
    for (byte[] tag : parsed_tags) {
        if (idx % 2 == 0) {
            uid_group.add(tsdb.getUidName(UniqueIdType.TAGK, tag).addCallback(new UIDNameCB(idx)));
        } else {
            uid_group.add(tsdb.getUidName(UniqueIdType.TAGV, tag).addCallback(new UIDNameCB(idx)));
        }
        idx++;
    }

    /**
     * Called after all of the UID name fetches have completed and parses the
     * tag name/value list into name/value pairs for proper display
     */
    final class CollateUIDsCB implements Callback<Deferred<Leaf>, ArrayList<Object>> {

        /**
         * @return A valid Leaf object loaded with UID names
         */
        @Override
        public Deferred<Leaf> call(final ArrayList<Object> name_calls) throws Exception {
            int idx = 0;
            String tagk = "";
            leaf.tags = new HashMap<String, String>(tags.size() / 2);
            for (String name : tags) {
                if (idx % 2 == 0) {
                    tagk = name;
                } else {
                    leaf.tags.put(tagk, name);
                }
                idx++;
            }
            return Deferred.fromResult(leaf);
        }

    }

    // wait for all of the UID name fetches in the group to complete before
    // returning the leaf
    return Deferred.group(uid_group).addCallbackDeferring(new CollateUIDsCB());
}

From source file:com.liferay.ide.portlet.core.PluginPackageModel.java

public void swapDependencies(String property, String dep1, String dep2) {
    String[] deps = null;//from  w  w w  .j a  v  a2  s  .co m
    String depsValue = pluginPackageProperties.getString(property, null);

    if (depsValue != null) {
        deps = depsValue.split(","); //$NON-NLS-1$
    } else {
        deps = new String[0];
    }

    ArrayList<String> list = new ArrayList<String>();
    Collections.addAll(list, deps);

    int index1 = list.indexOf(dep1);
    int index2 = list.indexOf(dep2);
    list.set(index2, dep1);
    list.set(index1, dep2);

    String[] newValues = list.toArray(new String[0]);

    StringBuffer buffer = new StringBuffer();

    for (String val : newValues) {
        buffer.append(val + ","); //$NON-NLS-1$
    }

    String newValue = buffer.toString().substring(0, buffer.length() - 1);
    pluginPackageProperties.setProperty(property, newValue);

    flushProperties();

    fireModelChanged(new ModelChangedEvent(this, null, property, depsValue, newValue));
}

From source file:com.ge.research.semtk.load.DataCleaner.java

/**
 * Take a row of data and remove null strings
 * @param row the input row of data//from  ww w . j  a  va 2s  .c o  m
 * @return cleaned rows of data
 */
private ArrayList<String> performRemoveNulls(ArrayList<String> row) {
    String value;
    for (int i = 0; i < row.size(); i++) { // for each value in the row         
        value = row.get(i);
        if (value.trim().equalsIgnoreCase("null")) { // if's null string
            row.set(i, ""); // change to empty string
        }
    }
    return row;
}

From source file:hrpod.tools.nlp.NLPTools.java

public ArrayList<String> stemmer(ArrayList<String> wordList) {
    PorterStemmer stemmer = new PorterStemmer();
    for (int wl = 0; wl < wordList.size(); wl++) {
        //logger.info("OLD WORD: " + wordList.get(wl));
        ArrayList<String> subWordList = new ArrayList();
        subWordList.addAll(Arrays.asList(wordList.get(wl).split(" ")));
        for (int swl = 0; swl < subWordList.size(); swl++) {
            String word = subWordList.get(swl);
            stemmer.setCurrent(word); //set string you need to stem
            stemmer.stem();/*w  ww  . j  a v a2s  .  com*/
            String stemmedWord = stemmer.getCurrent();
            subWordList.set(swl, stemmedWord);
        }
        wordList.set(wl, StringUtils.join(subWordList, " "));
        //logger.info("NEW WORD: " + wordList.get(wl));
    }

    return wordList;

}

From source file:com.predic8.membrane.core.transport.http.ConnectionManager.java

private int closeOldConnections() {
    ArrayList<ConnectionKey> toRemove = new ArrayList<ConnectionKey>();
    ArrayList<Connection> toClose = new ArrayList<Connection>();
    long now = System.currentTimeMillis();
    log.trace("closing old connections");
    int closed = 0, remaining;
    synchronized (this) {
        // close connections after their timeout
        for (Map.Entry<ConnectionKey, ArrayList<OldConnection>> e : availableConnections.entrySet()) {
            ArrayList<OldConnection> l = e.getValue();
            for (int i = 0; i < l.size(); i++) {
                OldConnection o = l.get(i);
                if (o.deathTime < now) {
                    // replace [i] by [last]
                    if (i == l.size() - 1)
                        l.remove(i);//  w  w  w.j  av a2s  .com
                    else
                        l.set(i, l.remove(l.size() - 1));
                    --i;
                    closed++;
                    toClose.add(o.connection);
                }
            }
            if (l.isEmpty())
                toRemove.add(e.getKey());
        }
        for (ConnectionKey remove : toRemove)
            availableConnections.remove(remove);
        remaining = availableConnections.size();
    }
    for (Connection c : toClose) {
        try {
            c.close();
        } catch (Exception e) {
            // do nothing
        }
    }
    if (closed != 0)
        log.debug("closed " + closed + " connections");
    return remaining;
}

From source file:com.ge.research.semtk.load.DataCleaner.java

/**
 * Take a row of data and converts appropriate values to lower case.
 * @param row the input row of data/*ww  w  . j  ava2  s  .c o  m*/
 * @return cleaned rows of data
 */
private ArrayList<String> performLowerCase(ArrayList<String> row) {
    String header;
    String value;
    for (int i = 0; i < row.size(); i++) { // for each value in the row         
        value = row.get(i);
        header = headers.get(i);

        if (columnsToLowerCase.contains(header)) {
            row.set(i, value.toLowerCase());
        }
    }
    return row;
}

From source file:org.apache.sysml.runtime.codegen.SpoofOperator.java

protected SideInput[] prepInputMatrices(ArrayList<MatrixBlock> inputs, int offset, int len, boolean denseOnly,
        boolean tB1) {
    SideInput[] b = new SideInput[len];
    for (int i = offset; i < offset + len; i++) {
        //decompress if necessary
        if (inputs.get(i) instanceof CompressedMatrixBlock)
            inputs.set(i, ((CompressedMatrixBlock) inputs.get(i)).decompress());
        //transpose if necessary
        int clen = inputs.get(i).getNumColumns();
        MatrixBlock in = (tB1 && i == 1) ? LibMatrixReorg.transpose(inputs.get(i),
                new MatrixBlock(clen, inputs.get(i).getNumRows(), false)) : inputs.get(i);

        //create side input
        if (denseOnly && (in.isInSparseFormat() || !in.isAllocated())) {
            //convert empty or sparse to dense temporary block (note: we don't do
            //this in place because this block might be used by multiple threads)
            if (in.getNumColumns() == 1 && in.isEmptyBlock(false)) //dense empty
                b[i - offset] = new SideInput(null, null, clen);
            else {
                b[i - offset] = new SideInput(DataConverter.convertToDenseBlock(in, false), null, clen);
                LOG.warn(getClass().getName() + ": Converted " + in.getNumRows() + "x" + in.getNumColumns()
                        + ", nnz=" + in.getNonZeros() + " sideways input matrix from sparse to dense.");
            }/*from  ww w  .  j  a va2  s. c  om*/
        } else if (in.isInSparseFormat() || !in.isAllocated()) {
            b[i - offset] = new SideInput(null, in, clen);
        } else {
            b[i - offset] = new SideInput(in.getDenseBlock(), null, clen);
        }
    }

    return b;
}

From source file:org.talend.designer.scd.util.TableEditorManager.java

public void addEditor(TableItem item, int column, TableEditor editor) {
    ArrayList<TableEditor> editors = (ArrayList<TableEditor>) editorMap.get(item);
    if (editors == null) {
        editors = new ArrayList<TableEditor>();
        editorMap.put(item, editors);/*from   w ww.j a va2 s . com*/
    }

    if (editors.size() <= column) {
        for (int i = editors.size(); i <= column; i++) {
            // add place holder to prevent index out of bound exception
            editors.add(null);
        }
    }
    editors.set(column, editor);
}

From source file:com.sillelien.dollar.api.types.DollarList.java

@NotNull
@Override//from   ww  w  . j a v  a 2 s .c  o m
public var $set(@NotNull var key, Object value) {
    ArrayList<var> newVal = new ArrayList<>(list.mutable());
    if (key.integer()) {
        newVal.set(key.toInteger(), DollarFactory.fromValue(value));
    } else {
        return DollarFactory.failure(ErrorType.INVALID_LIST_OPERATION);
    }
    return DollarFactory.fromValue(newVal, errors());
}

From source file:com.maxl.java.aips2xml.Aips2Xml.java

static void extractPackageInfo() {
    try {//w  ww  . j av a 2 s  .c  om
        long startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Processing packages xls ... ");
        // Load Swissmedic xls file
        FileInputStream packages_file = new FileInputStream(FILE_PACKAGES_XLS);
        // Get workbook instance for XLS file (HSSF = Horrible SpreadSheet Format)
        HSSFWorkbook packages_workbook = new HSSFWorkbook(packages_file);
        // Get first sheet from workbook
        HSSFSheet packages_sheet = packages_workbook.getSheetAt(0);
        // Iterate through all rows of first sheet
        Iterator<Row> rowIterator = packages_sheet.iterator();

        int num_rows = 0;
        while (rowIterator.hasNext()) {
            Row row = rowIterator.next();
            if (num_rows > 3) {
                String swissmedic_no5 = ""; // SwissmedicNo5 registration number (5 digits)
                String sequence_name = "";
                String package_id = "";
                String swissmedic_no8 = ""; // SwissmedicNo8 = SwissmedicNo5 + Package id (8 digits)
                String heilmittel_code = "";
                String package_size = "";
                String package_unit = "";
                String swissmedic_cat = "";
                String application_area = "";
                String public_price = "";
                String exfactory_price = "";
                String therapeutic_index = "";
                String withdrawn_str = "";
                String speciality_str = "";
                String plimitation_str = "";
                String add_info_str = ""; // Contains additional information separated by ;

                // 0: Zulassungsnnr, 1: Sequenz, 2: Sequenzname, 3: Zulassunginhaberin, 4: T-Nummer, 5: ATC-Code, 6: Heilmittelcode
                // 7: Erstzulassung Prparat, 8: Zulassungsdatum Sequenz, 9: Gltigkeitsdatum, 10: Verpackung, 11: Packungsgrsse
                // 12: Einheit, 13: Abgabekategorie, 14: Wirkstoff, 15: Zusammensetzung, 16: Anwendungsgebiet Prparat, 17: Anwendungsgebiet Sequenz

                swissmedic_no5 = getAnyValue(row.getCell(0)); // Swissmedic registration number (5 digits)
                sequence_name = getAnyValue(row.getCell(2)); // Sequence name
                heilmittel_code = getAnyValue(row.getCell(6));
                package_size = getAnyValue(row.getCell(11));
                package_unit = getAnyValue(row.getCell(12));
                swissmedic_cat = getAnyValue(row.getCell(13));
                application_area = getAnyValue(row.getCell(16));

                if (row.getCell(10) != null) {
                    package_id = getAnyValue(row.getCell(10));
                    swissmedic_no8 = swissmedic_no5 + package_id;
                    // Fill in row
                    ArrayList<String> pack = new ArrayList<String>();
                    pack.add(swissmedic_no5); // 0
                    pack.add(sequence_name); // 1
                    pack.add(heilmittel_code); // 2
                    pack.add(package_size); // 3
                    pack.add(package_unit); // 4
                    pack.add(swissmedic_cat); // 5
                    if (!application_area.isEmpty())
                        pack.add(application_area + " (Swissmedic)\n"); // 6 = swissmedic + bag
                    else
                        pack.add("");
                    pack.add(public_price); // 7
                    pack.add(exfactory_price); // 8
                    pack.add(therapeutic_index); // 9
                    pack.add(withdrawn_str); // 10
                    pack.add(speciality_str); // 11   
                    pack.add(plimitation_str); // 12
                    pack.add(add_info_str); // 13

                    package_info.put(swissmedic_no8, pack);
                }
            }
            num_rows++;
        }
        long stopTime = System.currentTimeMillis();
        if (SHOW_LOGS) {
            System.out.println(
                    (package_info.size() + 1) + " packages in " + (stopTime - startTime) / 1000.0f + " sec");
        }
        startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Processing atc classes xls ... ");
        if (DB_LANGUAGE.equals("de")) {
            // Load ATC classes xls file
            FileInputStream atc_classes_file = new FileInputStream(FILE_ATC_CLASSES_XLS);
            // Get workbook instance for XLS file (HSSF = Horrible SpreadSheet Format)
            HSSFWorkbook atc_classes_workbook = new HSSFWorkbook(atc_classes_file);
            // Get first sheet from workbook
            HSSFSheet atc_classes_sheet = atc_classes_workbook.getSheetAt(1);
            // Iterate through all rows of first sheet
            rowIterator = atc_classes_sheet.iterator();

            num_rows = 0;
            while (rowIterator.hasNext()) {
                Row row = rowIterator.next();
                if (num_rows > 2) {
                    String atc_code = "";
                    String atc_class = "";
                    if (row.getCell(0) != null) {
                        atc_code = row.getCell(0).getStringCellValue().replaceAll("\\s", "");
                    }
                    if (row.getCell(2) != null) {
                        atc_class = row.getCell(2).getStringCellValue();
                    }
                    // Build a full map atc code to atc class
                    if (atc_code.length() > 0) {
                        atc_map.put(atc_code, atc_class);
                    }
                }
                num_rows++;
            }
        } else if (DB_LANGUAGE.equals("fr")) {
            // Load multilinguagl ATC classes txt file
            String atc_classes_multi = readFromFile(FILE_ATC_MULTI_LINGUAL_TXT);
            // Loop through all lines
            Scanner scanner = new Scanner(atc_classes_multi);
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                List<String> atc_class = Arrays.asList(line.split(": "));
                String atc_code = atc_class.get(0);
                String[] atc_classes_str = atc_class.get(1).split(";");
                String atc_class_french = atc_classes_str[1].trim();
                atc_map.put(atc_code, atc_class_french);
            }
            scanner.close();
        }
        stopTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out
                    .println((atc_map.size() + 1) + " classes in " + (stopTime - startTime) / 1000.0f + " sec");
        // Load Refdata xml file
        File refdata_xml_file = null;
        if (DB_LANGUAGE.equals("de"))
            refdata_xml_file = new File(FILE_REFDATA_PHARMA_DE_XML);
        else if (DB_LANGUAGE.equals("fr"))
            refdata_xml_file = new File(FILE_REFDATA_PHARMA_FR_XML);
        else {
            System.err.println("ERROR: DB_LANGUAGE undefined");
            System.exit(1);
        }
        FileInputStream refdata_fis = new FileInputStream(refdata_xml_file);

        startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Unmarshalling Refdata Pharma " + DB_LANGUAGE + " ... ");

        JAXBContext context = JAXBContext.newInstance(Pharma.class);
        Unmarshaller um = context.createUnmarshaller();
        Pharma refdataPharma = (Pharma) um.unmarshal(refdata_fis);
        List<Pharma.ITEM> pharma_list = refdataPharma.getItem();

        String smno8;
        for (Pharma.ITEM pharma : pharma_list) {
            String ean_code = pharma.getGtin();
            if (ean_code.length() == 13) {
                smno8 = ean_code.substring(4, 12);
                // Extract pharma corresponding to swissmedicno8
                ArrayList<String> pi_row = package_info.get(smno8);
                // Replace sequence_name
                if (pi_row != null) {
                    if (pharma.getAddscr().length() > 0)
                        pi_row.set(1, pharma.getDscr() + ", " + pharma.getAddscr());
                    else
                        pi_row.set(1, pharma.getDscr());
                    if (pharma.getStatus().equals("I")) {
                        if (DB_LANGUAGE.equals("de"))
                            pi_row.set(10, "a.H.");
                        else if (DB_LANGUAGE.equals("fr"))
                            pi_row.set(10, "p.c.");
                    }
                } else {
                    if (SHOW_ERRORS)
                        System.err.println(">> Does not exist in BAG xls: " + smno8 + " (" + pharma.getDscr()
                                + ", " + pharma.getAddscr() + ")");
                }

            } else if (ean_code.length() < 13) {
                if (SHOW_ERRORS)
                    System.err.println(">> EAN code too short: " + ean_code + ": " + pharma.getDscr());
            } else if (ean_code.length() > 13) {
                if (SHOW_ERRORS)
                    System.err.println(">> EAN code too long: " + ean_code + ": " + pharma.getDscr());
            }
        }

        stopTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.println(pharma_list.size() + " medis in " + (stopTime - startTime) / 1000.0f + " sec");

        // Load BAG xml file               
        File bag_xml_file = new File(FILE_PREPARATIONS_XML);
        FileInputStream fis_bag = new FileInputStream(bag_xml_file);

        startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Processing preparations xml ... ");

        context = JAXBContext.newInstance(Preparations.class);
        um = context.createUnmarshaller();
        Preparations prepInfos = (Preparations) um.unmarshal(fis_bag);
        List<Preparations.Preparation> prep_list = prepInfos.getPreparations();

        int num_preparations = 0;
        for (Preparations.Preparation prep : prep_list) {
            String swissmedicno5_str = prep.getSwissmedicNo5();
            if (swissmedicno5_str != null) {
                String orggencode_str = ""; // "O", "G" or empty -> ""
                String flagSB20_str = ""; // "Y" -> 20% or "N" -> 10%                     
                if (prep.getOrgGenCode() != null)
                    orggencode_str = prep.getOrgGenCode();
                if (prep.getFlagSB20() != null) {
                    flagSB20_str = prep.getFlagSB20();
                    if (flagSB20_str.equals("Y")) {
                        if (DB_LANGUAGE.equals("de"))
                            flagSB20_str = "SB 20%";
                        else if (DB_LANGUAGE.equals("fr"))
                            flagSB20_str = "QP 20%";
                    } else if (flagSB20_str.equals("N")) {
                        if (DB_LANGUAGE.equals("de"))
                            flagSB20_str = "SB 10%";
                        else if (DB_LANGUAGE.equals("fr"))
                            flagSB20_str = "QP 10%";
                    } else
                        flagSB20_str = "";
                }
                add_info_map.put(swissmedicno5_str, orggencode_str + ";" + flagSB20_str);
            }

            List<Preparation.Packs> packs_list = prep.getPacks();
            for (Preparation.Packs packs : packs_list) {
                // Extract codes for therapeutic index / classification
                String bag_application = "";
                String therapeutic_code = "";
                List<Preparations.Preparation.ItCodes> itcode_list = prep.getItCodes();
                for (Preparations.Preparation.ItCodes itc : itcode_list) {
                    List<Preparations.Preparation.ItCodes.ItCode> code_list = itc.getItCode();
                    int index = 0;
                    for (Preparations.Preparation.ItCodes.ItCode code : code_list) {
                        if (index == 0) {
                            if (DB_LANGUAGE.equals("de"))
                                therapeutic_code = code.getDescriptionDe();
                            else if (DB_LANGUAGE.equals("fr"))
                                therapeutic_code = code.getDescriptionFr();
                        } else {
                            if (DB_LANGUAGE.equals("de"))
                                bag_application = code.getDescriptionDe();
                            else if (DB_LANGUAGE.equals("fr"))
                                bag_application = code.getDescriptionFr();
                        }
                        index++;
                    }
                }
                // Generate new package info
                List<Preparation.Packs.Pack> pack_list = packs.getPack();
                for (Preparation.Packs.Pack pack : pack_list) {
                    // Get SwissmedicNo8 and used it as a key to extract all the relevant package info
                    String swissMedicNo8 = pack.getSwissmedicNo8();
                    ArrayList<String> pi_row = package_info.get(swissMedicNo8);
                    // Preparation also in BAG xml file (we have a price)
                    if (pi_row != null) {
                        // Update Swissmedic catory if necessary ("N->A", Y->"A+")
                        if (pack.getFlagNarcosis().equals("Y"))
                            pi_row.set(5, pi_row.get(5) + "+");
                        // Extract point limitations
                        List<Preparations.Preparation.Packs.Pack.PointLimitations> point_limits = pack
                                .getPointLimitations();
                        for (Preparations.Preparation.Packs.Pack.PointLimitations limits : point_limits) {
                            List<Preparations.Preparation.Packs.Pack.PointLimitations.PointLimitation> plimits_list = limits
                                    .getPointLimitation();
                            if (plimits_list.size() > 0)
                                if (plimits_list.get(0) != null)
                                    pi_row.set(12, ", LIM" + plimits_list.get(0).getPoints() + "");
                        }
                        // Extract exfactory and public prices
                        List<Preparations.Preparation.Packs.Pack.Prices> price_list = pack.getPrices();
                        for (Preparations.Preparation.Packs.Pack.Prices price : price_list) {
                            List<Preparations.Preparation.Packs.Pack.Prices.PublicPrice> public_price = price
                                    .getPublicPrice();
                            List<Preparations.Preparation.Packs.Pack.Prices.ExFactoryPrice> exfactory_price = price
                                    .getExFactoryPrice();
                            if (exfactory_price.size() > 0) {
                                try {
                                    float f = Float.valueOf(exfactory_price.get(0).getPrice());
                                    String ep = String.format("%.2f", f);
                                    pi_row.set(8, "CHF " + ep);
                                } catch (NumberFormatException e) {
                                    if (SHOW_ERRORS)
                                        System.err.println("Number format exception (exfactory price): "
                                                + swissMedicNo8 + " (" + public_price.size() + ")");
                                }

                            }
                            if (public_price.size() > 0) {
                                try {
                                    float f = Float.valueOf(public_price.get(0).getPrice());
                                    String pp = String.format("%.2f", f);
                                    pi_row.set(7, "CHF " + pp);
                                    if (DB_LANGUAGE.equals("de"))
                                        pi_row.set(11, ", SL");
                                    else if (DB_LANGUAGE.equals("fr"))
                                        pi_row.set(11, ", LS");
                                } catch (NumberFormatException e) {
                                    if (SHOW_ERRORS)
                                        System.err.println("Number format exception (public price): "
                                                + swissMedicNo8 + " (" + public_price.size() + ")");
                                }
                            }
                            // Add application area and therapeutic code
                            if (!bag_application.isEmpty())
                                pi_row.set(6, pi_row.get(6) + bag_application + " (BAG)");
                            pi_row.set(9, therapeutic_code);
                        }
                    }
                }
            }
            num_preparations++;
        }

        stopTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.println(
                    num_preparations + " preparations in " + (stopTime - startTime) / 1000.0f + " sec");

        // Loop through all SwissmedicNo8 numbers
        for (Map.Entry<String, ArrayList<String>> entry : package_info.entrySet()) {
            String swissmedicno8 = entry.getKey();
            ArrayList<String> pi_row = entry.getValue();
        }

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}