Example usage for java.util LinkedHashMap containsKey

List of usage examples for java.util LinkedHashMap containsKey

Introduction

In this page you can find the example usage for java.util LinkedHashMap containsKey.

Prototype

boolean containsKey(Object key);

Source Link

Document

Returns true if this map contains a mapping for the specified key.

Usage

From source file:ca.sfu.federation.model.InputTable.java

/**
 * Add a property to the table.//  w  w  w  .j  a v  a  2 s .  c om
 * @param Name Input name.
 * @param Description Input description.
 * @param Clazz Input class.
 * @throws DuplicatePropertyException A property with the same name already exists in the table.
 */
private void addInput(String Name, String Description, Class Clazz) throws DuplicatePropertyException {
    // create the new input
    Input myInput = new Input(Name, Description, Clazz, this.parent.getContext());
    // add the input to the list and index
    String name = myInput.getName();
    LinkedHashMap index = this.getInputIndex();
    if (!index.containsKey(name)) {
        this.inputs.add(myInput);
    } else {
        throw new DuplicatePropertyException();
    }
}

From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.MultipleCurrencyParameterSensitivity.java

/**
 * Create a copy of the sensitivity and add a given named sensitivity to it. If the name / currency pair is in the map, the two sensitivity matrices are added.
 * Otherwise, a new entry is put into the map
 * @param nameCcy The name and the currency, not null
 * @param sensitivity The sensitivity to add, not null
 * @return The total sensitivity.// w  w  w.  ja  v a2  s  .  com
 */
public MultipleCurrencyParameterSensitivity plus(final Pair<String, Currency> nameCcy,
        final DoubleMatrix1D sensitivity) {
    ArgumentChecker.notNull(nameCcy, "Name/currency");
    ArgumentChecker.notNull(sensitivity, "Matrix");
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D> result = new LinkedHashMap<>();
    result.putAll(_sensitivity);
    if (result.containsKey(nameCcy)) {
        result.put(nameCcy, (DoubleMatrix1D) algebra.add(result.get(nameCcy), sensitivity));
    } else {
        result.put(nameCcy, sensitivity);
    }
    return new MultipleCurrencyParameterSensitivity(result);
}

From source file:net.chris54721.infinitycubed.workers.PackLoader.java

@Override
public void run() {
    try {//from www  . j av  a2  s .  c o  m
        LogHelper.info("Loading and updating modpacks");
        String publicJson = Utils.toString(new URL(Reference.FILES_URL + "public.json"));
        Type stringIntMap = new TypeToken<LinkedHashMap<String, Integer>>() {
        }.getType();
        LinkedHashMap<String, Integer> publicObjects = Reference.DEFAULT_GSON.fromJson(publicJson,
                stringIntMap);
        File localJson = new File(Resources.getFolder(Reference.PACKS_FOLDER), "public.json");
        List<String> updatePacks = new ArrayList<String>();
        if (localJson.isFile()) {
            String localPublicJson = Files.toString(localJson, Charsets.UTF_8);
            LinkedHashMap<String, Integer> localPublicObjects = Reference.DEFAULT_GSON.fromJson(localPublicJson,
                    stringIntMap);
            for (String pack : publicObjects.keySet()) {
                if (!localPublicObjects.containsKey(pack)
                        || !localPublicObjects.get(pack).equals(publicObjects.get(pack))) {
                    updatePacks.add(pack);
                }
            }
        } else
            updatePacks.addAll(publicObjects.keySet());
        Files.write(publicJson, localJson, Charsets.UTF_8);
        if (updatePacks.size() > 0) {
            for (String pack : updatePacks) {
                LogHelper.info("Updating JSON file for modpack " + pack);
                URL packJsonURL = Resources.getUrl(Resources.ResourceType.PACK_JSON, pack + ".json");
                File packJsonFile = Resources.getFile(Resources.ResourceType.PACK_JSON, pack + ".json");
                if (packJsonFile.isFile())
                    packJsonFile.delete();
                Downloadable packJsonDownloadable = new Downloadable(packJsonURL, packJsonFile);
                if (!packJsonDownloadable.download())
                    LogHelper.error("Failed updating JSON for modpack " + pack);
            }
        }
        Collection<File> packJsons = FileUtils.listFiles(Resources.getFolder(Reference.DATA_FOLDER),
                new String[] { "json" }, false);
        for (File packJsonFile : packJsons)
            loadPack(FilenameUtils.getBaseName(packJsonFile.getName()));
    } catch (Exception e) {
        LogHelper.fatal("Failed updating and loading public packs", e);
    }
}

