Search in sources :

Example 41 with LinkedHashMap

use of java.util.LinkedHashMap in project grails-core by grails.

the class PropertySourcesConfig method mergeEnumerablePropertySource.

private void mergeEnumerablePropertySource(EnumerablePropertySource enumerablePropertySource) {
    if (enumerablePropertySource instanceof NavigableMapPropertySource) {
        configMap.merge(((NavigableMapPropertySource) enumerablePropertySource).getSource(), false);
    } else {
        Map<String, Object> map = new LinkedHashMap<String, Object>();
        final String[] propertyNames = enumerablePropertySource.getPropertyNames();
        for (String propertyName : propertyNames) {
            Object value = enumerablePropertySource.getProperty(propertyName);
            if (value instanceof ConfigObject) {
                if (((ConfigObject) value).isEmpty())
                    continue;
            }
            if (value instanceof CharSequence) {
                value = resolvePlaceholders(value.toString());
            }
            map.put(propertyName, value);
        }
        configMap.merge(map, true);
    }
}
Also used : ConfigObject(groovy.util.ConfigObject) ConfigObject(groovy.util.ConfigObject) LinkedHashMap(java.util.LinkedHashMap)

Example 42 with LinkedHashMap

use of java.util.LinkedHashMap in project gradle by gradle.

the class RuntimeShadedJarCreator method createFatJar.

private void createFatJar(final File outputJar, final Iterable<? extends File> files, final ProgressLogger progressLogger) {
    final File tmpFile = tempFileFor(outputJar);
    IoActions.withResource(openJarOutputStream(tmpFile), new ErroringAction<ZipOutputStream>() {

        @Override
        protected void doExecute(ZipOutputStream jarOutputStream) throws Exception {
            processFiles(jarOutputStream, files, new byte[BUFFER_SIZE], new HashSet<String>(), new LinkedHashMap<String, List<String>>(), progressLogger);
            jarOutputStream.finish();
        }
    });
    GFileUtils.moveFile(tmpFile, outputJar);
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) File(java.io.File) UncheckedException(org.gradle.internal.UncheckedException) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) GradleException(org.gradle.api.GradleException) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap)

Example 43 with LinkedHashMap

use of java.util.LinkedHashMap in project grails-core by grails.

the class FetchAllTaskSelectorsBuildAction method execute.

