List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:info.archinnov.achilles.internals.parser.validator.BeanValidator.java
public static void validateNoDuplicateNames(AptUtils aptUtils, TypeName rawClassType, List<TypeParsingResult> parsingResults) { Map<String, String> mapping = new HashMap<>(); parsingResults.stream().map(x -> x.context).forEach(context -> { final String fieldName = context.fieldName; final String cqlColumn = context.cqlColumn; if (mapping.containsKey(fieldName)) { aptUtils.printError("The class '%s' already contains a field with name '%s'", rawClassType, fieldName);// w w w. j ava 2s . com } else if (mapping.containsValue(cqlColumn)) { aptUtils.printError("The class '%s' already contains a cql column with name '%s'", rawClassType, cqlColumn); } else { mapping.put(fieldName, cqlColumn); } }); }
From source file:com.ms.commons.cookie.parser.CookieParser.java
/** * <pre>/*from ww w . j av a 2s. co m*/ * ?questCookieCookie?{@link CookieNameEnum}Key,{@link CookieNameHelper}ValueMap * {@link CookieNameHelper}?{@link CookieNameEnum}{@link CookieKeyEnum} * @return Request CookieemptyMap * </pre> */ public static Map<CookieNameEnum, CookieNameHelper> loadCookie(HttpServletRequest request) { // Map Map<CookieNameEnum, CookieNameHelper> allValues = new HashMap<CookieNameEnum, CookieNameHelper>(); // Cookie Map<String, String> cookieKV = CookieUtils.arrayToMap(request.getCookies()); // ?CookieName?? for (CookieNameEnum cookieName : CookieNameEnum.values()) { // ?CookieName?? CookieNameConfig cookieNameConfig = CookieNamePolicyParser.getCookieNamePolicyMap().get(cookieName); boolean isCookieExisted = cookieKV.containsKey(cookieNameConfig.getCookieName()); if (isCookieExisted) { String value = cookieKV.get(cookieName.getCookieName()); CookieNameHelper cookieNameHelper = paserCookieValue(cookieNameConfig, value); // ? if (cookieNameHelper != null) { allValues.put(cookieName, cookieNameHelper); } } } return allValues; }
From source file:com.streamsets.pipeline.stage.origin.spooldir.TestOffsetUtil.java
static void compare(String offsetV1, Map<String, String> offsetV2, boolean removeAbsolutePaths) { try {//from w ww .j av a 2s.c om Offset offset = new Offset(VERSION_ONE, offsetV1); offsetV2.remove(OFFSET_VERSION); if (removeAbsolutePaths) { offsetV2 = removeAbsolutePaths(offsetV2); } Assert.assertTrue(String.format("offset does not contain file: %s", offset.getFile()), offsetV2.containsKey(offset.getFile())); Assert.assertEquals(offset.getOffset(), OffsetUtil.deserializeOffsetMap(offsetV2.get(offset.getFile())).get(POS)); Assert.assertEquals(offset.getOffsetString(), offsetV2.get(offset.getFile())); } catch (Exception ex) { Assert.fail(ex.toString()); } }
From source file:org.apache.servicemix.camel.nmr.ws.addressing.WSAddressingTest.java
protected static String verifyMAPs(AddressingProperties maps, Object checkPoint) { if (maps == null) { return "expected MAPs"; }// ww w . j a v a 2 s . c om String id = maps.getMessageID().getValue(); if (id == null) { return "expected MessageID MAP"; } if (!id.startsWith("urn:uuid")) { return "bad URN format in MessageID MAP: " + id; } // ensure MessageID is unique for this check point Map<String, String> checkPointMessageIDs = messageIDs.get(checkPoint); if (checkPointMessageIDs != null) { if (checkPointMessageIDs.containsKey(id)) { // return "MessageID MAP duplicate: " + id; return null; } } else { checkPointMessageIDs = new HashMap<String, String>(); messageIDs.put(checkPoint, checkPointMessageIDs); } checkPointMessageIDs.put(id, id); // To if (maps.getTo() == null) { return "expected To MAP"; } return null; }
From source file:net.sf.jasperreports.customvisualization.export.CVElementJsonHandler.java
/** * Clean the configuration object./*from www . j a v a 2 s . c o m*/ * * This function removes objects in the configuration map that are not * convertible in JSON (script object and design element). It also adds some * useful properties for the element such as width, height and all the * elements properties in form of property.xyz * * * @param configuration * @return */ public static Map<String, Object> createConfigurationForJSON(Map<String, Object> configuration, HtmlResourceHandler htmlResourceHandler) { Map<String, Object> jsonConfiguration = new HashMap<>(); JRTemplateGenericPrintElement element = (JRTemplateGenericPrintElement) configuration.get("element"); if (configuration.containsKey("series")) { jsonConfiguration.put("series", configuration.get("series")); } if (element != null) { jsonConfiguration.put(Processor.CONF_WIDTH, element.getWidth()); jsonConfiguration.put(Processor.CONF_HEIGHT, element.getHeight()); for (String prop : element.getPropertiesMap().getPropertyNames()) { jsonConfiguration.put("property." + prop, element.getPropertiesMap().getProperty(prop)); configuration.put("property." + prop, element.getPropertiesMap().getProperty(prop)); } jsonConfiguration.put("id", CVUtils.getElementId(element)); if (element.getParameterValue(CVPrintElement.SCRIPT_URI) != null) { String scriptLocation = getResourceURL( (String) element.getParameterValue(CVPrintElement.SCRIPT_URI), htmlResourceHandler); configuration.put(CVPrintElement.SCRIPT_URI, scriptLocation); } if (element.getParameterValue(CVPrintElement.CSS_URI) != null) { String cssLocation = getResourceURL((String) element.getParameterValue(CVPrintElement.CSS_URI), htmlResourceHandler); configuration.put(CVPrintElement.CSS_URI, cssLocation); } } // Add all the items properties... for (String itemPropertyKey : configuration.keySet()) { Object value = configuration.get(itemPropertyKey); if (itemPropertyKey == null || itemPropertyKey.isEmpty() || itemPropertyKey.equals("element") || itemPropertyKey.equals("series")) { continue; } if (value != null) { jsonConfiguration.put(itemPropertyKey, value.toString()); } } return jsonConfiguration; }
From source file:de.nava.informa.utils.ParserUtils.java
/** * Converts names of child-tags mentioned in <code>childrenNames</code> list * to that given case./*from w w w .ja v a 2s . com*/ * * @param root root element. * @param childrenNames names of child tags to convert. */ public static void matchCaseOfChildren(Element root, String[] childrenNames) { if (root == null || childrenNames.length == 0) return; // Prepare list of names int namesCount = childrenNames.length; Map<String, String> names = new HashMap<>(namesCount); for (String childName : childrenNames) { if (childName != null) { String lower = childName.toLowerCase(); if (!names.containsKey(lower)) names.put(lower, childName); } } // Walk through the children elements List elements = root.getChildren(); for (Object element : elements) { Element child = (Element) element; String childName = child.getName().toLowerCase(); if (names.containsKey(childName)) child.setName(names.get(childName)); } }
From source file:de.ingrid.iplug.ckan.utils.ScriptEngine.java
/** * Execute the given scripts with the given parameters * @param scripts The script files//from w w w . j av a 2s . c o m * @param parameters The parameters * @param compile Boolean indicating whether to compile the script or not * @return Map with the absolute paths of the scripts as keys and the execution results as values * If an execution returns null, the result will not be added * @throws Exception */ public static Map<String, Object> execute(Resource[] scripts, Map<String, Object> parameters, boolean compile) throws Exception { Map<Integer, Bindings> bindings = new Hashtable<Integer, Bindings>(); Map<String, Object> results = new Hashtable<String, Object>(); for (Resource script : scripts) { // get the engine for the script javax.script.ScriptEngine engine = getEngine(script); // initialize/get the bindings if (!bindings.containsKey(engine.hashCode())) { Bindings newBindings = engine.createBindings(); newBindings.putAll(parameters); bindings.put(engine.hashCode(), newBindings); } Bindings curBindings = bindings.get(engine.hashCode()); // execute the script CompiledScript compiledScript = null; Object result = null; if (compile && (compiledScript = getCompiledScript(script)) != null) { result = compiledScript.eval(curBindings); } else { result = engine.eval(new InputStreamReader(script.getInputStream()), curBindings); } if (result != null) { results.put(script.getFilename(), result); } } return results; }
From source file:vrisini.cordova.plugin.schedule.Schedule.java
/** * Checks wether a notification with an ID is scheduled. * * @param id/* w ww . j a va 2 s . c o m*/ * The notification ID to be check. * @param callbackContext */ public static void isScheduled(String id, CallbackContext callbackContext) { SharedPreferences settings = getSharedPreferences(); Map<String, ?> alarms = settings.getAll(); boolean isScheduled = alarms.containsKey(id); PluginResult result = new PluginResult(PluginResult.Status.OK, isScheduled); callbackContext.sendPluginResult(result); }
From source file:com.opengamma.analytics.financial.interestrate.InterestRateCurveSensitivityUtils.java
/** * Compare two maps of sensitivities with a given tolerance. The tolerance is used for both the time and the value. The two sensitivities are suppose to be in the same time order. * @param sensi1 The first sensitivity (as a map). * @param sensi2 The second sensitivity (as a map). * @param tolerance The tolerance.//from w ww . j a va 2 s . co m * @return True if the difference is below the tolerance and False if not. If the curves are not the same it returns False. */ public static boolean compare(final Map<String, List<DoublesPair>> sensi1, final Map<String, List<DoublesPair>> sensi2, final double tolerance) { Validate.notNull(sensi1, "sensitivity"); Validate.notNull(sensi2, "sensitivity"); for (final String name : sensi1.keySet()) { if (sensi2.containsKey(name)) { if (!compare(sensi1.get(name), sensi2.get(name), tolerance)) { return false; } } else { return false; } } for (final String name : sensi2.keySet()) { if (!(sensi1.containsKey(name))) { return false; } } return true; }
From source file:org.eclipse.sw360.datahandler.common.SW360Utils.java
public static String displayNameFor(String name, Map<String, String> nameToDisplayName) { return nameToDisplayName.containsKey(name) ? nameToDisplayName.get(name) : name; }