List of usage examples for org.apache.commons.lang3 StringUtils isNotEmpty
public static boolean isNotEmpty(final CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = false StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty("bob") = true StringUtils.isNotEmpty(" bob ") = true
From source file:io.wcm.caravan.commons.couchbase.impl.CouchbaseUtil.java
/** * Open couchbase bucket./* w w w.j a v a2 s. c o m*/ * @param cluster Couchbase cluster * @param bucketName Bucker name * @param bucketPassword Bucker password (optional) * @return Couchbase bucket */ public static AsyncBucket openBucket(Cluster cluster, String bucketName, String bucketPassword) { if (StringUtils.isNotEmpty(bucketPassword)) { return cluster.openBucket(bucketName, bucketPassword).async(); } else { return cluster.openBucket(bucketName).async(); } }
From source file:com.huacainfo.ace.workflow.mapper.ScriptTaskInfoMapper.java
protected void mapProperties(Object element) { ScriptTask scriptTask = (ScriptTask) element; if (StringUtils.isNotEmpty(scriptTask.getScriptFormat())) { createPropertyNode("Script format", scriptTask.getScriptFormat()); }//from w ww .j a va 2s. co m if (StringUtils.isNotEmpty(scriptTask.getScript())) { createPropertyNode("Script", scriptTask.getScript()); } createListenerPropertyNodes("Execution listeners", scriptTask.getExecutionListeners()); }
From source file:com.nridge.core.app.mail.Mail.java
/** * Convenience method that extracts a first name from an email address * formatted as 'first.last@company.com'. The first name will have its * first letter capitalized.//from w w w . j av a 2s . c om * * @param anEmailAddress Email address. * * @return Proper first name. */ public static String extractFirstName(String anEmailAddress) { String firstName = StringUtils.EMPTY; if (StringUtils.isNotEmpty(anEmailAddress)) { int offset = anEmailAddress.indexOf(StrUtl.CHAR_DOT); if (offset > 0) firstName = StrUtl.firstCharToUpper(anEmailAddress.substring(0, offset)); else { offset = anEmailAddress.indexOf(StrUtl.CHAR_AT); if (offset > 0) firstName = StrUtl.firstCharToUpper(anEmailAddress.substring(0, offset)); } } return firstName; }
From source file:com.huacainfo.ace.workflow.mapper.SequenceFlowInfoMapper.java
protected void mapProperties(Object element) { SequenceFlow sequenceFlow = (SequenceFlow) element; if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) { createPropertyNode("Condition expression", sequenceFlow.getConditionExpression()); }//from ww w .j a va 2 s. com createListenerPropertyNodes("Execution listeners", sequenceFlow.getExecutionListeners()); }
From source file:com.adobe.cq.wcm.core.components.testing.MockXFFactory.java
public static ExperienceFragmentSocialVariation getExperienceFragmentSocialVariation(Page page) { ExperienceFragmentSocialVariation socialVariation = mock(ExperienceFragmentSocialVariation.class); StringBuilder stringBuilder = new StringBuilder(); String image = null;//ww w . j a va2 s . co m for (Resource resource : page.getContentResource().getChild("root").getChildren()) { if (resource.isResourceType(IMAGE_RT) && StringUtils.isEmpty(image)) { image = resource.getValueMap().get("fileReference", String.class); } String text = resource.getValueMap().get("text", String.class); if (StringUtils.isNotEmpty(text)) { stringBuilder.append(text); } } when(socialVariation.getText()).thenReturn(stringBuilder.toString()); when(socialVariation.getImagePath()).thenReturn(image); return socialVariation; }
From source file:com.hybris.mobile.factory.barcode.IntentBarcodeFactory.java
/** * Get the associated IntentBarcode according to the barcodeValue and barcodeSymbology. Different cases, see the file * regex.xml to know how to identify each ones. * /*w w w. j a v a 2 s. co m*/ * @param barcodeValue * @param barcodeSymbology * @param activity * @return */ public static IntentBarcode getIntent(String barcodeValue, String barcodeSymbology, Activity activity) { IntentBarcode intentBarcode = null; // Identifying a product code String productCode = getProductCode(barcodeValue, barcodeSymbology); if (StringUtils.isNotEmpty(productCode)) { intentBarcode = new ProductDetailsIntentBarcodeImpl(productCode, activity); } else { // Identifying a order id String orderId = RegexUtil.getOrderIdFromHybrisPattern(barcodeValue); if (StringUtils.isNotEmpty(orderId)) { intentBarcode = new OrderDetailsIntentBarcodeImpl(orderId, activity); } else { // Identifying a location for a store (either user or store coordinates) List<String> positionValues = getStoreLocatorLocationValues(barcodeValue); // 3 values returned: longitude, latitude, radius // 2 cases: // - geolocation: just the radius is returned (index 2) // - store coordinates: we return the longitude (0), latitude (1) and radius (2) if (positionValues != null && positionValues.size() == 3 && (StringUtils.isNotEmpty(positionValues.get(2)) || (StringUtils.isNotEmpty(positionValues.get(1))) && StringUtils.isNotEmpty(positionValues.get(2)))) { intentBarcode = new StoreLocatorIntentBarcodeImpl(positionValues.get(0), positionValues.get(1), positionValues.get(2), activity); } } } return intentBarcode; }
From source file:com.pontorural.pedidovenda.converter.CfopConverter.java
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { Cfop retorno = null;/*from w w w . j ava 2 s.c om*/ if (StringUtils.isNotEmpty(value)) { String codigo = value; retorno = cfops.porId(codigo); } return retorno; }
From source file:com.keybox.manage.db.UserThemeDB.java
/** * get user theme//from w w w .ja v a 2s . c om * * @param userId object * @return user theme object */ public static UserSettings getTheme(Long userId) { UserSettings theme = null; Connection con = null; try { con = DBUtils.getConn(); PreparedStatement stmt = con.prepareStatement("select * from user_theme where user_id=?"); stmt.setLong(1, userId); ResultSet rs = stmt.executeQuery(); if (rs.next()) { theme = new UserSettings(); theme.setBg(rs.getString("bg")); theme.setFg(rs.getString("fg")); if (StringUtils.isNotEmpty(rs.getString("d1"))) { String[] colors = new String[16]; colors[0] = rs.getString("d1"); colors[1] = rs.getString("d2"); colors[2] = rs.getString("d3"); colors[3] = rs.getString("d4"); colors[4] = rs.getString("d5"); colors[5] = rs.getString("d6"); colors[6] = rs.getString("d7"); colors[7] = rs.getString("d8"); colors[8] = rs.getString("b1"); colors[9] = rs.getString("b2"); colors[10] = rs.getString("b3"); colors[11] = rs.getString("b4"); colors[12] = rs.getString("b5"); colors[13] = rs.getString("b6"); colors[14] = rs.getString("b7"); colors[15] = rs.getString("b8"); theme.setColors(colors); } } DBUtils.closeRs(rs); DBUtils.closeStmt(stmt); } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); return theme; }
From source file:com.glaf.jbpm.util.ExtensionUtils.java
public static List<Object> getValues(Map<String, Object> paramMap, Extension extension) { java.util.Date now = new java.util.Date(); List<Object> values = new java.util.ArrayList<Object>(); List<ExtensionParam> x_params = extension.getParams(); Iterator<ExtensionParam> iterator = x_params.iterator(); while (iterator.hasNext()) { ExtensionParam param = iterator.next(); String key = param.getValue(); Object value = param.getValue(); if (key != null && value != null) { String tmp = param.getValue(); if (StringUtils.isNotEmpty(tmp)) { if (tmp.equals("now()")) { value = new java.sql.Date(now.getTime()); } else if (tmp.equals("date()")) { value = new java.sql.Date(now.getTime()); } else if (tmp.equals("time()")) { value = new java.sql.Time(now.getTime()); } else if (tmp.equals("timestamp()")) { value = new java.sql.Timestamp(now.getTime()); } else if (tmp.equals("dateTime()")) { value = new java.sql.Timestamp(now.getTime()); } else if (tmp.equals("currentTimeMillis()")) { value = System.currentTimeMillis(); } else if (tmp.equals("#{rowId}")) { value = paramMap.get("rowId"); } else if (tmp.equals("#{processInstanceId}")) { value = ParamUtils.getLongValue(paramMap, "processInstanceId"); } else if (tmp.equals("#{processName}")) { value = ParamUtils.getString(paramMap, "processName"); } else if (tmp.equals("#{status}")) { value = paramMap.get("status"); } else if (tmp.startsWith("#P{") && tmp.endsWith("}")) { tmp = StringTools.replaceIgnoreCase(tmp, "#P{", ""); tmp = StringTools.replaceIgnoreCase(tmp, "}", ""); value = paramMap.get(tmp); } else if (tmp.startsWith("#{") && tmp.endsWith("}")) { value = DefaultExpressionEvaluator.evaluate(tmp, paramMap); }// ww w .j a v a2 s . com } } values.add(value); } return values; }
From source file:com.pontorural.pedidovenda.converter.PedidoConverter.java
@Override public Object getAsObject(FacesContext context, UIComponent component, String value) { Pedido retorno = null;// www .j a v a 2 s . co m if (StringUtils.isNotEmpty(value)) { Integer codigo = new Integer(value); retorno = pedidos.porId(codigo); } return retorno; }