Java Examples for java.util.HashMap
The following java examples will help you to understand the usage of java.util.HashMap. These source code samples are taken from different open source projects.
Example 1
Project: heapaudit-master File: TestHashMap.java View source code |
// Test allocation of HashMap. @Test public void HashMap() { clear(); HashMap<Integer, Integer> hashmap = new HashMap<Integer, Integer>(); for (int i = 0; i < 100; ++i) { hashmap.put(i, i); assertTrue(expect("java.util.HashMap$Entry", -1, 32)); } assertTrue(expect("java.util.HashMap", -1, 48)); assertTrue(expect("java.util.HashMap$Entry", 16, 80)); assertTrue(expect("java.util.HashMap$Entry", 32, 144)); assertTrue(expect("java.util.HashMap$Entry", 64, 272)); assertTrue(expect("java.util.HashMap$Entry", 128, 528)); assertTrue(expect("java.util.HashMap$Entry", 256, 1040)); assertTrue(empty()); }
Example 2
Project: bigbluebutton-master File: MessageToJson.java View source code |
public static String registerUserToJson(RegisterUserMessage message) { HashMap<String, Object> payload = new HashMap<String, Object>(); payload.put(Constants.MEETING_ID, message.meetingID); payload.put(Constants.NAME, message.fullname); payload.put(Constants.USER_ID, message.internalUserId); payload.put(Constants.ROLE, message.role); payload.put(Constants.EXT_USER_ID, message.externUserID); payload.put(Constants.AUTH_TOKEN, message.authToken); payload.put(Constants.AVATAR_URL, message.avatarURL); java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(RegisterUserMessage.REGISTER_USER, message.VERSION, null); return MessageBuilder.buildJson(header, payload); }
Example 3
Project: gluster-ovirt-poc-master File: ConnectStorageServerVDSCommand.java View source code |
@SuppressWarnings("unchecked")
protected Map<String, String>[] BuildStructFromConnectionListObject() {
Map<String, String>[] result = new HashMap[getParameters().getConnectionList().size()];
int i = 0;
for (storage_server_connections connection : getParameters().getConnectionList()) {
result[i] = CreateStructFromConnection(connection);
i++;
}
return result;
}
Example 4
Project: iterator-master File: Object.java View source code |
public static java.lang.Object decode_(com.jsoniter.JsonIterator iter) throws java.io.IOException { java.util.HashMap map = (java.util.HashMap) com.jsoniter.CodegenAccess.resetExistingObject(iter); if (iter.readNull()) { return null; } if (map == null) { map = new java.util.HashMap(); } if (!com.jsoniter.CodegenAccess.readObjectStart(iter)) { return map; } do { String field = com.jsoniter.CodegenAccess.readObjectFieldAsString(iter); map.put(field, (java.lang.Object) iter.read()); } while (com.jsoniter.CodegenAccess.nextToken(iter) == ','); return map; }
Example 5
Project: jwt4j-master File: DisabledRegisteredClaimsValidatorTest.java View source code |
@Test
public void shouldDoNothing() {
//given
final DisabledRegisteredClaimsValidator disabledRegisteredClaimsValidator = new DisabledRegisteredClaimsValidator();
//when
disabledRegisteredClaimsValidator.validate(new HashMap<String, String>() {
{
put(JWTConstants.JWT_ID, "Jwt-ID");
}
});
//then
}
Example 6
Project: spyjar-master File: InstantiatorTest.java View source code |
@SuppressWarnings("unchecked") public void testSimple() throws Exception { Instantiator<Map> i = new Instantiator<Map>("java.util.HashMap"); assertTrue(i.getInstance() instanceof HashMap); assertSame(i.getInstance(), i.getInstance()); Instantiator<Map> i2 = new Instantiator<Map>("java.util.HashMap"); assertTrue(i2.getInstance() instanceof HashMap); assertNotSame(i2.getInstance(), i.getInstance()); assertEquals(i.getInstance(), i2.getInstance()); }
Example 7
Project: test4XXX-master File: test4HashMap.java View source code |
/** * @param args */ public static void main(String[] args) { MyClass myClass = new MyClass("123"); HashMap<Integer, SoftReference<MyClass>> map = new HashMap<>(); map.put(myClass.hashCode(), new SoftReference<>(myClass)); map.put(myClass.hashCode(), new SoftReference<>(myClass)); myClass = new MyClass("456"); map.put(myClass.hashCode(), new SoftReference<>(myClass)); System.out.println(map.size()); Iterator<Entry<Integer, SoftReference<MyClass>>> iterator = map.entrySet().iterator(); while (iterator.hasNext()) { Entry<Integer, SoftReference<MyClass>> entry = iterator.next(); SoftReference<MyClass> val = entry.getValue(); MyClass item = val.get(); if (null != item) { System.out.println(item.mString); } // // map.remove(item.hashCode()); // Exception in thread "main" java.util.ConcurrentModificationException // at java.util.HashMap$HashIterator.nextNode(Unknown Source) // at java.util.HashMap$EntryIterator.next(Unknown Source) // at java.util.HashMap$EntryIterator.next(Unknown Source) // at test4HashMap.main(test4HashMap.java:30) } map.remove(myClass.hashCode()); // System.out.println(map.size()); listHashMap(); listHashMap1(); }
Example 8
Project: fastjson-master File: TestKlutz3.java View source code |
public void test_0() throws Exception {
EpubViewBook book = new EpubViewBook();
book.setBookName("xx");
book.setPageList(new ArrayList<EpubViewPage>());
EpubViewPage page = new EpubViewPage();
book.getPageList().add(page);
EpubViewMetaData metadata = new EpubViewMetaData();
metadata.setProperties(new HashMap<String, String>());
// book.setMetadata(null);
String str = JSON.toJSONString(book);
System.out.println(str);
JSON.parseObject(str, EpubViewBook.class);
}
Example 9
Project: intellij-generator-plugin-master File: TypeToTextFactory.java View source code |
public static TypeToTextMapping createDefaultVariableInitialization() { return new TypeToTextMapping().put("java.util.Collection", "java.util.Collections." + GENERICS_PLACEHOLDER + "emptySet()", true).put("java.util.Set", "java.util.Collections." + GENERICS_PLACEHOLDER + "emptySet()", true).put("java.util.List", "java.util.Collections." + GENERICS_PLACEHOLDER + "emptyList()", true).put("java.util.ArrayList", "new java.util.ArrayList" + GENERICS_PLACEHOLDER + "()", true).put("java.util.SortedSet", "new java.util.TreeSet" + GENERICS_PLACEHOLDER + "()", true).put("java.util.HashSet", "new java.util.HashSet" + GENERICS_PLACEHOLDER + "()", true).put("java.util.LinkedHashSet", "new java.util.LinkedHashSet" + GENERICS_PLACEHOLDER + "()", true).put("java.util.HashMap", "new java.util.HashMap" + GENERICS_PLACEHOLDER + "()", false); }
Example 10
Project: 2checkout-java-master File: TwocheckoutUtil.java View source code |
public static ArrayList<NameValuePair> convert(HashMap<String, String> params) { HashMap<String, String> callParams = params; ArrayList<NameValuePair> apiParams = new ArrayList<NameValuePair>(); for (Map.Entry<String, String> entry : callParams.entrySet()) { apiParams.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } return apiParams; }
Example 11
Project: Cliques-master File: StringUtils.java View source code |
public static String encodeUrl(HashMap<String, String> parameters) {
if (parameters == null || parameters.size() == 0)
return "";
StringBuilder sb = new StringBuilder();
sb.append("?");
boolean first = true;
for (String key : parameters.keySet()) {
if (first)
first = false;
else
sb.append("&");
sb.append(key + "=" + parameters.get(key));
}
return sb.toString();
}
Example 12
Project: Code4Reference-master File: MainTest.java View source code |
/** * @param args */ public static void main(String[] args) { // TrieTree tt=new TrieTree(); // tt.insertWord("rakesh"); // System.out.println("----------------------"); // tt.insertWord("rajesh"); // // if(tt.searchWord("rakesm")){ // System.out.println("Word is present"); // }else{ // System.out.println("Word is not present in the trie "); // } // // tt.printSuggestedWord("rak"); HashMap<Integer, String> hashmap = new HashMap<Integer, String>(); }
Example 13
Project: coding2017-master File: xmlTest.java View source code |
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String actionName = "login";
Map<String, String> params = new HashMap<String, String>();
params.put("name", "test");
params.put("password", "1234");
View view = Struts.runAction(actionName, params);
String str = view.getJsp();
System.out.println(str);
}
Example 14
Project: concurrencer-master File: TestFailDueToCreateValueSideEffects.java View source code |
public void doSideEffects() {
if (hm.containsKey("a_key")) {
String value = new String(" this is a value ");
value.trim();
// side-effect
hm = doSomething();
// side-effect
hm = new HashMap();
// side-effect
hm.clear();
hm.put("a_key", value);
}
}
Example 15
Project: ijoomer-adv-sdk-master File: PluginsCachingConstants.java View source code |
public static HashMap<String, String> getUnnormlizeFields() { HashMap<String, String> unNormalizeFields = new HashMap<String, String>() { { put(// plugin "player", // plugin ""); put(// plugin "content", // plugin ""); put("contentRating", ""); put(// plugin "video", // plugin ""); put(// plugin "links", // plugin ""); // plugin facebook put("location", ""); // plugin facebook put("category_list", ""); // plugin Weather put("weatherDesc", ""); // plugin Weather put("weatherIconUrl", ""); } }; return unNormalizeFields; }
Example 16
Project: JSON-RPC-master File: VarArgsUtil.java View source code |
public static Map<String, Object> convertArgs(Object[] params) {
final Map<String, Object> unsafeMap = new HashMap<>();
for (int i = 0; i < params.length; i += 2) {
if (params[i] instanceof String && params[i] != null && !params[i].toString().isEmpty()) {
unsafeMap.put(params[i].toString(), params[i + 1]);
}
}
return unsafeMap;
}
Example 17
Project: jsonrpc4j-master File: VarArgsUtil.java View source code |
public static Map<String, Object> convertArgs(Object[] params) {
final Map<String, Object> unsafeMap = new HashMap<>();
for (int i = 0; i < params.length; i += 2) {
if (params[i] instanceof String && params[i] != null && !params[i].toString().isEmpty()) {
unsafeMap.put(params[i].toString(), params[i + 1]);
}
}
return unsafeMap;
}
Example 18
Project: kanqiu_letv-master File: NativeCMD.java View source code |
public static Map<String, Object> runCmd(String cmd) {
Map<String, Object> map = new HashMap<String, Object>();
try {
Process process = Runtime.getRuntime().exec(cmd);
map.put("input", process.getInputStream());
map.put("error", process.getErrorStream());
return map;
} catch (Exception e) {
return null;
}
}
Example 19
Project: kotlin-master File: overMapEntries.java View source code |
public static void main(String[] args) {
Map<String, String> resultMap = new HashMap<String, String>();
for (final Map.Entry<String, String> entry : resultMap.entrySet()) {
String key = entry.getKey();
String type = entry.getValue();
if (key.equals("myKey")) {
System.out.println(type);
}
}
}
Example 20
Project: spark-template-engines-master File: PebbleExample.java View source code |
public static void main(String[] args) {
get("/hello", ( request, response) -> {
Map<String, Object> model = new HashMap<>();
model.put("message", "Hello World!");
// located in resources/spark/template/pebble
return new ModelAndView(model, "templates/hello.pebble");
}, new PebbleTemplateEngine());
}
Example 21
Project: street-master File: StringMapEntryModifyTest.java View source code |
public void testModify() {
StringMapEntryModify c = new StringMapEntryModify("a", "b", "c");
Map<String, String> m = new HashMap<>();
m.put("a", "b");
assertEquals("MODIFY \"a\"=\"b\" -> \"a\"=\"c\"", c.toString());
assertFalse(c.conflictsWith(m));
c.applyTo(m);
assertTrue(c.conflictsWith(m));
}
Example 22
Project: StreetComplete-master File: StringMapEntryModifyTest.java View source code |
public void testModify() {
StringMapEntryModify c = new StringMapEntryModify("a", "b", "c");
Map<String, String> m = new HashMap<>();
m.put("a", "b");
assertEquals("MODIFY \"a\"=\"b\" -> \"a\"=\"c\"", c.toString());
assertFalse(c.conflictsWith(m));
c.applyTo(m);
assertTrue(c.conflictsWith(m));
}
Example 23
Project: winstone-master File: HttpConnectorFactoryTest.java View source code |
@Test
public void testListenAddress() throws Exception {
Map<String, String> args = new HashMap<String, String>();
args.put("warfile", "target/test-classes/test.war");
args.put("prefix", "/");
args.put("httpPort", "59009");
args.put("httpListenAddress", "127.0.0.2");
winstone = new Launcher(args);
assertConnectionRefused("127.0.0.1", 59009);
makeRequest("http://127.0.0.2:59009/CountRequestsServlet");
}
Example 24
Project: xjava-master File: WordCount.java View source code |
public Map<String, Integer> phrase(String input) {
Map<String, Integer> countMap = new HashMap<String, Integer>();
input = input.trim().toLowerCase().replaceAll("[\\W]", " ");
final String[] tokenizedInput = input.split("\\s+");
for (String aWord : tokenizedInput) {
Integer count = countMap.get(aWord);
countMap.put(aWord, count == null ? 1 : count + 1);
}
return countMap;
}
Example 25
Project: ralasafe-master File: Factory.java View source code |
public static synchronized UserRoleManager getUserRoleManager(String appName, String userTypeName) {
if (userRoleManagers.get(appName) == null) {
synchronized (userRoleManagers) {
userRoleManagers.put(appName, new java.util.HashMap());
}
}
Map userRoleManagerMap = (Map) userRoleManagers.get(appName);
if (userRoleManagerMap.get(userTypeName) == null) {
synchronized (userRoleManagerMap) {
userRoleManagerMap.put(userTypeName, new UserRoleManagerImpl(appName, userTypeName));
}
}
return (UserRoleManager) ((Map) userRoleManagers.get(appName)).get(userTypeName);
}
Example 26
Project: android-libcore64-master File: HashMapTest.java View source code |
/** * java.util.HashMap#HashMap(int) */ public void test_ConstructorI() { // Test for method java.util.HashMap(int) HashMap hm2 = new HashMap(5); assertEquals("Created incorrect HashMap", 0, hm2.size()); try { new HashMap(-1); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } HashMap empty = new HashMap(0); assertNull("Empty hashmap access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); }
Example 27
Project: android_libcore-master File: HashMapTest.java View source code |
/** * @tests java.util.HashMap#HashMap(int) */ @TestTargetNew(level = TestLevel.COMPLETE, notes = "", method = "HashMap", args = { int.class }) public void test_ConstructorI() { // Test for method java.util.HashMap(int) HashMap hm2 = new HashMap(5); assertEquals("Created incorrect HashMap", 0, hm2.size()); try { new HashMap(-1); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } HashMap empty = new HashMap(0); assertNull("Empty hashmap access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); }
Example 28
Project: android_platform_libcore-master File: HashMapTest.java View source code |
/** * java.util.HashMap#HashMap(int) */ public void test_ConstructorI() { // Test for method java.util.HashMap(int) HashMap hm2 = new HashMap(5); assertEquals("Created incorrect HashMap", 0, hm2.size()); try { new HashMap(-1); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } HashMap empty = new HashMap(0); assertNull("Empty hashmap access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); }
Example 29
Project: robovm-master File: HashMapTest.java View source code |
/** * java.util.HashMap#HashMap(int) */ public void test_ConstructorI() { // Test for method java.util.HashMap(int) HashMap hm2 = new HashMap(5); assertEquals("Created incorrect HashMap", 0, hm2.size()); try { new HashMap(-1); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } HashMap empty = new HashMap(0); assertNull("Empty hashmap access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); }
Example 30
Project: android-sdk-sources-for-api-level-23-master File: HashMapTest.java View source code |
/** * java.util.HashMap#HashMap(int) */ public void test_ConstructorI() { // Test for method java.util.HashMap(int) HashMap hm2 = new HashMap(5); assertEquals("Created incorrect HashMap", 0, hm2.size()); try { new HashMap(-1); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } HashMap empty = new HashMap(0); assertNull("Empty hashmap access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); }
Example 31
Project: ARTPart-master File: HashMapTest.java View source code |
/** * java.util.HashMap#HashMap(int) */ public void test_ConstructorI() { // Test for method java.util.HashMap(int) HashMap hm2 = new HashMap(5); assertEquals("Created incorrect HashMap", 0, hm2.size()); try { new HashMap(-1); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } HashMap empty = new HashMap(0); assertNull("Empty hashmap access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); }
Example 32
Project: j2objc-master File: HashMapTest.java View source code |
/** * java.util.HashMap#HashMap(int) */ public void test_ConstructorI() { // Test for method java.util.HashMap(int) HashMap hm2 = new HashMap(5); assertEquals("Created incorrect HashMap", 0, hm2.size()); try { new HashMap(-1); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { } HashMap empty = new HashMap(0); assertNull("Empty hashmap access", empty.get("nothing")); empty.put("something", "here"); assertTrue("cannot get element", empty.get("something") == "here"); }
Example 33
Project: memo-nodes-master File: MemoJSONServlet.java View source code |
public static boolean get_CORS_headers(java.util.HashMap<String, String> ret, java.util.HashMap<String, String> httpHeaders) { Boolean isAllowed = true; String s = httpHeaders.get("Origin"); if (s == null) { String ref_s = httpHeaders.get("Referer"); if (ref_s != null) { try { URL url = new URL(ref_s); s = url.getProtocol() + "://" + url.getAuthority(); } catch (Exception e) { s = null; } } } if (s != null) { ret.put("Access-Control-Allow-Origin", s); ret.put("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); ret.put("Access-Control-Allow-Credentials", "true"); ret.put("Access-Control-Max-Age", "60"); //what? String returnMethod = httpHeaders.get("Access-Control-Request-Headers"); if (!"".equals(returnMethod)) { ret.put("Access-Control-Allow-Headers", returnMethod); } } return isAllowed; }
Example 34
Project: drools-master File: DynamicTypeUtils.java View source code |
@SafeVarargs public static <K, V> Map<K, V> prototype(Map.Entry<K, V>... attributes) { // as Stream.of(attributes).collect(toMap()); might fail due to some value=null, because toMap() uses java.util.HashMap.merge(HashMap.java:1224) // need avoid Stream API Map<K, V> result = new HashMap<>(); for (Entry<K, V> entry : attributes) { result.put(entry.getKey(), entry.getValue()); } return result; }
Example 35
Project: SabdroidEx-master File: JSONMarshaller.java View source code |
@Override public Object unMarshall(CharSequence json, Class clazz) throws InstantiationException, IllegalAccessException, IOException, ParseException { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(((String) json).getBytes()); JSONParser jsonParser = new JSONParser(); java.util.HashMap<String, Object> objectHashMap = (java.util.HashMap<String, Object>) jsonParser.parse(byteArrayInputStream, new java.util.concurrent.atomic.AtomicInteger(0), null); JSONPojoMapper simpleJSONMarshaller = new JSONPojoMapper(clazz); return simpleJSONMarshaller.unMarshal(objectHashMap); }
Example 36
Project: activiti-crystalball-master File: ResultQueryImplTest.java View source code |
public void testQueryVariables() {
SimulationEngine simulationEngine = SimulationEngineConfigurationImpl.createStandaloneInMemSimulationEngineConfiguration().buildSimulationEngine();
Map<String, Object> resultVariables = new HashMap<String, Object>();
resultVariables.put("processDefinitionKey", "processDefinitionId");
resultVariables.put("taskDefinitionKey", "activityId");
resultVariables.put("description", "count");
simulationEngine.getRuntimeService().saveResult("some-type", resultVariables);
}
Example 37
Project: activiti-engine-examples-master File: MethodExpressionServiceTaskTest.java View source code |
@Deployment
public void testSetServiceResultToProcessVariables() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("okReturningService", new OkReturningService());
ProcessInstance pi = runtimeService.startProcessInstanceByKey("setServiceResultToProcessVariables", variables);
assertEquals("ok", runtimeService.getVariable(pi.getId(), "result"));
}
Example 38
Project: activiti-engine-ppi-master File: MethodExpressionServiceTaskTest.java View source code |
@Deployment
public void testSetServiceResultToProcessVariables() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("okReturningService", new OkReturningService());
ProcessInstance pi = runtimeService.startProcessInstanceByKey("setServiceResultToProcessVariables", variables);
assertEquals("ok", runtimeService.getVariable(pi.getId(), "result"));
}
Example 39
Project: activiti-examples-master File: MethodExpressionServiceTaskTest.java View source code |
@Deployment
public void testSetServiceResultToProcessVariables() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("okReturningService", new OkReturningService());
ProcessInstance pi = runtimeService.startProcessInstanceByKey("setServiceResultToProcessVariables", variables);
assertEquals("ok", runtimeService.getVariable(pi.getId(), "result"));
}
Example 40
Project: AlgoDS-master File: Spammer1496.java View source code |
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = Integer.parseInt(in.nextLine());
Map<String, Integer> map = new HashMap<>();
for (int i = 0; i < n; i++) {
String s = in.nextLine();
if (!map.containsKey(s))
map.put(s, 1);
else
map.put(s, map.get(s) + 1);
}
for (String s : map.keySet()) {
if (map.get(s) > 1) {
System.out.println(s);
}
}
}
Example 41
Project: Android-Media-Library-master File: UPCDataSource.java View source code |
@SuppressWarnings("unchecked") public static String getUPCText(String upc) { String text = ""; try { XMLRPCClient client = new XMLRPCClient("http://www.upcdatabase.com/rpc"); HashMap<String, String> results = (HashMap<String, String>) client.call("lookupUPC", upc); if (results.size() > 0 && results.get("message").equalsIgnoreCase("Database entry found")) { text = results.get("description"); } } catch (Exception e) { Log.e("GrevianMedia", e.getMessage()); return ""; } return text; }
Example 42
Project: android-servlet-container-master File: WinstoneServerRunner.java View source code |
@Override
public void start() throws Exception {
Map<String, String> args = new HashMap<String, String>();
args.put("warfile", Environment.getExternalStorageDirectory().getPath() + "/winstone.war");
args.put("port", "8080");
args.put("preferredClassLoader", "exploit");
Launcher.initLogger(args);
winstone = new Launcher(args);
}
Example 43
Project: anycook-api-master File: NotificationTest.java View source code |
@Test
public void testParse() {
Map<String, String> data = new HashMap<>();
data.put("user", "username");
data.put("tag", "tagname");
//assertEquals("username", Notification.parse("%user", data));
//assertEquals("tagname", Notification.parse("%tag", data));
//assertEquals("Hallo username, das ist der Tag: tagname", Notification.parse("Hallo %user, das ist der Tag: %tag", data));
}
Example 44
Project: AppLock-master File: DataUtil.java View source code |
public static List<CommLockInfo> clearRepeatCommLockInfo(List<CommLockInfo> lockInfos) { HashMap<String, CommLockInfo> hashMap = new HashMap<>(); for (CommLockInfo lockInfo : lockInfos) { if (!hashMap.containsKey(lockInfo.getPackageName())) { hashMap.put(lockInfo.getPackageName(), lockInfo); } } List<CommLockInfo> commLockInfos = new ArrayList<>(); for (HashMap.Entry<String, CommLockInfo> entry : hashMap.entrySet()) { commLockInfos.add(entry.getValue()); } return commLockInfos; }
Example 45
Project: ApprovalTests.Java-master File: CachingRackTest.java View source code |
public void testCache() throws Exception {
HelloWorldRack rack = new HelloWorldRack();
RackCache cache = new RackCache();
cache.add(rack, "HelloWorld");
Map<String, Object> input = new HashMap<String, Object>();
input.put(RackEnvironment.PATH_INFO, "HelloWorld");
cache.call(input);
cache.call(input);
assertEquals(1, rack.calls);
}
Example 46
Project: atlas-lb-master File: UsagePollerTestHelper.java View source code |
public static Map<Integer, List<LoadBalancerHostUsage>> groupLBHostUsagesByLoadBalancer(List<LoadBalancerHostUsage> lbHostUsages) {
Map<Integer, List<LoadBalancerHostUsage>> lbMap = new HashMap<Integer, List<LoadBalancerHostUsage>>();
for (LoadBalancerHostUsage lbHostUsage : lbHostUsages) {
if (!lbMap.containsKey(lbHostUsage.getLoadbalancerId())) {
lbMap.put(lbHostUsage.getLoadbalancerId(), new ArrayList<LoadBalancerHostUsage>());
}
lbMap.get(lbHostUsage.getLoadbalancerId()).add(lbHostUsage);
}
return lbMap;
}
Example 47
Project: audit4j-core-master File: CommandIntTest.java View source code |
@Test
public void testMetadataCommand() {
CommandProcessor processor = CommandProcessor.getInstance();
Map<String, String> commands = new HashMap<String, String>();
commands.put("-metadata", "async");
processor.process(commands);
MetadataCommand command = (MetadataCommand) PreConfigurationContext.getCommandByName("-metadata");
Assert.assertTrue(command.isAsync());
}
Example 48
Project: avaje-ebeanorm-examples-master File: HstoreJsonTest.java View source code |
@Test
public void test() throws IOException {
Customer customer = new Customer();
customer.setName("SomeCustomer");
Map<String, String> tags = new HashMap<>();
tags.put("height", "100");
tags.put("length", "200");
customer.setTags(tags);
JsonContext jsonContext = Customer.db().json();
String jsonString = jsonContext.toJson(customer);
System.out.println(jsonString);
}
Example 49
Project: avaje-ebeanorm-master File: HstoreJsonTest.java View source code |
@Test
public void test() throws IOException {
Customer customer = new Customer();
customer.setName("SomeCustomer");
Map<String, String> tags = new HashMap<>();
tags.put("height", "100");
tags.put("length", "200");
customer.setTags(tags);
JsonContext jsonContext = Customer.db().json();
String jsonString = jsonContext.toJson(customer);
System.out.println(jsonString);
}
Example 50
Project: aviator-master File: TernaryOperatorExample.java View source code |
public static void main(String[] args) {
if (args.length < 1) {
System.err.println("Usage: java TernaryOperatorExample [number]");
System.exit(1);
}
int num = Integer.parseInt(args[0]);
Map<String, Object> env = new HashMap<String, Object>();
env.put("a", num);
String result = (String) AviatorEvaluator.execute("a>0? 'yes':'no'", env);
System.out.println(result);
}
Example 51
Project: bigbluebutton-bot-master File: ProbabilitiesConverter.java View source code |
@Override
public Map<Integer, Double> convert(String value) {
Map<Integer, Double> map = new HashMap<Integer, Double>();
String[] values = value.split(";");
for (String tmp : values) {
String[] pair = tmp.split(":");
int k = Integer.parseInt(pair[0]);
double v = Double.parseDouble(pair[1]);
map.put(k, v);
}
return map;
}
Example 52
Project: bluetooth_social-master File: StringUtils.java View source code |
//key1=value1,key2=value2........
public static Map<String, String> parseMapFromString(String baseString) {
String[] arr = baseString.split(",");
Map<String, String> result = new HashMap<String, String>();
for (int i = 0; i < arr.length; i++) {
String temp[] = arr[i].split("=");
String key = temp[0].trim();
String value = temp[1].substring(1, temp[1].length() - 1);
result.put(key, value);
}
return result;
}
Example 53
Project: braintree_java-master File: MapUtils.java View source code |
public static Map<String, Object> toMap(Object... args) { if (args.length % 2 == 1) throw new RuntimeException("toMap must be called with an even number of parameters"); HashMap<String, Object> map = new HashMap<String, Object>(); for (int i = 0; i < args.length; i += 2) { String key = String.valueOf(args[i]); Object value = args[i + 1]; map.put(key, value); } return map; }
Example 54
Project: camelinaction2-master File: PartnerServiceBean.java View source code |
public Map toMap(@XPath("partner/@id") int partnerId, @XPath("partner/date/text()") String date, @XPath("partner/code/text()") int statusCode, @XPath("partner/time/text()") long responseTime) {
if (partnerId <= 0) {
throw new IllegalArgumentException("PartnerId is invalid, was " + partnerId);
}
Map map = new HashMap();
map.put("id", partnerId);
map.put("date", date);
map.put("code", statusCode);
map.put("time", responseTime);
return map;
}
Example 55
Project: cargotracker-ddd-master File: JsonMoxyConfigurationContextResolver.java View source code |
@Override
public MoxyJsonConfig getContext(Class<?> objectType) {
MoxyJsonConfig configuration = new MoxyJsonConfig();
Map<String, String> namespacePrefixMapper = new HashMap<>(1);
namespacePrefixMapper.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
configuration.setNamespacePrefixMapper(namespacePrefixMapper);
configuration.setNamespaceSeparator(':');
return configuration;
}
Example 56
Project: ChatSecureAndroid-master File: TestUtils.java View source code |
public static void setUpApplication(Activity activity) { HashMap<Long, ProviderDef> providers = new HashMap<Long, ProviderDef>(); ImPluginHelper.getInstance(activity).skipLoadingPlugins(); providers.put(1L, new ProviderDef(1, "XMPP", "XMPP", null)); ImApp.getApplication(activity).onCreate(); ImApp.getApplication(activity).setImProviderSettings(providers); }
Example 57
Project: checker-framework-master File: Issue67.java View source code |
void test() {
Map<String, String> map = new HashMap<String, String>();
if (map.containsKey(KEY)) {
// no problem
map.get(KEY).toString();
}
//:: warning: (known.nonnull)
if (map.containsKey(KEY2) && map.get(KEY2).toString() != null) {
// error
// do nothing
}
}
Example 58
Project: cloning-master File: FastClonerHashMap.java View source code |
@SuppressWarnings({ "unchecked", "rawtypes" }) public Object clone(final Object t, final IDeepCloner cloner, final Map<Object, Object> clones) { final HashMap<Object, Object> m = (HashMap) t; final HashMap result = new HashMap(); for (final Map.Entry e : m.entrySet()) { final Object key = cloner.deepClone(e.getKey(), clones); final Object value = cloner.deepClone(e.getValue(), clones); result.put(key, value); } return result; }
Example 59
Project: cloudbreak-master File: JsonToFileSystemConverter.java View source code |
@Override
public FileSystem convert(FileSystemRequest source) {
FileSystem fs = new FileSystem();
fs.setName(source.getName());
fs.setType(source.getType().name());
fs.setDefaultFs(source.isDefaultFs());
if (source.getProperties() != null) {
fs.setProperties(source.getProperties());
} else {
fs.setProperties(new HashMap<>());
}
return fs;
}
Example 60
Project: com.idega.core-master File: AttributeParser.java View source code |
public static Map<String, String> parse(String stringToParse) {
Map<String, String> map = new HashMap<String, String>();
StringTokenizer tokens = new StringTokenizer(stringToParse, " ");
while (tokens.hasMoreTokens()) {
String attributes = tokens.nextToken();
if (attributes.indexOf("=") != -1) {
String[] values = attributes.split("=");
String attribute = values[0].trim();
String value = values[1];
map.put(attribute.toLowerCase(), TextSoap.findAndCut(value, "\""));
}
}
return map;
}
Example 61
Project: constellio-master File: SimpleDateFormatSingleton.java View source code |
public static SimpleDateFormat getSimpleDateFormat(String pattern) {
Map<String, SimpleDateFormat> patterns = dateFormats.get();
if (patterns == null) {
patterns = new HashMap<>();
dateFormats.set(patterns);
}
SimpleDateFormat simpleDateFormat = patterns.get(pattern);
if (simpleDateFormat == null) {
simpleDateFormat = new SimpleDateFormat(pattern);
patterns.put(pattern, simpleDateFormat);
}
return simpleDateFormat;
}
Example 62
Project: course-mongodb-M101J-master File: HelloWorldFreemarkerStyle.java View source code |
public static void main(String... args) {
Configuration configuration = new Configuration(Configuration.VERSION_2_3_22);
configuration.setClassForTemplateLoading(HelloWorldFreemarkerStyle.class, "/");
try {
Template helloTemplate = configuration.getTemplate("hello.ftl");
StringWriter writer = new StringWriter();
Map<String, Object> helloMap = new HashMap<String, Object>();
helloMap.put("name", "Freemarker");
helloTemplate.process(helloMap, writer);
System.out.println(writer);
} catch (Exception e) {
e.printStackTrace();
}
}
Example 63
Project: dgrid-master File: SendRestartTestCase.java View source code |
public void testRestart() throws Exception {
Map<String, String> params = new HashMap<String, String>(0);
Joblet joblet = new Joblet(0, 0l, 0, 0, getHostname(), 1, Constants.AGENT_RESTART_JOBLET, "Shutdown agent", params, "", JOB_STATUS.RECEIVED);
int jobletId = gridClient.submitHostJoblet(getHostname(), joblet, 0).getId();
super.doWork();
}
Example 64
Project: dip-master File: TuplesGrouping.java View source code |
public static Map<String, Integer> groupByField(List<Tuple> tuples, String field) {
Map<String, Integer> counts = new HashMap<>();
for (Tuple tuple : tuples) {
if (counts.containsKey(tuple.getStringByField(field))) {
counts.put(tuple.getStringByField(field), counts.get(tuple.getStringByField(field)) + 1);
} else {
if (tuple.getStringByField(field) != null)
counts.put(tuple.getStringByField(field), 1);
}
}
return counts;
}
Example 65
Project: DistributedCrawler-master File: LinkElement.java View source code |
public static LinkElement getElement(String name) {
if (LinkElement.elements == null) {
LinkElement.elements = new HashMap<String, LinkElement>();
LinkElement[] values = LinkElement.values();
for (LinkElement value : values) {
LinkElement.elements.put(value.name(), value);
}
}
return LinkElement.elements.get(name.toUpperCase());
}
Example 66
Project: dltk.javascript-master File: StepOverCommand.java View source code |
@Override
void parseAndExecute(String command, HashMap options) {
Object tid = options.get("-i");
this.debugger.runTransctionId = (String) tid;
if (this.debugger.stackmanager.getStackDepth() > 0) {
this.debugger.stackmanager.stepOver();
} else {
synchronized (this.debugger) {
while (!this.debugger.isInited) {
Thread.yield();
}
this.debugger.notify();
}
this.debugger.stackmanager.resume();
}
}
Example 67
Project: DoubanBookLog-master File: DbInfoApi.java View source code |
public static DbInfo getDbInfo(String token) { HashMap<String, String> header = new HashMap<String, String>(); header.put("Authorization", "Bearer " + token); String json = JavaHttpClient.getInstance().doGet(ApiUrlHelper.USER_INFO, header, token); try { return DbInfo.parseJson(new JSONObject(json)); } catch (JSONException e) { e.printStackTrace(); } return null; }
Example 68
Project: dragome-sdk-master File: MapObjectFactory.java View source code |
public Object instantiate(ObjectBinder context, Object value, Type targetType, Class targetClass) { if (targetType != null) { if (targetType instanceof ParameterizedType) { ParameterizedType ptype = (ParameterizedType) targetType; return context.bindIntoMap((Map) value, new HashMap<Object, Object>(), ptype.getActualTypeArguments()[0], ptype.getActualTypeArguments()[1]); } } return context.bindIntoMap((Map) value, new HashMap<Object, Object>(), null, null); }
Example 69
Project: ebean-jdk8-fix-master File: ArgParser.java View source code |
/** * Parse the args returning as name value pairs. */ public static HashMap<String, String> parse(String args) { HashMap<String, String> map = new HashMap<String, String>(); if (args != null) { String[] split = args.split(";"); for (String nameValuePair : split) { String[] nameValue = nameValuePair.split("="); if (nameValue.length == 2) { map.put(nameValue[0].toLowerCase(), nameValue[1]); } } } return map; }
Example 70
Project: ebean-master File: DeployPropertyParserMapTests.java View source code |
@Test
public void test_like_escape() {
Map<String, String> map = new HashMap<>();
map.put("customer.name", "t1.name");
map.put("id", "t0.id");
DeployPropertyParserMap parser = new DeployPropertyParserMap(map);
String output = parser.parse("(lower(customer.name) like ? escape'' or id > ?)");
Assert.assertEquals("(lower(t1.name) like ? escape'' or t0.id > ?)", output);
}
Example 71
Project: edison-microservice-master File: JobsPropertiesTest.java View source code |
@Test
public void shouldNormalizeJobTypes() throws Exception {
// given
final JobsProperties jobsProperties = new JobsProperties();
jobsProperties.getStatus().setCalculator(new HashMap<String, String>() {
{
put("Some Job Type", "foo");
}
});
// when
Map<String, String> calculators = jobsProperties.getStatus().getCalculator();
// then
assertThat(calculators, hasEntry("some-job-type", "foo"));
}
Example 72
Project: elasticsearch-analysis-hebrew-master File: AnalysisHebrewFactoryTests.java View source code |
@Override
protected Map<String, Class<?>> getTokenFilters() {
Map<String, Class<?>> filters = new HashMap<>(super.getTokenFilters());
filters.put("hebrew_lemmatizer", HebrewLemmatizerTokenFilterFactory.class);
filters.put("niqqud", NiqqudFilterTokenFilterFactory.class);
filters.put("add_suffix", AddSuffixTokenFilterFactory.class);
return filters;
}
Example 73
Project: esup-helpdesk-master File: ReloadableResourceBundleMessageSource.java View source code |
public Map<String, String> getStrings(Locale locale) {
Map<String, String> ret = new HashMap<String, String>();
PropertiesHolder propertiesHolder = getMergedProperties(locale);
Properties properties = propertiesHolder.getProperties();
for (Object key : properties.keySet()) {
ret.put((String) key, (String) properties.get(key));
}
return ret;
}
Example 74
Project: fcrepo-master File: RelationshipTupleTests.java View source code |
@Test public void test() throws URISyntaxException { String aliased = "dc:predicate"; String prefixed = "dcmi:predicate"; String absolute = "http://dc.org#predicate"; HashMap<String, String> aliases = new HashMap<String, String>(1); aliases.put("dc", "http://dc.org#"); assertEquals(absolute, RelationshipTuple.makePredicateFromRel(aliased, aliases).toString()); assertEquals(prefixed, RelationshipTuple.makePredicateFromRel(prefixed, aliases).toString()); assertEquals(absolute, RelationshipTuple.makePredicateFromRel(absolute, aliases).toString()); }
Example 75
Project: featherdb-master File: JavaScriptViewFactory.java View source code |
public Map<String, View> buildViews(JSONDocument doc) throws ViewException {
JSONObject viewDefs = doc.getMetaData().getJSONObject("view");
Map<String, View> views = new HashMap<String, View>();
for (String k : viewDefs.keySet()) {
String src = viewDefs.getString(k);
views.put(src, new JavaScriptView(doc.getDatabase(), src));
}
return views;
}
Example 76
Project: FiWare-Template-Handler-master File: MethodExpressionServiceTaskTest.java View source code |
@Deployment
public void testSetServiceResultToProcessVariables() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("okReturningService", new OkReturningService());
ProcessInstance pi = runtimeService.startProcessInstanceByKey("setServiceResultToProcessVariables", variables);
assertEquals("ok", runtimeService.getVariable(pi.getId(), "result"));
}
Example 77
Project: FormDesigner-master File: QueryAndFormData.java View source code |
public static String buildQueryString(HashMap<String, String> queryEntries) {
StringBuffer sb = new StringBuffer();
int i = 0;
for (String key : queryEntries.keySet()) {
String value = queryEntries.get(key);
if (i > 0) {
sb.append("&");
}
// encode the characters in the name
String encodedName = URL.encodeComponent(key);
sb.append(encodedName);
sb.append("=");
// encode the characters in the value
String encodedValue = URL.encodeComponent(value);
sb.append(encodedValue);
i++;
}
return sb.toString();
}
Example 78
Project: fpcms-master File: MapUtilTest.java View source code |
@Test public void test() { Map map = new HashMap(); Map defaultMap = new HashMap(); map.put("username", "badqiu"); map.put("pwd", "123456"); defaultMap.put("username", "jane"); defaultMap.put("blog", "www.blog.com/blog"); MapUtil.mergeWithDefaultMap(map, defaultMap); assertEquals(map.get("username"), "badqiu"); assertEquals(map.toString(), "{pwd=123456, username=badqiu, blog=www.blog.com/blog}"); }
Example 79
Project: freehep-ncolor-pdf-master File: OptionParser.java View source code |
public static Map parseOptions(String options) {
Map hashValues = new HashMap();
if (options != null) {
StringTokenizer st = new StringTokenizer(options, ",;");
while (st.hasMoreTokens()) {
String tk = st.nextToken().toLowerCase().trim();
int pos = tk.indexOf('=');
if (pos < 0)
hashValues.put(tk, "true");
else
hashValues.put(tk.substring(0, pos).trim(), tk.substring(pos + 1).trim());
}
}
return hashValues;
}
Example 80
Project: geoserver-2.0.x-master File: H2DataStoreInitializerTest.java View source code |
public void testDataStoreFactoryInitialized() { HashMap params = new HashMap(); params.put(H2DataStoreFactory.DBTYPE.key, "h2"); params.put(H2DataStoreFactory.DATABASE.key, "test"); DataAccessFactory f = DataStoreUtils.aquireFactory(params); assertNotNull(f); assertTrue(f instanceof H2DataStoreFactory); assertEquals(testData.getDataDirectoryRoot(), ((H2DataStoreFactory) f).getBaseDirectory()); }
Example 81
Project: geoserver-old-master File: H2DataStoreInitializerTest.java View source code |
public void testDataStoreFactoryInitialized() { HashMap params = new HashMap(); params.put(H2DataStoreFactory.DBTYPE.key, "h2"); params.put(H2DataStoreFactory.DATABASE.key, "test"); DataAccessFactory f = DataStoreUtils.aquireFactory(params); assertNotNull(f); assertTrue(f instanceof H2DataStoreFactory); assertEquals(testData.getDataDirectoryRoot(), ((H2DataStoreFactory) f).getBaseDirectory()); }
Example 82
Project: geoserver_trunk-master File: H2DataStoreInitializerTest.java View source code |
public void testDataStoreFactoryInitialized() { HashMap params = new HashMap(); params.put(H2DataStoreFactory.DBTYPE.key, "h2"); params.put(H2DataStoreFactory.DATABASE.key, "test"); DataAccessFactory f = DataStoreUtils.aquireFactory(params); assertNotNull(f); assertTrue(f instanceof H2DataStoreFactory); assertEquals(testData.getDataDirectoryRoot(), ((H2DataStoreFactory) f).getBaseDirectory()); }
Example 83
Project: geowebcache-master File: ArcGISLayerXMLConfigurationProviderTest.java View source code |
@SuppressWarnings("rawtypes")
public void testGetConfiguredXStream() {
final Map<String, Class> aliases = new HashMap<String, Class>();
XStream xs = new ArcGISLayerXMLConfigurationProvider().getConfiguredXStream(new GeoWebCacheXStream() {
@Override
public void alias(String alias, Class c) {
aliases.put(alias, c);
}
});
assertNotNull(xs);
assertEquals(ArcGISCacheLayer.class, aliases.get("arcgisLayer"));
}
Example 84
Project: gocd-build-status-notifier-master File: ConfigurationUtils.java View source code |
public static Map<String, Object> createField(String displayName, String defaultValue, boolean isRequired, boolean isSecure, String displayOrder) {
Map<String, Object> fieldProperties = new HashMap<String, Object>();
fieldProperties.put("display-name", displayName);
fieldProperties.put("default-value", defaultValue);
fieldProperties.put("required", isRequired);
fieldProperties.put("secure", isSecure);
fieldProperties.put("display-order", displayOrder);
return fieldProperties;
}
Example 85
Project: Grapes-master File: JongoUtilsTest.java View source code |
@Test public void generateJongoQuery() { Map<String, Object> params = new HashMap<String, Object>(); params.put("key1", "value1"); params.put("key2", "value2"); assertEquals("{}", JongoUtils.generateQuery(new HashMap<String, Object>())); assertEquals("{key1: 'value1'}", JongoUtils.generateQuery("key1", "value1")); assertEquals("{key1: 1}", JongoUtils.generateQuery("key1", 1)); assertEquals("{key1: true}", JongoUtils.generateQuery("key1", true)); assertEquals("{key2: 'value2', key1: 'value1'}", JongoUtils.generateQuery(params)); }
Example 86
Project: gson-fire-master File: CachedReflectionFactoryTest.java View source code |
@Test public void get() throws Exception { CachedReflectionFactory factory = new CachedReflectionFactory(); Object obj1 = factory.get(Object.class); Object obj2 = factory.get(Object.class); Object obj3 = factory.get(HashMap.class); //Test cache assertTrue(obj1 == obj2); assertTrue(obj1 != obj3); //Test type of objects assertTrue(obj1.getClass() == Object.class); assertTrue(obj3.getClass() == HashMap.class); }
Example 87
Project: guide-master File: Lambda5.java View source code |
//Pre-Defined Functional Interfaces public static void main(String... args) { //BiConsumer Example BiConsumer<String, Integer> printKeyAndValue = ( key, value) -> System.out.println(key + "-" + value); printKeyAndValue.accept("One", 1); printKeyAndValue.accept("Two", 2); System.out.println("##################"); //Java Hash-Map foreach supports BiConsumer HashMap<String, Integer> dummyValues = new HashMap<>(); dummyValues.put("One", 1); dummyValues.put("Two", 2); dummyValues.put("Three", 3); dummyValues.forEach(( key, value) -> System.out.println(key + "-" + value)); }
Example 88
Project: gyz-master File: HttpUtil.java View source code |
public static Map<String, Object> getResult(boolean success, Object data, int count, String errorMessage) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("success", success);
if (data != null) {
result.put("data", data);
}
result.put("count", count);
if (errorMessage != null) {
result.put("msg", errorMessage);
}
return result;
}
Example 89
Project: hazelcast-code-samples-master File: BrokenKeyMember.java View source code |
public static void main(String[] args) {
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
Map<Pair, String> normalMap = new HashMap<Pair, String>();
Map<Pair, String> hzMap = hz.getMap("map");
Pair key1 = new Pair("a", "1");
Pair key2 = new Pair("a", "2");
normalMap.put(key1, "foo");
hzMap.put(key1, "foo");
System.out.println("normalMap.get: " + normalMap.get(key2));
System.out.println("hzMap.get: " + hzMap.get(key2));
System.exit(0);
}
Example 90
Project: hebo-master File: Granularity.java View source code |
public String toField() {
Map<Granularity, String> map = new HashMap<Granularity, String>() {
{
put(Granularity.YEARLY, "?year");
put(Granularity.MONTHLY, "?month");
put(Granularity.HOURLY, "?hour");
put(Granularity.MINUTELY, "?minute");
}
};
return map.get(this);
}
Example 91
Project: Heyzap-ANE-master File: ExtensionContext.java View source code |
@Override
public Map<String, FREFunction> getFunctions() {
Map<String, FREFunction> functionMap = new HashMap<String, FREFunction>();
functionMap.put("load", new LoadFunction());
functionMap.put("checkin", new CheckinFunction());
functionMap.put("isSupported", new IsSupportedFunction());
functionMap.put("submitScore", new SubmitScoreFunction());
functionMap.put("showLeaderboards", new ShowLeaderboardsFunction());
return functionMap;
}
Example 92
Project: HockeySDK-Android-master File: HttpURLConnectionBuilderTest.java View source code |
@Test(expected = IllegalArgumentException.class)
public void testFormFieldSizeLimit() {
String mockString = new String(new char[(4 * 1024 * 1024) + 1]).replace('\0', ' ');
HttpURLConnectionBuilder builder = new HttpURLConnectionBuilder(TEST_URL);
builder.setRequestMethod("POST");
Map<String, String> fields = new HashMap<>();
fields.put("test", mockString);
builder.writeFormFields(fields);
}
Example 93
Project: HUSACCT-master File: ExternalCodeviewerImpl.java View source code |
@Override
public void displayErrorsInFile(String fileName, HashMap<Integer, Severity> errors) {
String location = "";
location = ConfigurationManager.getProperty("IDELocation");
switch(OSDetector.getOS()) {
case LINUX:
break;
case MAC:
break;
case WINDOWS:
try {
Runtime.getRuntime().exec(location + " --launcher.openFile \"" + fileName + "\"");
} catch (IOException e) {
e.printStackTrace();
}
break;
}
}
Example 94
Project: idea-php-symfony2-plugin-master File: DoctrineTypes.java View source code |
public static Map<Manager, String> getManagerInstanceMap() {
Map<Manager, String> managerMap = new HashMap<>();
managerMap.put(Manager.ORM, "\\Doctrine\\ORM\\EntityManager");
managerMap.put(Manager.MONGO_DB, "\\Doctrine\\ODM\\MongoDB\\DocumentManager");
managerMap.put(Manager.COUCH_DB, "\\Doctrine\\ODM\\CouchDB\\DocumentManager");
return managerMap;
}
Example 95
Project: intellij-community-master File: IDEA136401.java View source code |
void foo(Stream<String> pairStream) { Map<String, Map<String, Integer>> frequencyMap = pairStream.collect(Collectors.toMap( p -> p, p -> of(p, 1), ( m1, m2) -> new HashMap<>(m1))); Map<String, Map<String, Integer>> frequencyMap1 = pairStream.collect(Collectors.toMap( p -> p, p -> of(p, 1), ( m1, m2) -> new HashMap<>())); }
Example 96
Project: ismp_manager-master File: HttpMonitorTest.java View source code |
public static void main(String[] args) {
MonitorTest test = new MonitorTest();
test.setIpAddr("www.qidian.com");
test.setClassName("org.infosec.ismp.poller.monitor.http.HttpMonitor");
Map parameters = new HashMap();
parameters.put("port", "80");
parameters.put("url", "http://www.qidian.com");
test.setParameters(parameters);
test.test();
}
Example 97
Project: JamVM-PH-master File: AddLs.java View source code |
public static void main(String[] args) {
if (addrListByName == null) {
addrListByName = new HashMap<String, Address>();
}
if (args.length >= 2) {
addrListByName.put(args[0], new Address(args[0], args[1]));
}
for (Map.Entry<String, Address> entry : addrListByName.entrySet()) {
Address addr = (Address) entry.getValue();
System.out.println("Name: " + addr.getName());
System.out.println("Phone Number: " + addr.getPhoneNumber());
}
}
Example 98
Project: java-concurrency-torture-master File: Environment.java View source code |
public static Map<String, String> getEnvironment() {
Map<String, String> result = new HashMap<String, String>();
String[] keys = new String[] { "java.version", "java.vendor", "java.vm.version", "java.vm.vendor", "java.vm.name", "java.specification.version", "java.specification.vendor", "java.specification.name", "os.name", "os.arch", "os.version" };
for (String key : keys) {
result.put(key, System.getProperty(key));
}
return result;
}
Example 99
Project: java8-tutorial-master File: Lambda5.java View source code |
//Pre-Defined Functional Interfaces public static void main(String... args) { //BiConsumer Example BiConsumer<String, Integer> printKeyAndValue = ( key, value) -> System.out.println(key + "-" + value); printKeyAndValue.accept("One", 1); printKeyAndValue.accept("Two", 2); System.out.println("##################"); //Java Hash-Map foreach supports BiConsumer HashMap<String, Integer> dummyValues = new HashMap<>(); dummyValues.put("One", 1); dummyValues.put("Two", 2); dummyValues.put("Three", 3); dummyValues.forEach(( key, value) -> System.out.println(key + "-" + value)); }
Example 100
Project: JavalibCore-master File: AnnotationKeywordFactoryIntegrationTest.java View source code |
@Override
protected void setUp() throws Exception {
annotationKeywordFactory = new AnnotationKeywordFactory(new HashMap() {
{
put("keywordBean", new Object() {
@SuppressWarnings("unused")
@RobotKeyword
public void someKeyword() {
}
});
}
});
}
Example 101
Project: jenkow-plugin-master File: MethodExpressionServiceTaskTest.java View source code |
@Deployment
public void testSetServiceResultToProcessVariables() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("okReturningService", new OkReturningService());
ProcessInstance pi = runtimeService.startProcessInstanceByKey("setServiceResultToProcessVariables", variables);
assertEquals("ok", runtimeService.getVariable(pi.getId(), "result"));
}