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);
}
}
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);
}
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;
}
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;
}
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;
}
Aggregations