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() 

Source Link

Document

Constructs a new, empty tree map, using the natural ordering of its keys.

Usage

From source file:com.rizki.mufrizal.belajar.spring.data.mongodb.service.impl.CategoryServiceImpl.java

@Override
public TreeMap<String, Object> getCategories(Pageable pageable) {
    Page<Category> categories = categoryRepository.findAll(pageable);

    List<Category> categorys = new ArrayList<>();

    for (Category category : categories) {
        category.setDepartment(departmentRepository.findOne(category.getDepartmentId()));
        categorys.add(category);//w w w .j a  va 2s  .c  o m
    }

    TreeMap<String, Object> map = new TreeMap<>();
    map.put("content", categorys);
    map.put("last", categories.isLast());
    map.put("totalPages", categories.getTotalPages());
    map.put("totalElements", categories.getTotalElements());
    map.put("size", categories.getSize());
    map.put("number", categories.getNumber());
    map.put("sort", categories.getSort());
    map.put("first", categories.isFirst());
    map.put("numberOfElements", categories.getNumberOfElements());

    return map;
}

From source file:com.vrem.wifianalyzer.wifi.graphutils.SeriesCache.java

SeriesCache() {
    this.cache = new TreeMap<>();
}

From source file:net.meltdowntech.steamstats.SteamUser.java

private SteamUser() {
    values = new TreeMap<>();
    games = new ArrayList<>();
}

From source file:io.druid.benchmark.datagen.EnumeratedTreeDistribution.java

public EnumeratedTreeDistribution(final List<Pair<T, Double>> pmf) {
    super(pmf);/*from w w  w .ja  va 2s  .c  om*/

    // build the interval tree
    probabilityRanges = new TreeMap<Double, Integer>();
    normalizedPmf = this.getPmf();
    double cumulativep = 0.0;
    for (int i = 0; i < normalizedPmf.size(); i++) {
        probabilityRanges.put(cumulativep, i);
        Pair<T, Double> pair = normalizedPmf.get(i);
        cumulativep += pair.getSecond();
    }
}

From source file:com.spectralogic.ds3cli.views.json.CommandExceptionJsonView.java

@Override
public String render(final CommandException obj) throws JsonProcessingException {
    final CommonJsonView view = CommonJsonView.newView(CommonJsonView.Status.ERROR);
    final Map<String, String> jsonBackingMap = new TreeMap<>();

    view.message(obj.getMessage());/*from   w  ww. ja  v  a  2 s  . com*/

    try {
        final ObjectMapper mapper = new ObjectMapper();
        if (obj.getCause() != null) {
            if (obj.getCause() instanceof FailedRequestException) {
                final FailedRequestException ce = (FailedRequestException) obj.getCause();
                jsonBackingMap.put("StatusCode", Integer.toString(ce.getStatusCode()));
                jsonBackingMap.put("ApiErrorMessage", ce.getResponseString());
            } else {
                final ByteArrayOutputStream out = new ByteArrayOutputStream();
                final PrintWriter pOut = new PrintWriter(out);
                obj.printStackTrace(pOut);
                try {
                    jsonBackingMap.put("StackTrace", out.toString("utf-8"));
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
        }

        return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(view.data(jsonBackingMap));
    } catch (final Exception e) {
        return "Failed to render error: " + e.getMessage();
    }
}

From source file:in.huohua.peterson.network.HttpRequest.java

public HttpRequest(final String url, final String httpMethod) {
    this(url, httpMethod, new TreeMap<String, String>());
}

From source file:org.dspace.orm.dao.database.MetadataValueDao.java

private MetadataSchemaRegistry getSchema(String schema) {
    if (schemas == null)
        schemas = new TreeMap<String, MetadataSchemaRegistry>();

    if (!schemas.containsKey(schema)) {
        schemas.put(schema, schemaRegistry.selectByName(schema));
    }/*from   www  .j av a2  s  .  c o m*/

    return schemas.get(schema);
}

From source file:gov.nih.nci.cabig.ctms.web.WebTools.java

public static SortedMap<String, Object> requestPropertiesToMap(HttpServletRequest request) {
    BeanWrapper wrapped = new BeanWrapperImpl(request);
    SortedMap<String, Object> map = new TreeMap<String, Object>();
    for (PropertyDescriptor descriptor : wrapped.getPropertyDescriptors()) {
        String name = descriptor.getName();
        if (!EXCLUDED_REQUEST_PROPERTIES.contains(name) && descriptor.getReadMethod() != null) {
            Object propertyValue;
            try {
                propertyValue = wrapped.getPropertyValue(name);
            } catch (InvalidPropertyException e) {
                log.debug("Exception reading request property " + name, e);
                propertyValue = e.getMostSpecificCause();
            }//from   w w  w. j a  va 2 s  .  c  om
            map.put(name, propertyValue);
        }
    }
    return map;
}

From source file:it.osm.gtfs.input.OSMParser.java

public static Map<String, Stop> applyOSMIndex(List<Stop> stops)
        throws ParserConfigurationException, SAXException, IOException {
    final Map<String, Stop> result = new TreeMap<String, Stop>();

    for (Stop s : stops) {
        if (s.getOSMId() != null) {
            result.put(s.getOSMId(), s);
        }/*from ww w  .  j  av  a2 s .c  o m*/
    }

    return result;
}

From source file:monasca.log.api.app.LogSerializerTest.java

public void shouldSerializeValue() throws JSONException {
    String applicationType = "apache";
    SortedMap<String, String> dimensions = new TreeMap<String, String>();
    dimensions.put("app_name", "WebService01");
    dimensions.put("environment", "production");
    String message = "Hello, world!";

    final Log log = new Log(applicationType, dimensions, message);
    final String json = this.serializer.toJson(log);
    final String expected = "{\"application_type\":\"apache\",\"dimensions\":{\"app_name\":\"WebService01\",\"environment\":\"production\"},"
            + "\"message\":\"Hello, world!\"}";

    JSONAssert.assertEquals(expected, json, true);
}