Example usage for java.util LinkedHashMap get

List of usage examples for java.util LinkedHashMap get

Introduction

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

Prototype

public V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:hydrograph.ui.propertywindow.propertydialog.PropertyDialogBuilder.java

private void addCustomWidgetsToGroupWidget(LinkedHashMap<String, ArrayList<Property>> subgroupTree,
        String subgroupName, AbstractELTContainerWidget subGroupContainer) {
    boolean isError = false;
    for (final Property property : subgroupTree.get(subgroupName)) {
        AbstractWidget eltWidget = addCustomWidgetInGroupWidget(subGroupContainer, property);
        eltWidgetList.add(eltWidget);/*from w ww  .ja v  a 2s  . c o  m*/

        if (!eltWidget.isWidgetValid()) {
            isError = true;
        }
    }

    if (isError) {
        for (CTabItem item : tabFolder.getItems()) {
            if (StringUtils.equalsIgnoreCase(StringUtils.trim(item.getText()),
                    subgroupTree.get(subgroupName).get(0).getPropertyGroup())) {
                item.setImage(ImagePathConstant.COMPONENT_ERROR_ICON.getImageFromRegistry());
            }
        }
    }

}

From source file:com.openerp.addons.note.EditNoteFragment.java

public void createNotetag() {

    AlertDialog.Builder builder = new Builder(scope.context());
    final EditText tag = new EditText(scope.context());
    builder.setTitle("Tag Name").setMessage("Enter new Tag").setView(tag);

    builder.setPositiveButton("Create", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface di, int i) {
            // do something with onClick
            if (tag.getText().length() > 0) {
                LinkedHashMap<String, String> newTag = db.writeNoteTags(tag.getText().toString());
                noteTags.addObject(/*from ww  w .ja va  2s  . c  o  m*/
                        new TagsItems(Integer.parseInt(newTag.get("newID")), newTag.get("tagName"), ""));
            } else {
                Toast.makeText(scope.context(), "Enter Tag First", Toast.LENGTH_LONG).show();
            }
        }
    });

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface di, int i) {
        }
    });

    builder.create().show();
}

From source file:com.opengamma.analytics.financial.curve.sensitivity.ParameterSensitivity.java

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

From source file:com.compomics.pride_asa_pipeline.core.logic.enzyme.EnzymePredictor.java

