Example usage for java.util TreeMap put

List of usage examples for java.util TreeMap put

Introduction

In this page you can find the example usage for java.util TreeMap put.

Prototype

public V put(K key, V value) 

Source Link

Document

Associates the specified value with the specified key in this map.

Usage

From source file:com.cyclopsgroup.tornado.ui.view.user.UserProfile.java

/**
 * Override method execute in class UserProfile
 *
 * @see com.cyclopsgroup.waterview.Module#execute(com.cyclopsgroup.waterview.RuntimeData, com.cyclopsgroup.waterview.Context)
 *//*from w  ww. j ava 2s  .  co  m*/
public void execute(RuntimeData data, Context context) throws Exception {
    RuntimeUser user = RuntimeUser.getInstance(data);
    PersistenceManager persist = (PersistenceManager) lookup(PersistenceManager.ROLE);
    User u = (User) persist.load(User.class, user.getId());
    context.put("userObject", u);

    TreeMap languages = new TreeMap();
    TreeMap countries = new TreeMap();
    Locale[] availableLocales = Locale.getAvailableLocales();
    for (int i = 0; i < availableLocales.length; i++) {
        Locale locale = availableLocales[i];
        DefaultSelectOption lang = new DefaultSelectOption(locale.getLanguage(),
                locale.getDisplayLanguage(data.getLocale()) + '(' + locale.getLanguage() + ')');
        languages.put(locale.getLanguage(), lang);

        if (StringUtils.isNotEmpty(locale.getCountry())) {
            DefaultSelectOption cout = new DefaultSelectOption(locale.getCountry(),
                    locale.getDisplayCountry(data.getLocale()) + '(' + locale.getCountry() + ')');
            countries.put(locale.getCountry(), cout);
        }
    }
    context.put("countries", countries.values());
    context.put("languages", languages.values());
}

From source file:com.opengamma.analytics.financial.interestrate.CashFlowEquivalentCalculator.java

@Override
public AnnuityPaymentFixed visitBondFixedSecurity(final BondFixedSecurity bond, final YieldCurveBundle curves) {
    Validate.notNull(curves);/*  w  ww  . j  a  v  a  2 s  . co  m*/
    Validate.notNull(bond);
    Currency ccy = bond.getCurrency();
    TreeMap<Double, Double> flow = new TreeMap<Double, Double>();
    AnnuityPaymentFixed cfeNom = visit(bond.getNominal(), curves);
    AnnuityPaymentFixed cfeCpn = visit(bond.getCoupon(), curves);
    for (final PaymentFixed p : cfeNom.getPayments()) {
        flow.put(p.getPaymentTime(), p.getAmount());
    }
    for (final PaymentFixed p : cfeCpn.getPayments()) {
        addcf(flow, p.getPaymentTime(), p.getAmount());
    }
    PaymentFixed[] agregatedCfe = new PaymentFixed[flow.size()];
    int loopcf = 0;
    for (double time : flow.keySet()) {
        agregatedCfe[loopcf++] = new PaymentFixed(ccy, time, flow.get(time), cfeCpn.getDiscountCurve());
    }
    return new AnnuityPaymentFixed(agregatedCfe);

}

From source file:com.opengamma.analytics.financial.provider.calculator.discounting.CashFlowEquivalentCalculator.java

@Override
public AnnuityPaymentFixed visitBondFixedSecurity(final BondFixedSecurity bond,
        final MulticurveProviderInterface multicurves) {
    ArgumentChecker.notNull(bond, "Bond");
    ArgumentChecker.notNull(multicurves, "Multicurves provider");
    final Currency ccy = bond.getCurrency();
    final TreeMap<Double, Double> flow = new TreeMap<>();
    final AnnuityPaymentFixed cfeNom = bond.getNominal().accept(this, multicurves);
    final AnnuityPaymentFixed cfeCpn = bond.getCoupon().accept(this, multicurves);
    for (final PaymentFixed p : cfeNom.getPayments()) {
        flow.put(p.getPaymentTime(), p.getAmount());
    }//from   w w  w. j a v a  2s .c om
    for (final PaymentFixed p : cfeCpn.getPayments()) {
        addcf(flow, p.getPaymentTime(), p.getAmount());
    }
    final PaymentFixed[] agregatedCfe = new PaymentFixed[flow.size()];
    int loopcf = 0;
    for (final double time : flow.keySet()) {
        agregatedCfe[loopcf++] = new PaymentFixed(ccy, time, flow.get(time));
    }
    return new AnnuityPaymentFixed(agregatedCfe);

}

From source file:com.opengamma.analytics.financial.interestrate.CashFlowEquivalentCalculator.java

