Example usage for java.util TreeMap TreeMap

List of usage examples for java.util TreeMap TreeMap

Introduction

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

Prototype

public TreeMap(SortedMap<K, ? extends V> m) 

Source Link

Document

Constructs a new tree map containing the same mappings and using the same ordering as the specified sorted map.

Usage

From source file:com.espertech.esper.filter.FilterParamIndexStringRangeBase.java

protected FilterParamIndexStringRangeBase(FilterSpecLookupable lookupable, FilterOperator filterOperator) {
    super(filterOperator, lookupable);

    ranges = new TreeMap<StringRange, EventEvaluator>(new StringRangeComparator());
    rangesNullEndpoints = new IdentityHashMap<StringRange, EventEvaluator>();
    rangesRWLock = new ReentrantReadWriteLock();
}

From source file:org.springframework.analytics.rest.domain.FieldValueCounterResource.java

@JsonProperty
public void setValues(Map<String, Double> values) {
    this.values = new TreeMap<>(new ByDecreasingValueComparator(values));
    this.values.putAll(values);
}

From source file:forge.util.FileSection.java

/**
 * Instantiates a new file section./*from  w  w  w . j a v a2s .  co  m*/
 */
protected FileSection() {
    this(new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER));
}

From source file:com.mothsoft.alexis.web.security.OutboundRestAuthenticationInterceptor.java

@Override
public void handleMessage(Message message) {

    if (!CurrentUserUtil.isAuthenticated()) {
        throw new AuthenticationCredentialsNotFoundException("Unauthenticated user!");
    }/*from   w  w w.  java  2  s . c o  m*/

    @SuppressWarnings("unchecked")
    Map<String, List<String>> headers = (Map<String, List<String>>) message.get(Message.PROTOCOL_HEADERS);
    if (headers == null) {
        headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
        message.put(Message.PROTOCOL_HEADERS, headers);
    }

    final List<String> header = new ArrayList<String>();

    final String username = CurrentUserUtil.getCurrentUser().getUsername();
    final String apiToken = CurrentUserUtil.getCurrentUser().getApiToken();
    final String usernameToken = String.format("%s:%s", username, apiToken);
    try {
        header.add(String.format("Basic %s", new String(Base64.encodeBase64(usernameToken.getBytes("UTF-8")))));
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }

    headers.put("Authorization", header);
}

From source file:com.opengamma.financial.analytics.cashflow.FixedPaymentMatrix.java

public FixedPaymentMatrix(final Map<LocalDate, MultipleCurrencyAmount> values, final int maxCurrencyAmounts) {
    ArgumentChecker.notNull(values, "values");
    ArgumentChecker.notNegative(maxCurrencyAmounts, "max currency amounts");
    _values = new TreeMap<LocalDate, MultipleCurrencyAmount>(values);
    _maxCurrencyAmounts = maxCurrencyAmounts;
}

From source file:com.zotoh.cloudapi.core.CloudAPI.java

protected static Collection<VirtualMachineProduct> sort(Collection<VirtualMachineProduct> cs) {
    Map<VirtualMachineProduct, VirtualMachineProduct> m = new TreeMap<VirtualMachineProduct, VirtualMachineProduct>(
            new AAA());
    for (VirtualMachineProduct p : cs) {
        m.put(p, p);//from   w  ww .  j  av a 2s  .co  m
    }
    return m.values();
}

From source file:com.opengamma.financial.analytics.cashflow.FloatingPaymentMatrix.java

public FloatingPaymentMatrix(final Map<LocalDate, List<Pair<CurrencyAmount, String>>> values,
        final int maxEntries) {
    ArgumentChecker.notNull(values, "values");
    ArgumentChecker.notNegative(maxEntries, "max entries");
    _values = new TreeMap<LocalDate, List<Pair<CurrencyAmount, String>>>(values);
    _maxEntries = maxEntries;/*from  w  w  w .  j a  v a 2  s. c om*/
}

From source file:org.openmrs.module.rwandaprimarycare.AllEncountersController.java

@RequestMapping("/module/rwandaprimarycare/allEncounters")
public String listAllEncounters(@RequestParam("patientId") int patientId, ModelMap model)
        throws PrimaryCareException {

    //LK: Need to ensure that all primary care methods only throw a PrimaryCareException
    //So that errors will be directed to a touch screen error page
    try {/*from  w w w.  j a  v a  2s  .c  o  m*/
        Patient patient = Context.getPatientService().getPatient(patientId);
        SortedMap<Date, List<Encounter>> encounters = new TreeMap<Date, List<Encounter>>(
                Collections.reverseOrder());
        for (Encounter e : Context.getEncounterService().getEncountersByPatient(patient)) {
            Calendar cal = Calendar.getInstance();
            cal.setTime(e.getEncounterDatetime());
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);
            cal.set(Calendar.MILLISECOND, 0);
            Date day = cal.getTime();
            List<Encounter> holder = encounters.get(day);
            if (holder == null) {
                holder = new ArrayList<Encounter>();
                encounters.put(day, holder);
            }
            holder.add(e);
        }
        model.addAttribute("patient", patient);
        model.addAttribute("encounters", encounters);
        model.addAttribute("vitalsEncounterType", PrimaryCareBusinessLogic.getVitalsEncounterType());
        model.addAttribute("registrationEncounterType",
                PrimaryCareBusinessLogic.getRegistrationEncounterType());
    } catch (Exception e) {
        throw new PrimaryCareException(e);
    }
    return "/module/rwandaprimarycare/allEncounters";
}

From source file:cn.tata.t2s.ssm.util.AcmeCorpPhysicalNamingStrategy.java

private static Map<String, String> buildAbbreviationMap() {
    TreeMap<String, String> abbreviationMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    abbreviationMap.put("account", "acct");
    abbreviationMap.put("number", "num");
    return abbreviationMap;
}

From source file:com.erinors.hpb.server.handler.SortedMapHandler.java

@Override
public Object clone(CloningContext context, Object object) {
    if (!(object instanceof SortedMap)) {
        return null;
    }// www . j av a  2s .c om

    SortedMap<Object, Object> source = (SortedMap<Object, Object>) object;
    SortedMap<Object, Object> result;

    if (source instanceof PersistentSortedMap && !((PersistentSortedMap) source).wasInitialized()) {
        result = new UninitializedPersistentSortedMap<Object, Object>(source.comparator());
        context.addProcessedObject(object, result);
    } else {
        SortedMap<Object, Object> map = new TreeMap<Object, Object>(source.comparator());
        context.addProcessedObject(object, map);

        for (Map.Entry<?, ?> entry : source.entrySet()) {
            map.put(context.clone(entry.getKey()), context.clone(entry.getValue()));
        }

        result = map;
    }

    return result;
}