public Enzyme getMainEnzyme(LinkedHashMap<Enzyme, Integer> enzymecounts) {
    int chymoTrypsin;
    int argC;// w  ww  .  ja v  a  2s.co m
    int lysC;
    int pepsin;
    int trypsin;
    //if none of these, just pick the highest ranking

    Enzyme highestCount = enzymeFactory.getEnzyme("Trypsin");
    for (Enzyme anEnzyme : enzymecounts.keySet()) {
        int bestGuessCount = enzymecounts.get(highestCount);
        if (enzymecounts.get(anEnzyme) > bestGuessCount) {
            highestCount = anEnzyme;
        }
    }

    try {
        trypsin = enzymecounts.get(enzymeFactory.getEnzyme("Trypsin"));
    } catch (NullPointerException e) {
        trypsin = 0;
    }

    try {
        chymoTrypsin = enzymecounts.get(enzymeFactory.getEnzyme("Chymotrypsin (FYWL)"));
    } catch (NullPointerException e) {
        chymoTrypsin = 0;
    }
    try {
        pepsin = enzymecounts.get(enzymeFactory.getEnzyme("Pepsin A"));
    } catch (NullPointerException e) {
        pepsin = 0;
    }

    if (highestCount.getName().toUpperCase().contains("TRYPSIN +")
            && (double) chymoTrypsin < (double) (0.5 * trypsin)) {
        highestCount = enzymeFactory.getEnzyme("Trypsin");
    }

    //check if it's not chymotrypsin or pepsin...
    if (highestCount.getName().toUpperCase().contains("CHYMOTRYP")) {
        double trypsinToChymoTrypsin = (double) ((double) trypsin / (double) chymoTrypsin);
        double trypsinToPepsin = (double) ((double) trypsin / (double) pepsin);
        double pepsinToChymoTrypsin = (double) ((double) pepsin / (double) chymoTrypsin);
        if (trypsinToChymoTrypsin <= 0.5 && pepsinToChymoTrypsin < 0.8) {
            highestCount = enzymeFactory.getEnzyme("Chymotrypsin (FYWL)");
        } else if (trypsinToPepsin < 0.5) {
            highestCount = enzymeFactory.getEnzyme("Pepsin A");
        }
    } else if (highestCount.getName().toLowerCase().contains("pepsin")) {
        try {
            Enzyme chymoTrypsinEnzyme = enzymeFactory.getEnzyme("Chymotrypsin (FYWL)");
            chymoTrypsin = enzymecounts.get(chymoTrypsinEnzyme);
        } catch (NullPointerException e) {
            chymoTrypsin = 0;
        }
        //AT THIS POINT, IT IS NOT TRYPSIN, or C 
        if ((pepsin / chymoTrypsin) >= 0.9) {
            return highestCount;
        }
        highestCount = enzymeFactory.getEnzyme("Chymotrypsin (FYWL)");
    }

    //ELSE IT COULD VERY WELL BE TRYPSIN
    if (highestCount.getName().equalsIgnoreCase("trypsin")) {
        double trypsinToPepsin = (double) ((double) pepsin / (double) trypsin);

        try {
            argC = enzymecounts.get(enzymeFactory.getEnzyme("Arg-C"));
        } catch (NullPointerException e) {
            argC = 0;
        }
        try {
            lysC = enzymecounts.get(enzymeFactory.getEnzyme("Lys-C"));
        } catch (NullPointerException e) {
            lysC = 0;
        }
        //check if arg-c or lys-c
        double argToTryps = (double) (1 - ((double) argC / (double) trypsin));
        double lysToTryps = (double) (1 - ((double) lysC / (double) trypsin));
        if (trypsinToPepsin > 0.5) {
            highestCount = enzymeFactory.getEnzyme("Pepsin A");
        } else if (-0.1 < argToTryps && argToTryps < 0.1) {
            highestCount = enzymeFactory.getEnzyme("Arg-C");
        } else if (-0.1 < lysToTryps && lysToTryps < 0.1) {
            highestCount = enzymeFactory.getEnzyme("Lys-C");
        } else {
            highestCount = enzymeFactory.getEnzyme("Trypsin");
        }
    }

    bestGuess = highestCount;
    for (Enzyme anEnzyme : enzymecounts.keySet()) {
        System.out.println(anEnzyme.getName() + ":" + enzymecounts.get(anEnzyme));
    }
    return highestCount;
}

From source file:biz.netcentric.cq.tools.actool.configReader.YamlConfigReader.java

private Collection getConfigSection(final String sectionName, final Collection yamlList) {
    final List<LinkedHashMap<?, ?>> yamList = new ArrayList<LinkedHashMap<?, ?>>(yamlList);
    for (final LinkedHashMap<?, ?> currMap : yamList) {
        if (sectionName.equals(currMap.keySet().iterator().next())) {
            return (List<LinkedHashMap>) currMap.get(sectionName);
        }/*w  w w  . ja v  a  2  s. c  o  m*/
    }
    return null;
}

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

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

From source file:com.alibaba.wasp.plan.parser.druid.DruidDQLParser.java

private List<ColumnStruct> buildColumnsNotInIndex(FTable table, Index index, QueryInfo queryInfo)
        throws UnsupportedException {
    List<ColumnStruct> columns = new ArrayList<ColumnStruct>();
    LinkedHashMap<String, Field> fields = table.getColumns();
    for (String fieldname : queryInfo.getAllConditionFieldName()) {
        if (!index.getIndexKeys().containsKey(fieldname)) {
            Field field = fields.get(fieldname);
            if (field != null) {
                ColumnStruct column = buildColumnStruct(table, queryInfo, field);
                columns.add(column);//from www  .  j  a v  a2s  . c  o m
            }
        }
    }
    return columns;
}

From source file:com.att.aro.ui.view.diagnostictab.plot.DLPacketPlot.java

private void addSeries(Session session, LinkedHashMap<Color, PacketSeries> dlDatasets, AnalysisFilter filter) {
    Session thisSession = session;//from w ww.  ja v a2s  . c  o m

    for (PacketInfo packet : session.getAllPackets()) {
        if (packet.getDir() == null) {
            continue;
        }
        if (isDownloadPacket() && packet.getDir() == PacketDirection.DOWNLINK) {
            // Add the packet to the proper series based on color

            Color color = filter.getPacketColor(packet);
            PacketSeries series = dlDatasets.get(color);
            if (series == null) {
                series = new PacketSeries(color);
                dlDatasets.put(color, series);
            }
            series.add(new PacketDataItem(thisSession, packet));
        } else if (!isDownloadPacket() && packet.getDir() == PacketDirection.UPLINK) {
            // Add the packet to the proper series based on color

            Color color = filter.getPacketColor(packet);
            PacketSeries series = dlDatasets.get(color);
            if (series == null) {
                series = new PacketSeries(color);
                dlDatasets.put(color, series);
            }
            series.add(new PacketDataItem(thisSession, packet));
        } else {
            continue;
        }
    }
}

