List of usage examples for org.apache.commons.lang StringUtils isNotEmpty
public static boolean isNotEmpty(String str)
Checks if a String is not empty ("") and not null.
From source file:eionet.meta.service.data.SchemaSetFilter.java
/** * * @return//from ww w . ja v a 2 s.co m */ public boolean isValued() { if (StringUtils.isNotEmpty(identifier)) { return true; } if (StringUtils.isNotEmpty(regStatus)) { return true; } if (CollectionUtils.isNotEmpty(regStatuses)) { return true; } if (isAttributesValued()) { return true; } if (isComplexAttributesValued()) { return true; } return false; }
From source file:com.microsoft.alm.plugin.external.commands.UndoCommand.java
/** * Returns the files that were undone//from w w w . j av a2 s.c om * <p/> * Output example: * /path/path: * Undoing edit: file1.java * No pending changes were found for /path/path/file2.java. * <p/> */ @Override public List<String> parseOutput(final String stdout, final String stderr) { final String[] output = getLines(stdout); // check for failure if (StringUtils.isNotEmpty(stderr)) { logger.error("Undo failed with the following stderr: " + stderr); for (int i = 0; i < output.length; i++) { // finding error message by eliminating all other known output lines since we can't parse for the error line itself (it's unknown to us) // TODO: figure out a better way to get the error message instead of parsing if (isOutputLineExpected(output[i], new String[] { UNDO_LINE_PREFIX }, true)) { throw new RuntimeException(output[i]); } } // couldn't figure out error message parsing so returning generic error logger.error("Parsing of the stdout failed to get the error message"); throw new TeamServicesException(TeamServicesException.KEY_ERROR_UNKNOWN); } final List<String> filesUndone = new ArrayList<String>(); // parse output for directory paths and file names to combine String path = StringUtils.EMPTY; for (int i = 0; i < output.length; i++) { if (isFilePath(output[i])) { path = output[i]; } else if (StringUtils.isNotEmpty(output[i])) { filesUndone.add(getFilePath(path, output[i], "")); //TODO: Need to pass in the path root } } return filesUndone; }
From source file:au.org.ala.delta.translation.naturallanguage.IndexWriter.java
private void writeItemIndexHeading(Item item) { String heading = _context.getIndexHeading(item.getItemNumber()); if (StringUtils.isNotEmpty(heading)) { _indexFile.outputLine(heading);//from w w w . j a v a 2 s . com } }
From source file:com.git.original.common.utils.IPUtils.java
/** * ?IP?// w ww . j ava 2 s. c om * <p> * :<br/> * 1. 220.xxx.xxx.xxx<br> * 2. 123.xxx.xxx.xxx<br> * other<br> * * @return * @throws SocketException * If an I/O error occurs. * @throws NullPointerException * can not found the interface * @throws RuntimeException * can not get net address */ public static InetAddress getWANIpv4Address(String interfaceName) throws SocketException, NullPointerException, RuntimeException { InetAddress ipStartWith123 = null; InetAddress ipv4Addr = null; if (StringUtils.isNotEmpty(interfaceName)) { // ? NetworkInterface netInterface = NetworkInterface.getByName(interfaceName.trim()); if (netInterface == null) { throw new NullPointerException("can not found the network interface by name: " + interfaceName); } Enumeration<InetAddress> addrEnum = netInterface.getInetAddresses(); while (addrEnum.hasMoreElements()) { InetAddress addr = addrEnum.nextElement(); String hostAddr = addr.getHostAddress(); if (hostAddr.startsWith("220.")) { return addr; } else if (ipStartWith123 == null && hostAddr.startsWith("123.")) { ipStartWith123 = addr; } else if (addr instanceof Inet4Address) { ipv4Addr = addr; } } } else { /* * ??? */ Enumeration<NetworkInterface> interfaceEnum = NetworkInterface.getNetworkInterfaces(); while (interfaceEnum.hasMoreElements()) { NetworkInterface netInterface = interfaceEnum.nextElement(); if (netInterface.isLoopback() || !netInterface.isUp()) { continue; } Enumeration<InetAddress> addrEnum = netInterface.getInetAddresses(); while (addrEnum.hasMoreElements()) { InetAddress addr = addrEnum.nextElement(); String hostAddr = addr.getHostAddress(); if (hostAddr.startsWith("220.")) { return addr; } else if (ipStartWith123 == null && hostAddr.startsWith("123.")) { ipStartWith123 = addr; } else if (addr instanceof Inet4Address) { ipv4Addr = addr; } } } } if (ipStartWith123 != null) { return ipStartWith123; } else if (ipv4Addr != null) { return ipv4Addr; } throw new RuntimeException("can not get WAN Address"); }
From source file:net.shopxx.controller.admin.LoginController.java
@RequestMapping public String index(HttpServletRequest request, ModelMap model) { String loginToken = WebUtils.getCookie(request, Admin.LOGIN_TOKEN_COOKIE_NAME); if (!StringUtils.equalsIgnoreCase(loginToken, adminService.getLoginToken())) { return "redirect:/"; }//from w w w.ja va 2 s .c o m if (adminService.isAuthenticated()) { return "redirect:common/main.jhtml"; } Message failureMessage = null; String loginFailure = (String) request .getAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME); if (StringUtils.isNotEmpty(loginFailure)) { if (loginFailure.equals("net.shopxx.exception.IncorrectCaptchaException")) { failureMessage = Message.error("admin.captcha.invalid"); } else if (loginFailure.equals("org.apache.shiro.authc.UnknownAccountException")) { failureMessage = Message.error("admin.login.unknownAccount"); } else if (loginFailure.equals("org.apache.shiro.authc.DisabledAccountException")) { failureMessage = Message.error("admin.login.disabledAccount"); } else if (loginFailure.equals("org.apache.shiro.authc.LockedAccountException")) { failureMessage = Message.error("admin.login.lockedAccount"); } else if (loginFailure.equals("org.apache.shiro.authc.IncorrectCredentialsException")) { Setting setting = SystemUtils.getSetting(); if (ArrayUtils.contains(setting.getAccountLockTypes(), Setting.AccountLockType.admin)) { failureMessage = Message.error("admin.login.accountLockCount", setting.getAccountLockCount()); } else { failureMessage = Message.error("admin.login.incorrectCredentials"); } } else if (loginFailure.equals("net.shopxx.exception.IncorrectLicenseException")) { failureMessage = Message.error("admin.login.incorrectLicense"); } else if (loginFailure.equals("org.apache.shiro.authc.AuthenticationException")) { failureMessage = Message.error("admin.login.authentication"); } } RSAPublicKey publicKey = rsaService.generateKey(request); model.addAttribute("modulus", Base64.encodeBase64String(publicKey.getModulus().toByteArray())); model.addAttribute("exponent", Base64.encodeBase64String(publicKey.getPublicExponent().toByteArray())); model.addAttribute("captchaId", UUID.randomUUID().toString()); model.addAttribute("failureMessage", failureMessage); return "/admin/login/index"; }
From source file:com.ultrapower.eoms.common.plugin.ecside.table.cell.CheckBoxHeaderCell.java
public String getHtmlDisplay(TableModel model, Column column) { HtmlBuilder html = new HtmlBuilder(); String tableId = model.getTable().getTableId(); String selectableControlName = column.getAlias(); /*from w w w . j a v a 2 s . co m*/ html.td(2).valign("middle").append(" columnName=\"").append(column.getAlias()).append("\" "); if ("true".equalsIgnoreCase(column.getGroup())) { html.append(" group=\"true\" "); } if (StringUtils.isNotEmpty(column.getWidth())) { html.width(column.getWidth()); } String headerClass=column.getHeaderClass(); StringBuffer styleClass=new StringBuffer(); if (StringUtils.isNotEmpty(headerClass)) { styleClass.append(headerClass); } if (StringUtils.isNotEmpty(column.getHeaderStyleClass())) { styleClass.append(" ").append(column.getHeaderStyleClass()); } html.styleClass(styleClass.toString().trim()); if (StringUtils.isNotEmpty(column.getHeaderStyle())) { html.style(column.getHeaderStyle()); } // html.onmouseover(ECSideConstants.UTIL_FUNCTION_NAME+".lightHeader(this,'"+tableId+"');" ); // html.onmouseout(ECSideConstants.UTIL_FUNCTION_NAME+".unlightHeader(this,'"+tableId+"');" ); // // // // html.close(); // // // // html.span(); // String cstyle = "columnSeparator"; // html.styleClass(cstyle); // html.close().append(" "); // html.spanEnd(); html.div().styleClass("headerTitle").close(); html.span().styleClass("checkboxHeader"); html.title(model.getMessages().getMessage(PreferencesConstants.HEAD_TIP_CHECKALL)); html.onclick(ECSideConstants.UTIL_FUNCTION_NAME + ".checkAll(this,'" + selectableControlName + "','" + tableId + "');"); html.close(); html.append(" "); // // html.input("checkbox"); // if (column.getStyleClass() != null) { // html.styleClass(column.getStyleClass()); // } else { //// html.styleClass("checkboxHeader"); // } // // html.xclose(); // html.spanEnd(); //html.append(column.getTitle()); html.divEnd(); html.tdEnd(); return html.toString(); }
From source file:com.google.code.trapo.web.tags.AbstractTrapoTag.java
private String completeUrl() throws JspException { StringBuilder completeUrl = contextUrl().append(url); if (!completeUrl.toString().endsWith("/")) { completeUrl.append("/"); }//from w w w .j a v a 2s .c o m completeUrl.append(transformValue()); if (StringUtils.isNotEmpty(extension)) { completeUrl.append(".").append(extension); } return completeUrl.toString(); }
From source file:eionet.meta.service.data.SchemaFilter.java
/** * * @return//ww w. j a va 2s.com */ public boolean isValued() { if (StringUtils.isNotEmpty(fileName)) { return true; } if (StringUtils.isNotEmpty(schemaSetIdentifier)) { return true; } if (StringUtils.isNotEmpty(regStatus)) { return true; } if (isAttributesValued()) { return true; } return false; }
From source file:com.alibaba.tamper.process.DebugValueProcess.java
@Override public Object process(Object value, ValueProcessInvocation invocation) throws BeanMappingException { BeanMappingField currentField = invocation.getContext().getCurrentField(); if (currentField.isMapping() == false && invocation.getContext().getBeanObject().getBehavior().isDebug() && logger.isDebugEnabled()) { StringBuilder builder = new StringBuilder(); builder.append("srcName[" + currentField.getSrcField().getName()); builder.append("],srcClass[" + ObjectUtils.toString(currentField.getSrcField().getClazz(), "null")); builder.append("],targetName[" + currentField.getTargetField().getName()); builder.append(/*from ww w . j a va 2 s .co m*/ "],targetClass[" + ObjectUtils.toString(currentField.getTargetField().getClazz(), "null")); if (StringUtils.isNotEmpty(currentField.getDefaultValue())) { builder.append("],[defaultValue=" + currentField.getDefaultValue()); } if (StringUtils.isNotEmpty(currentField.getConvertor())) { builder.append("],[convertor=" + currentField.getConvertor()); } if (StringUtils.isNotEmpty(currentField.getScript())) { builder.append("],[script=" + currentField.getScript()); } builder.append("], Value = " + ObjectUtils.toString(value, "null")); logger.debug(builder.toString()); } return invocation.proceed(value); // }
From source file:gov.nih.nci.cabig.caaers.domain.expeditedfields.UnsatisfiedProperty.java
/** * This method will return a qualified display name. * ie. displayname [parent]~displayname [current node] * * @return the display name/*from ww w . j a va2 s . c om*/ */ public String getDisplayName() { ArrayList<String> displayNameList = new ArrayList<String>(); TreeNode node = treeNode; while (node != null && node instanceof PropertyNode && StringUtils.isNotEmpty(node.getDisplayName())) { displayNameList.add(node.getDisplayName()); node = node.getParent(); } Collections.reverse(displayNameList); return StringUtils.join(displayNameList, "~"); }