List of usage examples for org.apache.commons.lang3 StringUtils equalsIgnoreCase
public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2)
Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.
null s are handled without exceptions.
From source file:com.nridge.core.base.io.xml.DocumentXML.java
private Document loadDocument(Element anElement) throws IOException { Node nodeItem;/* ww w. j a v a2s .c om*/ Attr nodeAttr; Document document; Element nodeElement; String nodeName, nodeValue; String docName = anElement.getAttribute("name"); String typeName = anElement.getAttribute("type"); String docTitle = anElement.getAttribute("title"); String schemaVersion = anElement.getAttribute("schemaVersion"); if ((StringUtils.isNotEmpty(typeName)) && (StringUtils.isNotEmpty(schemaVersion))) document = new Document(typeName); else document = new Document("Unknown"); if (StringUtils.isNotEmpty(docName)) document.setName(docName); if (StringUtils.isNotEmpty(docTitle)) document.setName(docTitle); NamedNodeMap namedNodeMap = anElement.getAttributes(); int attrCount = namedNodeMap.getLength(); for (int attrOffset = 0; attrOffset < attrCount; attrOffset++) { nodeAttr = (Attr) namedNodeMap.item(attrOffset); nodeName = nodeAttr.getNodeName(); nodeValue = nodeAttr.getNodeValue(); if (StringUtils.isNotEmpty(nodeValue)) { if ((StringUtils.equalsIgnoreCase(nodeName, "name")) || (StringUtils.equalsIgnoreCase(nodeName, "type")) || (StringUtils.equalsIgnoreCase(nodeName, "title")) || (StringUtils.equalsIgnoreCase(nodeName, "schemaVersion"))) continue; else document.addFeature(nodeName, nodeValue); } } NodeList nodeList = anElement.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { nodeItem = nodeList.item(i); if (nodeItem.getNodeType() != Node.ELEMENT_NODE) continue; nodeName = nodeItem.getNodeName(); if (StringUtils.equalsIgnoreCase(nodeName, IO.XML_TABLE_NODE_NAME)) { nodeElement = (Element) nodeItem; DataTableXML dataTableXML = new DataTableXML(); dataTableXML.load(nodeElement); document.setTable(dataTableXML.getTable()); } else if (StringUtils.equalsIgnoreCase(nodeName, IO.XML_RELATED_NODE_NAME)) { nodeElement = (Element) nodeItem; loadRelated(document, nodeElement); } else if (StringUtils.equalsIgnoreCase(nodeName, IO.XML_ACL_NODE_NAME)) { nodeElement = (Element) nodeItem; loadACL(document, nodeElement); } } return document; }
From source file:com.erudika.para.core.User.java
/** * Checks for admin rights/*from w ww.j a va 2 s . com*/ * @return true if user has admin rights */ @JsonIgnore public boolean isAdmin() { return StringUtils.equalsIgnoreCase(this.groups, Groups.ADMINS.toString()); }
From source file:com.glaf.jbpm.container.ProcessContainer.java
/** * //from w w w . ja va 2 s . c om * * @param actorId * @param rows * @return */ public List<TaskItem> filter(String actorId, List<TaskItem> rows) { List<Agent> agents = this.getAgents(actorId); logger.debug(agents); List<TaskItem> taskItems = new java.util.ArrayList<TaskItem>(); if (rows != null && rows.size() > 0) { Iterator<TaskItem> iter = rows.iterator(); while (iter.hasNext()) { TaskItem item = iter.next(); // logger.debug(item.getProcessDescription() + "\t" // + item.getTaskDescription() + "\t" + item.getActorId()); /** * ? */ if (StringUtils.equals(actorId, item.getActorId())) { taskItems.add(item); } else if (StringUtils.contains(item.getActorId(), actorId)) { List<String> actorIds = StringTools.split(item.getActorId()); if (actorIds != null && actorIds.contains(actorId)) { taskItems.add(item); } } else { if (agents != null && agents.size() > 0) { Iterator<Agent> it = agents.iterator(); while (it.hasNext()) { Agent agent = it.next(); if (!agent.isValid()) { continue; } /** * ??? */ if (!StringUtils.equals(item.getActorId(), agent.getAssignFrom())) { continue; } switch (agent.getAgentType()) { case 0:// ? taskItems.add(item); break; case 1:// ?? if (StringUtils.equalsIgnoreCase(agent.getProcessName(), item.getProcessName())) { taskItems.add(item); } break; case 2:// ?? if (StringUtils.equalsIgnoreCase(agent.getProcessName(), item.getProcessName()) && StringUtils.equalsIgnoreCase(agent.getTaskName(), item.getTaskName())) { taskItems.add(item); } break; default: break; } } } } } } return taskItems; }
From source file:com.inkubator.hrm.web.approval.ApprovalDefinitionPopupFormController.java
public void onBehalfAppoverChange() { String apporverType = approvalDefinitionModel.getOnBehalfType(); if (StringUtils.equalsIgnoreCase(apporverType, HRMConstant.APPROVAL_TYPE_INDIVIDUAL)) { onBehalfApproverTypeIndividual = Boolean.FALSE; onBehalfApproverTypePosition = Boolean.TRUE; } else if (StringUtils.equalsIgnoreCase(apporverType, HRMConstant.APPROVAL_TYPE_DEPARTMENT)) { onBehalfApproverTypeIndividual = Boolean.TRUE; onBehalfApproverTypePosition = Boolean.TRUE; } else if (StringUtils.equalsIgnoreCase(apporverType, HRMConstant.APPROVAL_TYPE_POSITION)) { onBehalfApproverTypeIndividual = Boolean.TRUE; onBehalfApproverTypePosition = Boolean.FALSE; } else {//from www . j av a2 s .c om onBehalfApproverTypeIndividual = Boolean.TRUE; onBehalfApproverTypePosition = Boolean.TRUE; } approvalDefinitionModel.setHrmUserByOnBehalfIndividual(null); approvalDefinitionModel.setJabatanByOnBehalfPosition(null); }
From source file:com.erudika.para.core.User.java
/** * Checks for moderator rights// w ww. java 2s . com * @return true if user has mod rights */ @JsonIgnore public boolean isModerator() { return isAdmin() ? true : StringUtils.equalsIgnoreCase(this.groups, Groups.MODS.toString()); }
From source file:com.glaf.chart.web.springmvc.HighChartsController.java
@ResponseBody @RequestMapping("/json") public byte[] json(HttpServletRequest request, ModelMap modelMap) throws IOException { RequestUtils.setRequestParameterToAttribute(request); Map<String, Object> params = RequestUtils.getParameterMap(request); String chartId = ParamUtils.getString(params, "chartId"); String mapping = ParamUtils.getString(params, "mapping"); String mapping_enc = ParamUtils.getString(params, "mapping_enc"); String name = ParamUtils.getString(params, "name"); String name_enc = ParamUtils.getString(params, "name_enc"); Chart chart = null;// w w w . j a v a 2s . c o m if (StringUtils.isNotEmpty(chartId)) { chart = chartService.getChart(chartId); } else if (StringUtils.isNotEmpty(name)) { chart = chartService.getChartByName(name); } else if (StringUtils.isNotEmpty(name_enc)) { String str = RequestUtils.decodeString(name_enc); chart = chartService.getChartByName(str); } else if (StringUtils.isNotEmpty(mapping)) { chart = chartService.getChartByMapping(mapping); } else if (StringUtils.isNotEmpty(mapping_enc)) { String str = RequestUtils.decodeString(mapping_enc); chart = chartService.getChartByMapping(str); } JSONArray result = new JSONArray(); if (chart != null) { ChartDataManager manager = new ChartDataManager(); chart = manager.getChartAndFetchDataById(chart.getId(), params, RequestUtils.getActorId(request)); logger.debug("chart rows size:" + chart.getColumns().size()); request.setAttribute("chart", chart); List<ColumnModel> columns = chart.getColumns(); if (columns != null && !columns.isEmpty()) { double total = 0D; if (StringUtils.equalsIgnoreCase(chart.getChartType(), "pie")) { for (ColumnModel cm : columns) { total += cm.getDoubleValue(); } } for (ColumnModel cm : columns) { JSONObject json = new JSONObject(); json.put("category", cm.getCategory()); json.put("series", cm.getSeries()); json.put("doublevalue", cm.getDoubleValue()); if (StringUtils.equalsIgnoreCase(chart.getChartType(), "pie")) { json.put("category", cm.getSeries()); json.put("value", Math.round(cm.getDoubleValue() / total * 10000) / 100.0D); } else { json.put("value", cm.getDoubleValue()); } result.add(json); } } } logger.debug("json:" + result.toJSONString()); return result.toJSONString().getBytes("UTF-8"); }
From source file:com.google.dart.tools.core.utilities.io.FileUtilities.java
/** * If the file with given path exists, and its canonical path differs from the given path only in * case, return the path with the same case as the {@link File} in the file system. * <p>/*from w ww .ja v a 2s . c o m*/ * According to specification it is OK to use a different case in URI, as long as embedding allows * this. But Eclipse LTK (refactoring framework) is not happy. We need to convert such URI to * canonical, at least during refactoring. */ public static String getFileSystemCase(String path) { File file = new File(path); if (file.exists()) { try { String absolutePath = file.getAbsolutePath(); String canonicalPath = file.getCanonicalPath(); if (StringUtils.equalsIgnoreCase(absolutePath, canonicalPath)) { return canonicalPath; } } catch (Throwable e) { } } return path; }
From source file:com.bekwam.resignator.model.ConfigurationDataSourceImpl.java
@Override public boolean profileExists(String profileName) { boolean exists = false; if (configuration.isPresent()) { for (Profile p : configuration.get().getProfiles()) { if (StringUtils.equalsIgnoreCase(p.getProfileName(), profileName)) { exists = true;// w ww . jav a 2s. c om break; } } } return exists; }
From source file:com.hybris.mobile.lib.commerce.data.product.ProductBase.java
public boolean isOutOfStock() { return stock != null && stock.getStockLevelStatus() != null && StringUtils .equalsIgnoreCase(stock.getStockLevelStatus(), StockLevelEnum.OUT_OF_STOCK.getStatus()); }
From source file:com.ottogroup.bi.asap.repository.ComponentClassloader.java
/** * Initializes the class loader by pointing it to folder holding managed JAR files * @param componentFolder// www .j av a 2 s .com * @param componentJarIdentifier file to search for in component JAR which identifies it as component JAR * @throws IOException * @throws RequiredInputMissingException */ public void initialize(final String componentFolder, final String componentJarIdentifier) throws IOException, RequiredInputMissingException { /////////////////////////////////////////////////////////////////// // validate input if (StringUtils.isBlank(componentFolder)) throw new RequiredInputMissingException("Missing required value for parameter 'componentFolder'"); File folder = new File(componentFolder); if (!folder.isDirectory()) throw new IOException("Provided input '" + componentFolder + "' does not reference a valid folder"); File[] jarFiles = folder.listFiles(); if (jarFiles == null || jarFiles.length < 1) throw new RequiredInputMissingException("No JAR files found in folder '" + componentFolder + "'"); // /////////////////////////////////////////////////////////////////// logger.info("Initializing component classloader [componentJarIdentifier=" + componentJarIdentifier + ", folder=" + componentFolder + "]"); // step through jar files, ensure it is a file and iterate through its contents for (File jarFile : jarFiles) { if (jarFile.isFile()) { JarInputStream jarInputStream = null; try { jarInputStream = new JarInputStream(new FileInputStream(jarFile)); JarEntry jarEntry = null; while ((jarEntry = jarInputStream.getNextJarEntry()) != null) { String jarEntryName = jarEntry.getName(); // if the current file references a class implementation, replace slashes by dots, strip // away the class suffix and add a reference to the classes-2-jar mapping if (StringUtils.endsWith(jarEntryName, ".class")) { jarEntryName = jarEntryName.substring(0, jarEntryName.length() - 6).replace('/', '.'); this.classesJarMapping.put(jarEntryName, jarFile.getAbsolutePath()); } else { // if the current file references a resource, check if it is the identifier file which // marks this jar to contain component implementation if (StringUtils.equalsIgnoreCase(jarEntryName, componentJarIdentifier)) this.componentJarFiles.add(jarFile.getAbsolutePath()); // ...and add a mapping for resource to jar file as well this.resourcesJarMapping.put(jarEntryName, jarFile.getAbsolutePath()); } } } catch (Exception e) { logger.error("Failed to read from JAR file '" + jarFile.getAbsolutePath() + "'. Error: " + e.getMessage()); } finally { try { jarInputStream.close(); } catch (Exception e) { logger.error("Failed to close open JAR file '" + jarFile.getAbsolutePath() + "'. Error: " + e.getMessage()); } } } } // load classes from jars marked component files and extract the deployment descriptors for (String cjf : this.componentJarFiles) { logger.info("Attempting to load pipeline components located in '" + cjf + "'"); // open JAR file and iterate through it's contents JarInputStream jarInputStream = null; try { jarInputStream = new JarInputStream(new FileInputStream(cjf)); JarEntry jarEntry = null; while ((jarEntry = jarInputStream.getNextJarEntry()) != null) { // fetch name of current entry and ensure it is a class file String jarEntryName = jarEntry.getName(); if (jarEntryName.endsWith(".class")) { // replace slashes by dots and strip away '.class' suffix jarEntryName = jarEntryName.substring(0, jarEntryName.length() - 6).replace('/', '.'); Class<?> c = loadClass(jarEntryName); AsapComponent pc = c.getAnnotation(AsapComponent.class); if (pc != null) { this.managedComponents.put(getManagedComponentKey(pc.name(), pc.version()), new ComponentDescriptor(c.getName(), pc.type(), pc.name(), pc.version(), pc.description())); logger.info("pipeline component found [type=" + pc.type() + ", name=" + pc.name() + ", version=" + pc.version() + "]"); ; } } } } catch (Exception e) { logger.error("Failed to read from JAR file '" + cjf + "'. Error: " + e.getMessage()); } finally { try { jarInputStream.close(); } catch (Exception e) { logger.error("Failed to close open JAR file '" + cjf + "'. Error: " + e.getMessage()); } } } }