From source file:com.itemanalysis.psychometrics.measurement.TestSummary.java

public TestSummary(int numberOfItems, int numberOfSubscales, int[] cutScores,
        LinkedHashMap<VariableName, VariableAttributes> variableAttributeMap, boolean unbiased,
        boolean deletedReliability, boolean showCsem) {

    this.variableAttributes = new ArrayList<VariableAttributes>();
    for (VariableName v : variableAttributeMap.keySet()) {
        this.variableAttributes.add(variableAttributeMap.get(v));
    }/*from  ww w . java  2 s.  co m*/

    this.unbiased = unbiased;
    this.numberOfItems = numberOfItems;
    this.cutScores = cutScores;
    this.deletedReliability = deletedReliability;
    this.showCsem = showCsem;
    stats = new DescriptiveStatistics();
    stdDev = new StandardDeviation(unbiased);
    relMatrix = new CovarianceMatrix(variableAttributes);
    this.numberOfSubscales = numberOfSubscales;
    if (numberOfSubscales > 1)
        partRelMatrix = new CovarianceMatrix(numberOfSubscales);

}

From source file:com.okta.tools.awscli.java

private static String oktaAuthentication() throws ClientProtocolException, JSONException, IOException {

    String strSessionToken = "";
    AuthResult authResult = null;//from w w w. j a  v a2 s . c om

    int requestStatus = 0;
    String strAuthStatus = "";

    //Redo sequence if response from AWS doesn't return 200 Status
    while (!strAuthStatus.equalsIgnoreCase("SUCCESS") && !strAuthStatus.equalsIgnoreCase("MFA_REQUIRED")) {

        // Prompt for user credentials
        System.out.print("Username: ");
        //Scanner scanner = new Scanner(System.in);

        String oktaUsername = null; //scanner.next();

        Console console = System.console();
        String oktaPassword = null;
        if (console != null) {
            oktaPassword = new String(console.readPassword("Password: "));
        } else { // hack to be able to debug in an IDE
            System.out.print("Password: ");
        }
        try {
            authResult = authenticateCredentials(oktaUsername, oktaPassword);
            strAuthStatus = authResult.getStatus();

            if (strAuthStatus.equalsIgnoreCase("MFA_REQUIRED")) {
                if (userClient != null) {
                    LinkedHashMap<String, Object> user = (LinkedHashMap<String, Object>) (authResult
                            .getEmbedded().get("user"));
                    userId = (String) user.get("id");

                    //userId = user.getId();
                    /*User user = userClient.getUser(oktaUsername);
                    if(user!=null)
                        userId = user.getId();*/
                }
            }

        } catch (ApiException apiException) {
            String strEx = apiException.getMessage();

            switch (apiException.getStatusCode()) {
            case 400:
            case 401:
                System.out.println("You provided invalid credentials, please try again.");
                break;
            case 500:
                System.out.println("\nUnable to establish connection with: " + oktaOrg
                        + " \nPlease verify that your Okta org url is correct and try again");
                System.exit(0);
                break;
            default:
                throw new RuntimeException("Failed : HTTP error code : " + apiException.getStatusCode()
                        + " Error code: " + apiException.getErrorResponse().getErrorCode() + " Error summary: "
                        + apiException.getErrorResponse().getErrorSummary());

            }
        }
        //requestStatus = responseAuthenticate.getStatusLine().getStatusCode();
        //authnFailHandler(requestStatus, responseAuthenticate);
    }

    //Retrieve and parse the Okta response for session token
    /*BufferedReader br = new BufferedReader(new InputStreamReader(
            (responseAuthenticate.getEntity().getContent())));
            
    String outputAuthenticate = br.readLine();
    JSONObject jsonObjResponse = new JSONObject(outputAuthenticate);
            
    responseAuthenticate.close();*/

    if (strAuthStatus.equalsIgnoreCase("MFA_REQUIRED")) {
        return mfa(authResult);
    }
    //else {
    //    return jsonObjResponse.getString("sessionToken");
    //}

    if (authResult != null)
        strSessionToken = authResult.getSessionToken();
    return strSessionToken;
}