Example usage for java.util SortedMap get

List of usage examples for java.util SortedMap get

Introduction

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

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:org.n52.movingcode.runtime.processors.java.JavaJARProcessor.java

/**
 * Creates an args[] object for executing a main method
 * //from w ww.j a  va 2  s.  c  om
 * @param paramSet
 *        - the parameter specification
 * @param executionValues
 *        - the values for the parameters
 */
private static String[] buildArgs(SortedMap<ParameterID, String[]> executionValues,
        SortedMap<ParameterID, IOParameter> paramMap) throws IllegalArgumentException {

    List<String> arguments = new ArrayList<String>();

    // assemble commandLine with values, separators and all that stuff
    for (ParameterID identifier : executionValues.keySet()) {
        String argument = "";
        // 1. add prefix
        argument = argument + paramMap.get(identifier).printPrefix();
        // 2. add values with subsequent separator
        for (String value : executionValues.get(identifier)) {
            argument = argument + value + paramMap.get(identifier).printSeparator();
        }
        // remove last occurrence of separator
        if (argument.length() != 0) {
            argument = argument.substring(0,
                    argument.length() - paramMap.get(identifier).printSeparator().length());
        }
        // 3. add suffix
        argument = argument + paramMap.get(identifier).printSuffix();
        // 4. add to argument to CommandLine
        arguments.add(argument);
    }

    return arguments.toArray(new String[arguments.size()]);
}

From source file:com.aurel.track.exchange.excel.ExcelFieldMatchBL.java

/**
 * Gets a columnName to fieldID map//from   w ww.ja v a2  s  . c  o  m
 * @param columnIndexToFieldIDMap
 * @param columnIndexToColumNameMap
 * @return
 */
static Map<String, Integer> getColumnNameToFieldIDMap(Map<Integer, Integer> columnIndexToFieldIDMap,
        SortedMap<Integer, String> columnIndexToColumNameMap) {
    Map<String, Integer> columNameToFieldIDMap = new HashMap<String, Integer>();
    Iterator<Integer> iterator = columnIndexToColumNameMap.keySet().iterator();
    while (iterator.hasNext()) {
        Integer columnIndex = iterator.next();
        String columnName = columnIndexToColumNameMap.get(columnIndex);
        if (columnIndexToFieldIDMap.containsKey(columnIndex)) {
            Integer fieldID = columnIndexToFieldIDMap.get(columnIndex);
            if (fieldID != null && fieldID.intValue() != 0) {
                columNameToFieldIDMap.put(columnName, columnIndexToFieldIDMap.get(columnIndex));
            }
        }
    }
    return columNameToFieldIDMap;
}

From source file:com.aurel.track.exchange.excel.ExcelFieldMatchBL.java

/**
 * Gets a columnIndex to fieldID map/* w ww  . j a va2s  .c  om*/
 * @param columNameToFieldIDMap
 * @param columnIndexToColumNameMap
 * @return
 */
static Map<Integer, Integer> getColumnIndexToFieldIDMap(Map<String, Integer> columNameToFieldIDMap,
        SortedMap<Integer, String> columnIndexToColumNameMap) {
    Map<Integer, Integer> columnIndexToFieldIDMap = new HashMap<Integer, Integer>();
    Iterator<Integer> iterator = columnIndexToColumNameMap.keySet().iterator();
    while (iterator.hasNext()) {
        Integer columnIndex = iterator.next();
        String columnName = columnIndexToColumNameMap.get(columnIndex);
        if (columNameToFieldIDMap.containsKey(columnName)) {
            columnIndexToFieldIDMap.put(columnIndex, columNameToFieldIDMap.get(columnName));
        }
    }
    return columnIndexToFieldIDMap;
}

From source file:com.comcast.cmb.common.util.AuthUtil.java

private static String constructV1DataToSign(Map<String, String> parameters) {

    StringBuilder data = new StringBuilder();
    SortedMap<String, String> sortedParameters = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    sortedParameters.putAll(parameters);

    for (String key : sortedParameters.keySet()) {
        data.append(key);/*w  w w. ja va  2  s.  com*/
        data.append(sortedParameters.get(key));
    }

    return data.toString();
}

From source file:org.n52.movingcode.runtime.processors.python.PythonCLIProcessor.java

/**
 * Creates a CommandLine Object for execution
 * /* ww w  . j a va 2 s.  c  o  m*/
 * @param paramSet
 *        - the parameter specification
 * @param executionValues
 *        - the values for the parameters
 * @return CommandLine - an executable CommandLine
 */
private static CommandLine buildCommandLine(String executable, SortedMap<ParameterID, String[]> executionValues,
        SortedMap<ParameterID, IOParameter> paramMap) throws IllegalArgumentException {

    CommandLine commandLine = CommandLine.parse(executable);

    // assemble commandLine with values, separators and all that stuff
    for (ParameterID identifier : executionValues.keySet()) {
        String argument = "";
        // 1. add prefix
        argument = argument + paramMap.get(identifier).printPrefix();
        // 2. add values with subsequent separator
        for (String value : executionValues.get(identifier)) {
            argument = argument + value + paramMap.get(identifier).printSeparator();
        }
        // remove last occurrence of separator
        if (argument.length() != 0) {
            argument = argument.substring(0,
                    argument.length() - paramMap.get(identifier).printSeparator().length());
        }
        // 3. add suffix
        argument = argument + paramMap.get(identifier).printSuffix();
        // 4. add to argument to CommandLine
        commandLine.addArgument(argument, false);
    }

    return commandLine;
}

From source file:edu.brown.utils.CollectionUtil.java