@Override
public AnnuityPaymentFixed visitSwap(final Swap<?, ?> swap, final YieldCurveBundle curves) {
    Validate.notNull(curves);//from  w  w w.  j ava2  s . com
    Validate.notNull(swap);
    Currency ccy = swap.getFirstLeg().getCurrency();
    Validate.isTrue(ccy.equals(swap.getSecondLeg().getCurrency()),
            "Cash flow equivalent available only for single currency swaps.");
    TreeMap<Double, Double> flow = new TreeMap<Double, Double>();
    AnnuityPaymentFixed cfeLeg1 = visit(swap.getFirstLeg(), curves);
    AnnuityPaymentFixed cfeLeg2 = visit(swap.getSecondLeg(), curves);
    for (final PaymentFixed p : cfeLeg1.getPayments()) {
        flow.put(p.getPaymentTime(), p.getAmount());
    }
    for (final PaymentFixed p : cfeLeg2.getPayments()) {
        addcf(flow, p.getPaymentTime(), p.getAmount());
    }
    PaymentFixed[] agregatedCfe = new PaymentFixed[flow.size()];
    int loopcf = 0;
    for (double time : flow.keySet()) {
        agregatedCfe[loopcf++] = new PaymentFixed(ccy, time, flow.get(time), cfeLeg1.getDiscountCurve());
    }
    return new AnnuityPaymentFixed(agregatedCfe);
}

From source file:controllers.Send.java

public static Result create() {
    String token = UUID.randomUUID().toString();
    SessionHelper.putToken(token);//from w  w  w .ja v  a 2 s  .c  om
    Logger.debug("Tracking ID : " + token);

    Form<models.forms.CashInForm> transactionForm = form(models.forms.CashInForm.class)
            .bindFromRequest(request());
    Logger.debug("Send create request : " + transactionForm.data());
    if (transactionForm.data().isEmpty()) {
        CashInForm fillForm = new CashInForm();
        fillForm.senderCountry = SessionHelper.getUser().corporate.country;
        fillForm.senderCurrency = SessionHelper.getUser().corporate.currency;
        transactionForm = transactionForm.fill(fillForm);
    }

    models.Corporate corporate = SessionHelper.getUser().corporate;
    corporate.refresh();
    CorporateStatistic cs = corporate.getStatistic();
    if (cs.hasExceedCreditLimit()) {
        flash("error", "YOUR CREDIT LEFT HAS REACH ITS LIMIT, PLEASE CONTACT YOUR FINANCE FOR SETTLEMENT.");
    } else if (cs.hasExceedCreditAlertLimit()) {
        flash("warning", "YOUR CREDIT LEFT HAS REACH ALERT LIMIT, PLEASE CONTACT YOUR FINANCE FOR SETTLEMENT.");
    }

    String channelCode = "";

    transactionForm.get().trackingId = token;

    TreeMap<String, String> mapChannel = new TreeMap<String, String>();
    try {
        channelCode = corporate.configuration.channelCode;

        if (channelCode != null && !channelCode.trim().equals("")) {
            Object[] channel = channelCode.split(";");
            List<Channel> channels = null;
            channels = Channel.find.where().in("code", channel).orderBy("code").findList();
            for (Iterator<Channel> iterator = channels.iterator(); iterator.hasNext();) {
                Channel channelItem = (Channel) iterator.next();
                if (!channelItem.code.equals("10"))
                    mapChannel.put(channelItem.code, channelItem.name);
            }
        }
    } catch (Exception e) {
        channelCode = "empty";
    }

    if (channelCode == null || channelCode == "")
        channelCode = "empty";
    return ok(create.render(transactionForm, channelCode, mapChannel));
}

From source file:hydrograph.ui.engine.ui.converter.impl.InputTeradataUiConverter.java

@Override
protected Map<String, String> getRuntimeProperties() {
    LOGGER.debug("Generating Runtime Properties for -{}", componentName);
    TreeMap<String, String> runtimeMap = null;
    TypeProperties typeProperties = ((Teradata) typeBaseComponent).getRuntimeProperties();
    if (typeProperties != null) {
        runtimeMap = new TreeMap<>();
        for (Property runtimeProperty : typeProperties.getProperty()) {
            runtimeMap.put(runtimeProperty.getName(), runtimeProperty.getValue());
        }/*from   w w  w.  j  ava2 s . c  o m*/
    }
    return runtimeMap;
}

From source file:com.earnstone.index.ShardedIndex.java

public boolean initializeShardBoundries(List<T> startingBoundries) {

    if (shards.size() == 0) {
        TreeMap<T, T> map = new TreeMap<T, T>();

        for (T value : startingBoundries) {
            map.put(value, value);
        }//from  w  ww.  j a v a2s  .co  m

        saveShardsCache(map);
        shards = map;
        return true;
    } else {
        return false;
    }
}

From source file:controllers.Send.java

