List of usage examples for org.apache.commons.lang3 StringUtils isEmpty
public static boolean isEmpty(final CharSequence cs)
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0.
From source file:com.vmware.identity.openidconnect.server.IdmServiceContextProvider.java
@Override public IIdmServiceContext getServiceContext() { IIdmServiceContext serviceContext = null; IDiagnosticsContext context = DiagnosticsContextFactory.getCurrentDiagnosticsContext(); if (context != null && !StringUtils.isEmpty(context.getCorrelationId())) { serviceContext = IdmServiceContextFactory.getIdmServiceContext(context.getCorrelationId()); }//from w w w . j ava2 s .co m return serviceContext; }
From source file:com.webbfontaine.valuewebb.model.validators.tt.TINValidator.java
@Override public boolean isValid(Object value) { if (Utils.currentPage().contains("TtGenList")) { return true; }// www . ja va 2 s .c o m String tin = (String) value; if (StringUtils.isEmpty(tin)) { return true; // mandatory value check is not done by this validator } CompanyData company = RefSelect.getInstance().loadCompany(companyType, tin); boolean isValid = false; if (company != null) { if (companyType == CompanyType.IMPORTER) { setImpData(company); } if (companyType == CompanyType.APPLICANT) { setAppDisabledData(company); } isValid = true; //checkIfBlocked(company); todo: Remove this method if TIN blocked checking is really unnecessary (Marina) } if (!isValid) { LOGGER.debug("Company inexistent {}", value); } return isValid; }
From source file:net.sf.jsignpdf.utils.PKCS11Utils.java
/** * Tries to register the sun.security.pkcs11.SunPKCS11 provider with * configuration provided in the given file. * /*w w w. ja va2 s.c o m*/ * @param configPath * path to PKCS#11 provider configuration file * @return newly registered PKCS#11 provider name if provider successfully * registered; <code>null</code> otherwise */ public static String registerProvider(final String configPath) { if (StringUtils.isEmpty(configPath)) { return null; } LOGGER.debug("Registering SunPKCS11 provider from configuration in " + configPath); final File cfgFile = new File(configPath); final String absolutePath = cfgFile.getAbsolutePath(); if (cfgFile.isFile()) { try { Provider pkcs11Provider = (Provider) Class.forName("sun.security.pkcs11.SunPKCS11") .getConstructor(String.class).newInstance(absolutePath); Security.addProvider(pkcs11Provider); final String name = pkcs11Provider.getName(); LOGGER.debug("SunPKCS11 provider registered with name " + name); return name; } catch (Exception e) { System.err.println("Unable to register SunPKCS11 security provider."); e.printStackTrace(); } } else { System.err.println( "The PKCS#11 provider is not registered. Configuration file doesn't exist: " + absolutePath); } return null; }
From source file:com.adguard.commons.utils.CharsetUtils.java
/** * Extracts Charset from Content-Type header value * * @param contentType Content-Type header value * @param defaultCharset Will be returned if no charset found * @return Charset or defaultCharset//from w w w . j a v a 2 s. c o m */ public static Charset forContentType(String contentType, Charset defaultCharset) { try { if (!StringUtils.isEmpty(contentType)) { String[] parts = StringUtils.split(contentType, ';'); for (String t1 : parts) { String t = t1.trim(); int index = t.toLowerCase().indexOf("charset="); if (index != -1) { String charset = t.substring(index + 8); String charset1 = StringUtils.split(charset, ",;")[0]; return forName(charset1, defaultCharset); } } return defaultCharset; } return defaultCharset; } catch (Exception ex) { log.debug(String.format("Cannot extract charset from %s", contentType), ex); return defaultCharset; } }
From source file:com.micromux.cassandra.jdbc.PooledTest.java
@BeforeClass public static void setUpBeforeClass() throws Exception { // configure OPTIONS if (!StringUtils.isEmpty(TRUST_STORE)) { OPTIONS = String.format("trustStore=%s&trustPass=%s", URLEncoder.encode(TRUST_STORE), TRUST_PASS); }// ww w . j av a 2 s . c o m Class.forName("com.micromux.cassandra.jdbc.CassandraDriver"); con = DriverManager .getConnection(String.format("jdbc:cassandra://%s:%d/%s?%s", HOST, PORT, "system", OPTIONS)); Statement stmt = con.createStatement(); // Drop Keyspace String dropKS = String.format("DROP KEYSPACE \"%s\";", KEYSPACE); try { stmt.execute(dropKS); } catch (Exception e) {/* Exception on DROP is OK */ } // Create KeySpace String createKS = String.format( "CREATE KEYSPACE \"%s\" WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};", KEYSPACE); stmt.execute(createKS); // Create KeySpace String useKS = String.format("USE \"%s\";", KEYSPACE); stmt.execute(useKS); // Create the target Column family String createCF = "CREATE COLUMNFAMILY pooled_test (somekey text PRIMARY KEY," + "someInt int" + ") ;"; stmt.execute(createCF); String insertWorld = "UPDATE pooled_test SET someInt = 1 WHERE somekey = 'world'"; stmt.execute(insertWorld); }
From source file:com.adaptris.core.metadata.DiscardEmptyValuesFilter.java
@Override public MetadataCollection filter(MetadataCollection original) { MetadataCollection result = new MetadataCollection(); for (MetadataElement element : original) { if (!StringUtils.isEmpty(element.getValue())) { result.add(element);//from w w w .j a v a2 s . c om } } return result; }
From source file:com.tojc.ormlite.android.annotation.OrmLiteAnnotationAccessor.java
/** * Gets the column name from DatabaseField annotation. If the DatabaseField#columnName is not * specified, returns the field name.//from w ww . ja v a 2 s. co m * @param element * Element to be evaluated. * @return Returns the column name. */ public static String getAnnotationColumnName(AnnotatedElement element) { String result = ""; DatabaseField databaseField = element.getAnnotation(DatabaseField.class); if (databaseField != null) { result = databaseField.columnName(); if (StringUtils.isEmpty(result)) { result = ((Field) element).getName(); } } return result; }
From source file:AIR.Common.Configuration.AppSettingsHelper.java
private static long getInt64(String key, Long defaultValue) { String rawValue = get(key);// w w w .ja v a 2 s .com if (!StringUtils.isEmpty(rawValue)) { long value = Long.parseLong(rawValue); return value; } return defaultValue != null ? defaultValue.longValue() : 0; }
From source file:com.thruzero.common.core.support.ValueTransformer.java
/** Return true if the value given at construction time is null or its String value is "". */ public boolean isEmptyValue() { return StringUtils.isEmpty(getStringValue()); }
From source file:ch.cyberduck.core.onedrive.OneDriveHomeFeatureTest.java
@Test public void testHomeFeature() throws BackgroundException { final Path drive = new OneDriveHomeFinderFeature(session).find(); assertNotNull(drive);//ww w. ja v a 2s . c o m assertFalse(drive.isRoot()); assertTrue(drive.isVolume()); assertTrue(drive.isDirectory()); assertNotEquals("null", drive.getName()); assertFalse(StringUtils.isEmpty(drive.getName())); }