/**
 * @param <K>//from  w  w  w.java2  s. c  om
 * @param <V>
 * @param map
 * @return
 */
public static <K extends Comparable<?>, V> List<V> getSortedList(SortedMap<K, Collection<V>> map) {
    List<V> ret = new ArrayList<V>();
    for (K key : map.keySet()) {
        ret.addAll(map.get(key));
    } // FOR
    return (ret);
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.filter.GWikiChangeNotificationActionBean.java

/**
 * Gets the notification pages for email.
 *
 * @param wikiContext the wiki context/*w w w .j  a  v a 2s  .c  o  m*/
 * @param props the props
 * @param email the email
 * @return PageId to Title, Recursive
 */
@SuppressWarnings("unchecked")
public static Map<String, Pair<String, Boolean>> getNotificationPagesForEmail(GWikiContext wikiContext,
        Map<String, String> props, String email) {
    Map<String, Pair<String, Boolean>> ret = new TreeMap<String, Pair<String, Boolean>>();
    Map<String, String> m = (Map<String, String>) (Map<?, ?>) props;
    for (Map.Entry<String, String> me : m.entrySet()) {
        SortedMap<String, Boolean> pm = parseNotLine(me.getValue());
        if (pm.containsKey(email) == false) {
            continue;
        }

        GWikiElementInfo ei = wikiContext.getWikiWeb().findElementInfo(me.getKey());
        if (ei == null) {
            continue;
        }
        ret.put(me.getKey(), Pair.make(wikiContext.getTranslatedProp(ei.getTitle()), pm.get(email)));
    }
    return ret;
}

From source file:models.ModuleVersion.java

public static SortedMap<String, SortedSet<ModuleVersion>> findDependants(String moduleName, String version) {
    String query = "SELECT d.version, v FROM ModuleVersion v JOIN v.dependencies d LEFT JOIN FETCH v.module WHERE d.name=:name";
    if (version != null && !version.isEmpty()) {
        query += " AND d.version=:version";
    }// w  w  w. j a v a  2 s.co m
    Query jpa = JPA.em().createQuery(query).setParameter("name", moduleName);
    if (version != null && !version.isEmpty()) {
        jpa.setParameter("version", version);
    }
    List<Object[]> results = jpa.getResultList();

    Comparator<String> versionComparator = new Comparator<String>() {
        @Override
        public int compare(String v1, String v2) {
            return Util.compareVersions(v1, v2);
        }
    };

    Comparator<ModuleVersion> dependantComparator = new Comparator<ModuleVersion>() {
        @Override
        public int compare(ModuleVersion v1, ModuleVersion v2) {
            int result = v1.module.name.compareTo(v2.module.name);
            if (result == 0) {
                result = Util.compareVersions(v1.version, v2.version);
            }
            return result;
        }
    };

    SortedMap<String, SortedSet<ModuleVersion>> dependantsMap = new TreeMap<String, SortedSet<ModuleVersion>>(
            versionComparator);
    for (Object[] result : results) {
        String ver = (String) result[0];
        ModuleVersion dependant = (ModuleVersion) result[1];

        SortedSet<ModuleVersion> dependants = dependantsMap.get(ver);
        if (dependants == null) {
            dependants = new TreeSet<ModuleVersion>(dependantComparator);
            dependantsMap.put(ver, dependants);
        }
        dependants.add(dependant);
    }

    return dependantsMap;
}

From source file:org.web4thejob.studio.support.StudioUtil.java

private static <T extends Controller> T getController(ControllerEnum id) {
    Desktop desktop;/*from  w  w w.  ja  v  a  2  s  .  com*/
    if (id == CANVAS_CONTROLLER && isCanvasDesktop() || (id != CANVAS_CONTROLLER && !isCanvasDesktop())) {
        desktop = Executions.getCurrent().getDesktop();
    } else {
        desktop = getPairedDesktop();
    }

    SortedMap<ControllerEnum, Controller> controllers = cast(desktop.getAttribute(ATTR_STUDIO_CONTROLLERS));
    notNull(controllers, "called to early");
    return cast(controllers.get(id));
}

From source file:com.basho.riak.client.raw.pbc.ConversionUtil.java

/**
 * Take a link walked m/r result and make it into a WalkResult.
 *
 * This is a little bit nasty since the JSON is parsed to a Map.
 *
 * @param secondPhaseResult/*w  w w .j ava 2  s . c  o  m*/
 *            the contents of which *must* be a json array of {step: int, v:
 *            riakObjectMap}
 * @return a WalkResult of RiakObjects grouped by first-phase step
 * @throws IOException
 */
@SuppressWarnings({ "rawtypes" })
static WalkResult convert(MapReduceResult secondPhaseResult) throws IOException {
    final SortedMap<Integer, Collection<IRiakObject>> steps = new TreeMap<Integer, Collection<IRiakObject>>();

    try {
        Collection<Map> results = secondPhaseResult.getResult(Map.class);
        for (Map o : results) {
            final int step = Integer.parseInt((String) o.get("step"));
            Collection<IRiakObject> stepAccumulator = steps.get(step);

            if (stepAccumulator == null) {
                stepAccumulator = new ArrayList<IRiakObject>();
                steps.put(step, stepAccumulator);
            }

            final Map data = (Map) o.get("v");

            stepAccumulator.add(mapToRiakObject(data));
        }
    } catch (ConversionException e) {
        throw new IOException(e.getMessage());
    }
    // create a result instance
    return new WalkResult() {
        public Iterator<Collection<IRiakObject>> iterator() {
            return new UnmodifiableIterator<Collection<IRiakObject>>(steps.values().iterator());
        }
    };
}