From source file:org.karndo.graphs.CustomChartFactory.java

/**
 * Creates a chart of the selected PiracyEvent data graphed by vessel
 * type. Presently uses a very basic method of graphing this data by 
 * using the static CreateBarChart3D method available in class
 * org.jfree.chart.ChartFactory.     //w ww.jav  a  2  s.c  o m
 * 
 * @param data the selected PiracyEvent data to graph.
 * @return A JFreeChart object representing a graph of the selected 
 * PiracyEvent data against vessel type.
 */
public JFreeChart createHistogramVesselType(LinkedList<PiracyEvent> data) {
    //the data to plot
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    LinkedHashMap<String, MutableInt> freqs_cats = new LinkedHashMap<String, MutableInt>();

    for (PiracyEvent ev : data) {
        if (!freqs_cats.containsKey(ev.getVesselType())) {
            freqs_cats.put(ev.getVesselType(), new MutableInt(1));
        } else {
            freqs_cats.get(ev.getVesselType()).increment();
        }
    }

    Iterator itr = freqs_cats.keySet().iterator();
    while (itr.hasNext()) {
        String category = (String) itr.next();
        Integer i1 = freqs_cats.get(category).getValue();
        dataset.addValue(i1, "Piracy Incidents", category);
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Piracy Incidents " + "by vessel type", "Vessel Type",
            "Frequency", dataset, PlotOrientation.VERTICAL, false, true, false);
    return chart;
}

From source file:org.karndo.graphs.CustomChartFactory.java

/**
 * Creates a chart of the selected PiracyEvent data graphed by event 
 * status. Presently uses a very basic method of graphing this data by 
 * using the static CreateBarChart3D method available in class
 * org.jfree.chart.ChartFactory.    //from  w  ww  .  j a  v  a 2  s  .c  o  m
 * 
 * @param data the selected PiracyEvent data to graph.
 * @return A JFreeChart object representing a graph of the selected 
 * PiracyEvent data against event status.
 */
public JFreeChart createHistogramStatus(LinkedList<PiracyEvent> data) {
    //the data to plot
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    LinkedHashMap<String, MutableInt> freqs_cats = new LinkedHashMap<String, MutableInt>();

    for (PiracyEvent ev : data) {
        if (!freqs_cats.containsKey(ev.getStatus())) {
            freqs_cats.put(ev.getStatus(), new MutableInt(1));
        } else {
            freqs_cats.get(ev.getStatus()).increment();
        }
    }

    Iterator itr = freqs_cats.keySet().iterator();
    while (itr.hasNext()) {
        String category = (String) itr.next();
        Integer i1 = freqs_cats.get(category).getValue();
        dataset.addValue(i1, "Piracy Incidents", category);
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Piracy Incidents " + "by event status", "Event Status",
            "Frequency", dataset, PlotOrientation.VERTICAL, false, true, false);
    return chart;
}

From source file:org.eda.fpsrv.FPParams.java

public void setFromJSONString(String jsonString) throws IOException {
    LinkedHashMap<String, String> h_map;
    h_map = new ObjectMapper().readValue(jsonString, new TypeReference<LinkedHashMap<String, Object>>() {
    });/*from  w w w.j  a  v  a2s  .c o  m*/
    FPProperty property;
    for (String key : properties.keySet()) {
        if (h_map.containsKey(key)) {
            property = properties.get(key);
            property.setValue(h_map.get(key));
        }
    }
}

From source file:org.cytoscape.kddn.internal.KddnMethods.java

/**
 * variable selection based on t-test/* ww  w  . j  a  v a2s.  co  m*/
 * @param var
 * @param d1
 * @param d2
 * @return
 */