public AllTasksModel execute(BuildController controller) {
    AllTasksModel model = new AllTasksModel();
    Map<String, Set<String>> allTaskSelectors = new LinkedHashMap<String, Set<String>>();
    model.allTaskSelectors = allTaskSelectors;
    Map<String, Set<String>> allTasks = new LinkedHashMap<String, Set<String>>();
    model.allTasks = allTasks;
    Map<String, String> projectPaths = new HashMap<String, String>();
    model.projectPaths = projectPaths;
    for (BasicGradleProject project : controller.getBuildModel().getProjects()) {
        BuildInvocations entryPointsForProject = controller.getModel(project, BuildInvocations.class);
        Set<String> selectorNames = new LinkedHashSet<String>();
        for (TaskSelector selector : entryPointsForProject.getTaskSelectors()) {
            selectorNames.add(selector.getName());
        }
        allTaskSelectors.put(project.getName(), selectorNames);
        Set<String> taskNames = new LinkedHashSet<String>();
        for (Task task : entryPointsForProject.getTasks()) {
            taskNames.add(task.getName());
        }
        allTasks.put(project.getName(), taskNames);
        projectPaths.put(project.getName(), project.getPath());
        if (project.getProjectDirectory().getAbsolutePath().equals(currentProjectPath)) {
            model.currentProject = project.getName();
        }
    }
    return model;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Task(org.gradle.tooling.model.Task) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BasicGradleProject(org.gradle.tooling.model.gradle.BasicGradleProject) BuildInvocations(org.gradle.tooling.model.gradle.BuildInvocations) TaskSelector(org.gradle.tooling.model.TaskSelector) LinkedHashMap(java.util.LinkedHashMap) AllTasksModel(org.grails.cli.gradle.FetchAllTaskSelectorsBuildAction.AllTasksModel)

Example 44 with LinkedHashMap

use of java.util.LinkedHashMap in project groovy-core by groovy.

the class InvokerHelper method createMap.

public static Map createMap(Object[] values) {
    Map answer = new LinkedHashMap(values.length / 2);
    int i = 0;
    while (i < values.length - 1) {
        if ((values[i] instanceof SpreadMap) && (values[i + 1] instanceof Map)) {
            Map smap = (Map) values[i + 1];
            Iterator iter = smap.keySet().iterator();
            for (; iter.hasNext(); ) {
                Object key = iter.next();
                answer.put(key, smap.get(key));
            }
            i += 2;
        } else {
            answer.put(values[i++], values[i++]);
        }
    }
    return answer;
}
Also used : Iterator(java.util.Iterator) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 45 with LinkedHashMap

use of java.util.LinkedHashMap in project translationstudio8 by heartsome.

the class TermBaseSearchDialog method sortMap.

/**
	 * 对搜索结果按相似度进行排序
	 * @param mapItem
	 * @return ;
	 */
private LinkedHashMap<String, Object[]> sortMap(LinkedHashMap<MetaData, HashMap<String, IdentityHashMap<String, String>>> mapItem) {
    Iterator<Entry<MetaData, HashMap<String, IdentityHashMap<String, String>>>> it = mapItem.entrySet().iterator();
    LinkedHashMap<String, Object[]> mapData = new LinkedHashMap<String, Object[]>();
    while (it.hasNext()) {
        Entry<MetaData, HashMap<String, IdentityHashMap<String, String>>> entry = it.next();
        MetaData metaData = entry.getKey();
        HashMap<String, IdentityHashMap<String, String>> mapTerm = entry.getValue();
        Iterator<Entry<String, IdentityHashMap<String, String>>> iterator = mapTerm.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, IdentityHashMap<String, String>> e = (Map.Entry<String, IdentityHashMap<String, String>>) iterator.next();
            String strGroupIdString = e.getKey();
            IdentityHashMap<String, String> map = e.getValue();
            String key = metaData.getDatabaseName() + "_" + metaData.getServerName() + "_" + strGroupIdString;
            Object[] arrObj = new Object[] { metaData, map };
            mapData.put(key, arrObj);
        }
    }
    ArrayList<Entry<String, Object[]>> entryList = new ArrayList<Entry<String, Object[]>>(mapData.entrySet());
    Collections.sort(entryList, new Comparator<Map.Entry<String, Object[]>>() {

        @SuppressWarnings("unchecked")
        public int compare(Map.Entry<String, Object[]> arg0, Map.Entry<String, Object[]> arg1) {
            IdentityHashMap<String, String> map0 = (IdentityHashMap<String, String>) arg0.getValue()[1];
            IdentityHashMap<String, String> map1 = (IdentityHashMap<String, String>) arg1.getValue()[1];
            String strSimilarity0 = map0.get("similarity");
            String strSimilarity1 = map1.get("similarity");
            if (strSimilarity0 == null || strSimilarity1 == null) {
                if (strSimilarity0 != null) {
                    return -1;
                } else if (strSimilarity1 != null) {
                    return 1;
                } else {
                    return 0;
                }
            } else {
                int intData0 = Integer.parseInt(strSimilarity0);
                int intData1 = Integer.parseInt(strSimilarity1);
                if (intData0 > intData1) {
                    return -1;
                } else if (intData0 < intData1) {
                    return 1;
                } else {
                    return 0;
                }
            }
        }
    });
    mapData.clear();
    for (Entry<String, Object[]> entry : entryList) {
        String key = entry.getKey();
        Object[] obj = entry.getValue();
        mapData.put(key, obj);
    }
    return mapData;
}
Also used : IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IdentityHashMap(java.util.IdentityHashMap) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Entry(java.util.Map.Entry) MetaData(net.heartsome.cat.common.bean.MetaData) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)2393 Map (java.util.Map)691 ArrayList (java.util.ArrayList)674 HashMap (java.util.HashMap)439 Test (org.junit.Test)317 List (java.util.List)297 IOException (java.io.IOException)151 HashSet (java.util.HashSet)128 Set (java.util.Set)110 LinkedHashSet (java.util.LinkedHashSet)100 File (java.io.File)93 LinkedList (java.util.LinkedList)75 TreeMap (java.util.TreeMap)72 Node (org.apache.hadoop.hive.ql.lib.Node)70 NodeProcessor (org.apache.hadoop.hive.ql.lib.NodeProcessor)68 Rule (org.apache.hadoop.hive.ql.lib.Rule)68 GraphWalker (org.apache.hadoop.hive.ql.lib.GraphWalker)66 Dispatcher (org.apache.hadoop.hive.ql.lib.Dispatcher)65 Iterator (java.util.Iterator)64 DefaultRuleDispatcher (org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher)64