List of usage examples for java.util TreeMap TreeMap
public TreeMap()
From source file:com.titankingdoms.dev.titanchat.addon.AddonManager.java
public AddonManager() { this.plugin = TitanChat.getInstance(); if (getAddonDirectory().mkdirs()) plugin.log(Level.INFO, "Creating addon directory..."); this.addons = new TreeMap<String, ChatAddon>(); }
From source file:uk.ac.ebi.eva.pipeline.io.mappers.GeneLineMapper.java
@Override public FeatureCoordinates mapLine(String line, int lineNumber) throws Exception { String[] lineSplit = line.split("\t"); String[] attributesSplit = lineSplit[8].split(";"); Map<String, String> attributes = new TreeMap<>(); for (String attribute : attributesSplit) { String[] keyValue = attribute.split(" "); // don't do a `put(keyValue[0], keyValue[1])`: a space may appear before the key // also, remove quotes from the value int valueLength = keyValue[keyValue.length - 1].length(); attributes.put(keyValue[keyValue.length - 2], keyValue[keyValue.length - 1].substring(1, valueLength - 1)); }/* w ww . j a v a2 s .co m*/ String feature = lineSplit[2]; return new FeatureCoordinates(attributes.get(feature + "_id"), attributes.get(feature + "_name"), feature, lineSplit[0], Integer.parseInt(lineSplit[3]), Integer.parseInt(lineSplit[4])); }
From source file:com.itemanalysis.psychometrics.scaling.NormalizedScore.java
/** * Creates a TreeMap<Integer, Double> lookup table of normalized scores. * The key is a raw score level and the rho is a normalized score. This * method is useful when finding normalized scores that correspond to an examinee's * raw score. After calling this method, individual elements in the * TreeMap can be accessed with getNormalizedScoreAt(int rho) or * valueIterator()./*from w ww. j a v a2s. com*/ * */ public void createLookupTable(PercentileRank prank, LinearTransformation linear) { this.prank = prank; NormalDistribution normal = new NormalDistribution(); normScoreTable = new TreeMap<Integer, Double>(); prank.createLookupTable(); Iterator<Integer> iter = prank.valueIterator(); double p = 0.0; double q = 0.0; Integer i = null; while (iter.hasNext()) { i = iter.next(); p = prank.getPercentileRankAt(i) / 100.0; q = normal.inverseCumulativeProbability(p); normScoreTable.put(i, linear.transform(q)); } }
From source file:com.nec.nsgui.model.biz.cifs.NSBeanUtil.java
/** * The bean members' type is limited to String and String[] *//*from w w w .ja v a 2 s . com*/ public static void setProperties(Object bean, String[] valueArray, String delimiter) throws Exception { if (bean == null || valueArray == null || valueArray.length == 0) { return; } Map map = new TreeMap(); for (int i = 0; i < valueArray.length; i++) { String keyAndValue = valueArray[i]; if (keyAndValue == null || keyAndValue.indexOf(KEY_VALUE_SPLITER) == -1) { continue; } else { String[] tmpArray = valueArray[i].split(KEY_VALUE_SPLITER, 2); String key = tmpArray[0].trim(); if (delimiter != null) { PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(bean, key); Class propertyType = descriptor.getPropertyType(); if (propertyType.isArray()) { String[] values = tmpArray[1].split(delimiter); map.put(key, values); continue; } } String value = tmpArray[1]; map.put(key, value); } } if (map.size() > 0) { BeanUtils.populate(bean, map); } return; }
From source file:com.cloudera.sqoop.io.LobReaderCache.java
private LobReaderCache() { this.readerMap = new TreeMap<Path, LobFile.Reader>(); }
From source file:com.jsonstore.database.DatabaseSchema.java
public DatabaseSchema(String name) { this.name = name; this.nodes = new TreeMap<String, SearchFieldType>(); this.safeNodes = new TreeMap<String, SearchFieldType>(); this.internalNodes = new TreeMap<String, SearchFieldType>(); // Add in nodes that are implicitly part of any schema. try {/* w w w. ja v a 2s .c om*/ internalNodes.put(DatabaseConstants.FIELD_DELETED, SearchFieldType.BOOLEAN); internalNodes.put(DatabaseConstants.FIELD_DIRTY, SearchFieldType.NUMBER); internalNodes.put(DatabaseConstants.FIELD_ID, SearchFieldType.INTEGER); internalNodes.put(DatabaseConstants.FIELD_JSON, SearchFieldType.STRING); internalNodes.put(DatabaseConstants.FIELD_OPERATION, SearchFieldType.STRING); } catch (Throwable e) { // Ignore, since this can't happen. } }
From source file:com.haulmont.timesheets.core.HolidaysCache.java
private String doLoadCache(boolean lockReadBeforeFinish) { try {//from w w w.ja v a 2s .c o m lock.writeLock().lock(); cache = new TreeMap<>(); LoadContext<Holiday> loadContext = new LoadContext<>(Holiday.class); loadContext .setQueryString("select e from ts$Holiday e " + "where (e.startDate between :start and :end) or (e.endDate between :start and :end)") .setParameter("start", DateUtils.addYears(timeSource.currentTimestamp(), -1)) .setParameter("end", DateUtils.addYears(timeSource.currentTimestamp(), 1)); List<Holiday> holidays = dataManager.loadList(loadContext); for (Holiday holiday : holidays) { Date startDate = holiday.getStartDate(); Date endDate = holiday.getEndDate(); Date currentDate = startDate; while (currentDate.before(endDate)) { cache.put(currentDate, holiday); currentDate = DateUtils.addDays(currentDate, 1); } } if (lockReadBeforeFinish) { lock.readLock().lock(); } return "Successfully loaded"; } finally { lock.writeLock().unlock(); } }
From source file:forge.util.storage.StorageReaderFileSections.java
protected Map<String, T> createMap() { return new TreeMap<String, T>(); }
From source file:com.netflix.adminresources.resources.PropertiesResource.java
/** * List all properties/* w w w.ja v a 2 s .c o m*/ @GET public Viewable showIndex() { Map<String, Object> model = new HashMap<String, Object>(); return new Viewable("/webadmin/props/index.ftl", model); } */ @GET public Response getAllProperties() { Map<String, String> allPropsAsString = new TreeMap<String, String>(); AbstractConfiguration config = ConfigurationManager.getConfigInstance(); Iterator<String> keys = config.getKeys(); Set<String> maskedResources = MaskedResourceHelper.getMaskedResourceSet(); while (keys.hasNext()) { final String key = keys.next(); // mask the specified properties final Object value; if (maskedResources.contains(key)) { value = MaskedResourceHelper.MASKED_PROPERTY_VALUE; } else { value = config.getProperty(key); } if (null != value) { allPropsAsString.put(key, value.toString()); } } GsonBuilder gsonBuilder = new GsonBuilder().serializeNulls(); Gson gson = gsonBuilder.create(); String propsJson = gson.toJson(new PairResponse(allPropsAsString)); return Response.ok(propsJson).build(); }
From source file:com.bluexml.xforms.controller.navigation.NavigationSessionListener.java
/** * Gets the navigation path from session. * /*ww w . j a v a 2s. c o m*/ * @param sessionId * the session id * * @return the navigation path from session */ private static Map<String, NavigationPath> getNavigationPathFromSession(String sessionId) { Map<String, NavigationPath> result = navigations.get(sessionId); if (result == null) { result = new TreeMap<String, NavigationPath>(); navigations.put(sessionId, result); } return result; }