public static int[] variableSelection(String[] var, double[][] d1, double[][] d2) {

    LinkedHashMap<String, Integer> selectedVar = new LinkedHashMap<String, Integer>();
    LinkedHashMap<String, Double> varPvalue = new LinkedHashMap<String, Double>();

    TTest aTest = new TTest();

    for (int i = 0; i < var.length; i++) {
        double pval = 0;

        // equal variance
        //pval = aTest.homoscedasticTTest(getColumn(d1,i), getColumn(d2,i));
        // unequal variance
        pval = aTest.tTest(getColumn(d1, i), getColumn(d2, i));

        if (selectedVar.containsKey(var[i])) {
            if (varPvalue.get(var[i]) > pval) {
                selectedVar.put(var[i], i);
                varPvalue.put(var[i], pval);
            }
        } else {
            selectedVar.put(var[i], i);
            varPvalue.put(var[i], pval);
        }
    }

    int[] idx = new int[selectedVar.size()];
    int i = 0;
    for (String s : selectedVar.keySet()) {
        idx[i] = selectedVar.get(s);
        i++;
    }

    return idx;
}

From source file:com.logsniffer.reader.grok.GrokTextReader.java

@Override
public LinkedHashMap<String, FieldBaseTypes> getFieldTypes() throws FormatException {
    init();/*from   w ww.  j  a  va 2s  .  c  o  m*/
    final LinkedHashMap<String, FieldBaseTypes> fields = super.getFieldTypes();
    fields.putAll(grokBean.getGrok(groksRegistry).getFieldTypes());
    if (overflowAttribute != null && !fields.containsKey(overflowAttribute)) {
        fields.put(overflowAttribute, FieldBaseTypes.STRING);
    }
    return fields;
}

From source file:com.johan.vertretungsplan.parser.UntisMonitorParser.java

public Vertretungsplan getVertretungsplan() throws IOException, JSONException {
    new LoginHandler(schule).handleLogin(executor, cookieStore, username, password); //

    JSONArray urls = schule.getData().getJSONArray("urls");
    String encoding = schule.getData().getString("encoding");
    List<Document> docs = new ArrayList<Document>();

    for (int i = 0; i < urls.length(); i++) {
        JSONObject url = urls.getJSONObject(i);
        loadUrl(url.getString("url"), encoding, url.getBoolean("following"), docs);
    }//w  w  w . j  a va  2s.  co  m

    LinkedHashMap<String, VertretungsplanTag> tage = new LinkedHashMap<String, VertretungsplanTag>();
    for (Document doc : docs) {
        if (doc.title().contains("Untis")) {
            VertretungsplanTag tag = parseMonitorVertretungsplanTag(doc, schule.getData());
            if (!tage.containsKey(tag.getDatum())) {
                tage.put(tag.getDatum(), tag);
            } else {
                VertretungsplanTag tagToMerge = tage.get(tag.getDatum());
                tagToMerge.merge(tag);
                tage.put(tag.getDatum(), tagToMerge);
            }
        } else {
            //Fehler
        }
    }
    Vertretungsplan v = new Vertretungsplan();
    v.setTage(new ArrayList<VertretungsplanTag>(tage.values()));

    return v;
}

From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.SimpleParameterSensitivity.java

/**
 * Create a copy of the sensitivity and add a given sensitivity to it.
 * @param other The sensitivity to add.//  w ww  .jav a  2  s .  co  m
 * @return The total sensitivity.
 */
public SimpleParameterSensitivity plus(final SimpleParameterSensitivity other) {
    ArgumentChecker.notNull(other, "Sensitivity to add");
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final LinkedHashMap<String, DoubleMatrix1D> result = new LinkedHashMap<>();
    result.putAll(_sensitivity);
    for (final Map.Entry<String, DoubleMatrix1D> entry : other.getSensitivities().entrySet()) {
        final String name = entry.getKey();
        if (result.containsKey(name)) {
            result.put(name, (DoubleMatrix1D) algebra.add(result.get(name), entry.getValue()));
        } else {
            result.put(name, entry.getValue());
        }
    }
    return new SimpleParameterSensitivity(result);
}