public static Result createBillPayment() {
    String token = UUID.randomUUID().toString();
    SessionHelper.putToken(token);//ww w .ja v  a2  s .c  o  m
    Logger.debug("Tracking ID : " + token);

    Form<models.forms.CashInForm> transactionForm = form(models.forms.CashInForm.class)
            .bindFromRequest(request());
    Logger.debug("Send create bill payment request : " + transactionForm.data());
    if (transactionForm.data().isEmpty()) {
        CashInForm fillForm = new CashInForm();
        fillForm.senderCountry = SessionHelper.getUser().corporate.country;
        fillForm.senderCurrency = SessionHelper.getUser().corporate.currency;
        transactionForm = transactionForm.fill(fillForm);
    }

    models.Corporate corporate = SessionHelper.getUser().corporate;
    corporate.refresh();
    CorporateStatistic cs = corporate.getStatistic();
    if (cs.hasExceedCreditLimit()) {
        flash("error", "YOUR CREDIT LEFT HAS REACH ITS LIMIT, PLEASE CONTACT YOUR FINANCE FOR SETTLEMENT.");
    } else if (cs.hasExceedCreditAlertLimit()) {
        flash("warning", "YOUR CREDIT LEFT HAS REACH ALERT LIMIT, PLEASE CONTACT YOUR FINANCE FOR SETTLEMENT.");
    }

    transactionForm.get().trackingId = token;
    String channelCode = "";

    TreeMap<String, String> mapChannel = new TreeMap<String, String>();
    try {
        channelCode = corporate.configuration.channelCode;

        if (channelCode != null && !channelCode.trim().equals("")) {
            Object[] channel = channelCode.split(";");
            List<Channel> channels = null;
            channels = Channel.find.where().in("code", channel).orderBy("code").findList();
            for (Iterator<Channel> iterator = channels.iterator(); iterator.hasNext();) {
                Channel channelItem = (Channel) iterator.next();
                if (channelItem.code.equals("10")) {
                    mapChannel.put(channelItem.code, channelItem.name);
                    transactionForm.get().channel = channelItem;
                }
            }
        }
    } catch (Exception e) {
        channelCode = "empty";
    }

    if (channelCode == null || channelCode == "")
        channelCode = "empty";
    return ok(create_bill_payment.render(transactionForm, channelCode, mapChannel));
}

From source file:com.michellemay.mappings.LanguageTagsMapping.java

/**
 * Instantiates a new Language tags mapping.
 *//*from  w  w w.  j  a v  a  2 s  . c om*/
public LanguageTagsMapping() {
    super(NAME);
    this.withCaseSensitive(false);

    // Build reverse map.  Use a tree map to offer case insensitiveness while preserving keys case (useful for extending)
    TreeMap<String, Locale> map = new TreeMap<String, Locale>(
            this.getCaseSensitive() ? null : String.CASE_INSENSITIVE_ORDER);
    for (Locale loc : LocaleUtils.availableLocaleList()) {
        String isoCode = loc.getLanguage();
        if (isoCode.length() > 0) {
            String displayValue = loc.toLanguageTag();
            if (!map.containsKey(displayValue)) {
                // Also add variant with underscores
                map.put(displayValue, loc);
                map.put(displayValue.replace('-', '_'), loc);
            }
        }
    }
    this.withMapping(map);
}

From source file:com.opengamma.analytics.financial.provider.calculator.discounting.CashFlowEquivalentCalculator.java

@Override
public AnnuityPaymentFixed visitSwap(final Swap<?, ?> swap, final MulticurveProviderInterface multicurves) {
    ArgumentChecker.notNull(swap, "Swap");
    ArgumentChecker.notNull(multicurves, "Multicurves provider");
    final Currency ccy = swap.getFirstLeg().getCurrency();
    Validate.isTrue(ccy.equals(swap.getSecondLeg().getCurrency()),
            "Cash flow equivalent available only for single currency swaps.");
    final TreeMap<Double, Double> flow = new TreeMap<>();
    final AnnuityPaymentFixed cfeLeg1 = swap.getFirstLeg().accept(this, multicurves);
    final AnnuityPaymentFixed cfeLeg2 = swap.getSecondLeg().accept(this, multicurves);
    for (final PaymentFixed p : cfeLeg1.getPayments()) {
        flow.put(p.getPaymentTime(), p.getAmount());
    }/*w ww.j a v  a2s.  c o m*/
    for (final PaymentFixed p : cfeLeg2.getPayments()) {
        addcf(flow, p.getPaymentTime(), p.getAmount());
    }
    final PaymentFixed[] agregatedCfe = new PaymentFixed[flow.size()];
    int loopcf = 0;
    for (final double time : flow.keySet()) {
        agregatedCfe[loopcf++] = new PaymentFixed(ccy, time, flow.get(time));
    }
    return new AnnuityPaymentFixed(agregatedCfe);
}