List of usage examples for java.util Map isEmpty
boolean isEmpty();
From source file:com.microsoft.Malmo.Utils.TextureHelper.java
public static void setMiscTextureColours(Map<String, Integer> miscColours) { if (miscColours == null || miscColours.isEmpty()) miscTexturesToColours = null;/*from w w w. ja v a 2s.co m*/ else miscTexturesToColours = miscColours; texturesToColours.clear(); }
From source file:de.weltraumschaf.jebnf.ast.visitor.XmlVisitor.java
/** * Creates a opening tag string by name. * * @param name The tag name./*from w w w . j av a 2 s. co m*/ * @param attributes Optional tag attributes. * @param block Whether the tag is in line or block. * @return Returns formatted tag string. */ public static String createOpenTag(final String name, final Map<NodeAttribute, String> attributes, final boolean block) { final StringBuilder tag = new StringBuilder(); tag.append('<').append(name); if (null != attributes && !attributes.isEmpty()) { for (Map.Entry<NodeAttribute, String> attribute : attributes.entrySet()) { tag.append(String.format(" %s=\"%s\"", attribute.getKey().toString().toLowerCase(), StringEscapeUtils.escapeXml(attribute.getValue()))); } } if (!block) { tag.append('/'); } return tag.append('>').toString(); }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditN3Generator.java
public static List<String> subInUris(Map<String, String> varsToVals, List<String> targets) { if (varsToVals == null || varsToVals.isEmpty()) return targets; ArrayList<String> outv = new ArrayList<String>(); for (String target : targets) { String temp = target;/*from ww w . j a va2s .co m*/ for (String key : varsToVals.keySet()) { temp = subInUris(key, varsToVals.get(key), temp); } outv.add(temp); } return outv; }
From source file:org.terasoluna.gfw.web.el.Functions.java
/** * build query string from map.// w w w .j ava 2 s .c o m * <p> * query string is encoded with "UTF-8". * </p> * @see ObjectToMapConverter * @param map map * @return query string. if map is not empty, return query string. ex) name1=value&name2=value&... */ public static String mapToQuery(Map<String, Object> map) { if (map == null || map.isEmpty()) { return ""; } UriComponentsBuilder builder = UriComponentsBuilder.fromPath(""); for (Map.Entry<String, Object> e : map.entrySet()) { String name = e.getKey(); Object value = e.getValue(); builder.queryParam(name, value); } String query = builder.build().encode().toString(); // remove the beginning symbol character('?') of the query string. return query.substring(1); }
From source file:org.bigtester.ate.GlobalUtils.java
/** * Find data source bean./* www . ja v a 2s . c o m*/ * * @param appCtx * the app ctx * @return the data source * @throws NoSuchBeanDefinitionException * the no such bean definition exception */ public static DataSource findDataSourceBean(ApplicationContext appCtx) throws NoSuchBeanDefinitionException { Map<String, DataSource> testcases = appCtx.getBeansOfType(DataSource.class); if (testcases.isEmpty()) { throw new NoSuchBeanDefinitionException(DataSource.class); } else { DataSource dataSource = testcases.values().iterator().next(); if (null == dataSource) { throw new NoSuchBeanDefinitionException(DataSource.class); } else { return dataSource; } } }
From source file:com.amazon.pay.impl.Util.java
/** * This method uses HttpURLConnection instance to make requests. * * @param method The HTTP method (GET,POST,PUT,etc.). * @param url The URL// ww w . j a v a 2 s .c om * @param urlParameters URL Parameters * @param headers Header key-value pairs * @return ResponseData * @throws IOException */ public static ResponseData httpSendRequest(String method, String url, String urlParameters, Map<String, String> headers) throws IOException { URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); if (headers != null && !headers.isEmpty()) { for (String key : headers.keySet()) { con.setRequestProperty(key, headers.get(key)); } } con.setDoOutput(true); con.setRequestMethod(method); if (urlParameters != null) { DataOutputStream wr = new DataOutputStream(con.getOutputStream()); wr.writeBytes(urlParameters); wr.flush(); wr.close(); } int responseCode = con.getResponseCode(); BufferedReader in; if (responseCode != 200) { in = new BufferedReader(new InputStreamReader(con.getErrorStream())); } else { in = new BufferedReader(new InputStreamReader(con.getInputStream())); } String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine).append(LINE_SEPARATOR); } in.close(); return new ResponseData(responseCode, response.toString()); }
From source file:org.bigtester.ate.GlobalUtils.java
/** * Find data source bean.//from w w w . j a v a 2 s .c o m * * @param appCtx * the app ctx * @return the data source * @throws NoSuchBeanDefinitionException * the no such bean definition exception */ public static IMyWebDriver findMyWebDriver(ApplicationContext appCtx) throws NoSuchBeanDefinitionException { Map<String, IMyWebDriver> drivers = appCtx.getBeansOfType(IMyWebDriver.class); if (drivers.isEmpty()) { throw new NoSuchBeanDefinitionException(DataSource.class); } else { IMyWebDriver retDriver = drivers.values().iterator().next(); if (null == retDriver) { throw new NoSuchBeanDefinitionException(DataSource.class); } else { return retDriver; } } }
From source file:com.adnature.framework.web.util.Struts2Utils.java
/** * ??Request//from w w w.j a v a2 s. co m * @param prefix ?? */ public static void fillSearchParams(String prefix) { if (StringUtils.isBlank(prefix)) { return; } HttpServletRequest request = getRequest(); Map<String, Object> parmMap = new HashMap<String, Object>(); // request??????,?????Map Map<String, Object> filterParamMap = WebUtils.getParametersStartingWith(request, prefix + "#filter_"); if (filterParamMap != null && !filterParamMap.isEmpty()) { for (Entry<String, Object> entry : filterParamMap.entrySet()) { String filterName = entry.getKey(); String value = ((String) entry.getValue()).trim().replaceAll("\"", """); value = value.replaceAll("<", "<"); value = value.replaceAll(">", ">"); // value,filter. boolean omit = StringUtils.isBlank(value); if (!omit) { request.setAttribute("filter_" + filterName, value); parmMap.put("filter_" + filterName, value); } } // request.setAttribute(HibernateWebUtils.SEARCH_KEY, parmMap); request.setAttribute(prefix, parmMap); } }
From source file:org.bigtester.ate.GlobalUtils.java
/** * Find test project bean./*from ww w . j a v a 2s . com*/ * * @param appCtx * the app ctx * @return the test project * @throws NoSuchBeanDefinitionException * the no such bean definition exception */ public static TestProject findTestProjectBean(ApplicationContext appCtx) throws NoSuchBeanDefinitionException { Map<String, TestProject> testProjects = appCtx.getBeansOfType(TestProject.class); if (testProjects.isEmpty()) { throw new NoSuchBeanDefinitionException(TestProject.class); } else { TestProject testProject = testProjects.values().iterator().next(); if (null == testProject) { throw new NoSuchBeanDefinitionException(TestProject.class); } else { return testProject; } } }
From source file:gov.nij.processor.MessageProcessor.java
/** * This method will set the WS-Addressing Message Properties on the exchange prior to sending an outbound CXF message. * It allows for 'MessageID' and 'ReplyTo' * /*from w ww .j av a 2s . c o m*/ * @param senderExchange * @param requestID * @return * @throws Exception */ public static Map<String, Object> setWSAddressingProperties(Map<String, String> wsAddressingMessageProperties) throws Exception { Map<String, Object> requestContext = null; if (!wsAddressingMessageProperties.isEmpty()) { // get Message Addressing Properties instance AddressingProperties maps = new AddressingProperties(); String messageID = wsAddressingMessageProperties.get("MessageID"); if (StringUtils.isNotEmpty(messageID)) { // set MessageID property AttributedURIType messageIDAttr = WSA_OBJECT_FACTORY.createAttributedURIType(); messageIDAttr.setValue(messageID); maps.setMessageID(messageIDAttr); } String replyToString = wsAddressingMessageProperties.get("ReplyTo"); if (StringUtils.isNotEmpty(replyToString)) { AttributedURIType replyToAttr = new AttributedURIType(); replyToAttr.setValue(replyToString); EndpointReferenceType replyToRef = new EndpointReferenceType(); replyToRef.setAddress(replyToAttr); maps.setReplyTo(replyToRef); } requestContext = new HashMap<String, Object>(); requestContext.put(CLIENT_ADDRESSING_PROPERTIES, maps); } else { throw new Exception("WS-Addressing Message Properties can not be set. Map is empty."); } return requestContext; }