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.icesoft.applications.faces.address.MatchAddressDB.java

/**
 * Finds the closest cities to the provided city.
 *
 * @param checkCity the city to check/*ww w.  ja v a 2 s .  com*/
 * @return list of cities
 */
public ArrayList getClosestCity(String checkCity) {

    String myCheckCity = AddressFormProcessor.fixCapitalization(checkCity);
    ArrayList cities = getCity(myCheckCity);

    if (cities != null) {
        //at least one exact match, so exit
        return cities;
    }

    //get closest city in each state
    Iterator itor = stateMap.values().iterator();
    TreeMap closest = new TreeMap();
    MatchCity city;

    while (itor.hasNext()) {
        MatchState state = (MatchState) itor.next();
        city = state.getClosestCity(myCheckCity);
        closest.put((city.getCity()), city);
    }

    //get closest of the closest cities
    city = (MatchCity) getClosestMatch(myCheckCity, closest);

    //must return all cities with this name
    cities = getCity(city.getCity());
    itor = cities.iterator();

    while (itor.hasNext()) {
        ((MatchCity) itor.next()).setMatch(false);
    }
    return cities;
}

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

@Override
protected Map<String, String> getRuntimeProperties() {
    LOGGER.debug("Fetching runtime properties for -", componentName);
    TreeMap<String, String> runtimeMap = null;
    TypeProperties typeProperties = ((Redshift) typeBaseComponent).getRuntimeProperties();
    if (typeProperties != null) {
        runtimeMap = new TreeMap<>();
        for (Property runtimeProperty : typeProperties.getProperty()) {
            runtimeMap.put(runtimeProperty.getName(), runtimeProperty.getValue());
        }//from  w  w w  .j  a va 2 s  . c  o m
    }
    return runtimeMap;

}

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

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

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

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

From source file:byps.test.servlet.MyRemoteStreams.java

@Override
public TreeMap<Integer, InputStream> getImages() throws RemoteException {
    if (log.isDebugEnabled())
        log.debug("getImages(");
    Map<Integer, ByteBuffer> mapStreamBytes = this.mapStreamBytes;
    if (mapStreamBytes == null)
        return null;
    TreeMap<Integer, InputStream> map = new TreeMap<Integer, InputStream>();
    for (Integer k : mapStreamBytes.keySet()) {
        ByteBuffer buf = mapStreamBytes.get(k);
        InputStream istrm = new ByteArrayInputStream(buf.array(), buf.position(), buf.remaining());
        map.put(k, istrm);
    }//from   w  w  w  . ja v a 2s.  com
    if (log.isDebugEnabled())
        log.debug(")getImages=" + map);
    return map;
}

From source file:com.qwazr.scheduler.SchedulerManager.java

TreeMap<String, String> getSchedulers() {
    etcTracker.check();/*w  w w . j  a va 2  s .c om*/
    final TreeMap<String, String> map = new TreeMap<String, String>();
    final Map<String, SchedulerDefinition> scMap = schedulerMap;
    if (scMap == null)
        return map;
    scMap.forEach(
            (name, schedulerDef) -> map.put(name, ClusterManager.INSTANCE.myAddress + "/schedulers/" + name));
    return map;
}

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

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

From source file:edu.illinois.cs.cogcomp.core.datastructures.Lexicon.java

public void writeIntegerToFeatureStringFormat(PrintStream out) throws IOException {
    if (null == this.featureNames)
        throw new IllegalStateException("Error: Lexicon has not been configured to store feature names.");

    TreeMap<Integer, String> idToFeat = new TreeMap();

    for (String feat : this.featureNames) {
        int id = lookupId(feat);
        idToFeat.put(id, feat);
    }//from  ww w  . ja  v a2  s  .c o m

    for (Integer id : idToFeat.keySet()) {
        out.print(id);
        out.print("\t");
        out.print(idToFeat.get(id));
    }
    out.flush();
}

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

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

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

public void reloadShardsCache() {
    ColumnQuery<byte[], T, byte[]> columnQuery = HFactory.createColumnQuery(keyspace,
            BytesArraySerializer.get(), getColumnNameSerializer(), BytesArraySerializer.get());
    columnQuery.setColumnFamily(columnFamily).setKey(baseIndexKey).setName(getShardColumnName());
    QueryResult<HColumn<T, byte[]>> result = columnQuery.execute();

    if (result.get() == null)
        shards = new TreeMap<T, T>();
    else {//from w  w w . ja  v  a  2s  .  co  m
        List<T> list = getDataListForBytes(result.get().getValue());
        TreeMap<T, T> map = new TreeMap<T, T>();
        for (T value : list) {
            map.put(value, value);
        }

        shards = map;
    }
}