List of usage examples for org.apache.commons.lang3 StringUtils trimToEmpty
public static String trimToEmpty(final String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null .
From source file:com.thinkbiganalytics.schema.QueryRunner.java
/** * Tests that the specified query is a SHOW, SELECT, DESC, or DESCRIBE query. * * @param query the query to test/*from ww w.j a v a 2s. co m*/ * @return {@code true} if the query is valid, or {@code false} otherwise */ private boolean validateQuery(@Nonnull final String query) { final String testQuery = StringUtils.trimToEmpty(query); return Arrays.stream(new String[] { "show", "select", "desc", "describe" }) .anyMatch(prefix -> StringUtils.startsWithIgnoreCase(testQuery, prefix)); }
From source file:com.omertron.themoviedbapi.model.Person.java
public void setName(String name) { this.name = StringUtils.trimToEmpty(name); }
From source file:kenh.expl.Environment.java
/** * Load <code>Function</code>. * //w w w. j a va 2s. co m * @param funcPackage The function package. * @param funcName The function name. * @return Use <code>funcPackage + funcName</code> to load class, if not find, return null. */ private Function getFunction_(String funcPackage, String funcName) { if (StringUtils.isBlank(funcPackage)) return null; if (StringUtils.isBlank(funcName)) return null; funcPackage = StringUtils.trimToEmpty(funcPackage); funcName = StringUtils.trimToEmpty(funcName); try { if (StringUtils.isNotBlank(funcPackage)) { Function function = (Function) Class.forName(funcPackage + "." + StringUtils.capitalize(funcName)) .newInstance(); return function; } } catch (Throwable e) { } return null; }
From source file:com.esri.geoportal.commons.robots.BotsReader.java
/** * Parses line into entry./*from ww w .j a v a 2 s . c om*/ * <p> * Skip empty lines. Skip comments. Skip invalid lines. * * @param line line to parse * @return entry or <code>null</code> if skipped * @throws IOException parsing line fails */ protected Map.Entry<Directive, String> parseEntry(String line) throws IOException { line = StringUtils.trimToEmpty(line); if (line.startsWith("#")) { return null; } int colonIndex = line.indexOf(":"); if (colonIndex < 0) { return null; } String key = StringUtils.trimToEmpty(line.substring(0, colonIndex)); Directive dir = Directive.parseDirective(key); if (dir == null) { return null; } String rest = line.substring(colonIndex + 1, line.length()); int hashIndex = rest.indexOf("#"); String value = StringUtils.trimToEmpty(hashIndex >= 0 ? rest.substring(0, hashIndex) : rest); value = decode(value); return new Entry(dir, value); }
From source file:gobblin.source.extractor.extract.sftp.SftpLightWeightFileSystem.java
@Override public FileStatus getFileStatus(Path path) throws IOException { ChannelSftp channelSftp = null;// w w w . ja v a 2s . co m ChannelExec channelExec1 = null; ChannelExec channelExec2 = null; try { channelSftp = this.fsHelper.getSftpChannel(); SftpATTRS sftpAttrs = channelSftp.stat(HadoopUtils.toUriPath(path)); FsPermission permission = new FsPermission((short) sftpAttrs.getPermissions()); channelExec1 = this.fsHelper.getExecChannel("id " + sftpAttrs.getUId()); String userName = IOUtils.toString(channelExec1.getInputStream()); channelExec2 = this.fsHelper.getExecChannel("id " + sftpAttrs.getGId()); String groupName = IOUtils.toString(channelExec2.getInputStream()); FileStatus fs = new FileStatus(sftpAttrs.getSize(), sftpAttrs.isDir(), 1, 0l, sftpAttrs.getMTime(), sftpAttrs.getATime(), permission, StringUtils.trimToEmpty(userName), StringUtils.trimToEmpty(groupName), path); return fs; } catch (SftpException e) { throw new IOException(e); } finally { safeDisconnect(channelSftp); safeDisconnect(channelExec1); safeDisconnect(channelExec2); } }
From source file:com.esri.geoportal.harvester.migration.MigrationBroker.java
private void buildHarvestSites(InitContext context) throws SQLException, DataProcessorException { try (Connection conn = dataSource.getConnection(); PreparedStatement st = makeSitesStatement(conn); ResultSet rs = st.executeQuery();) { MigrationSiteBuilder builder = new MigrationSiteBuilder(getEngine()); while (rs.next()) { MigrationHarvestSite hs = new MigrationHarvestSite(); hs.docuuid = StringUtils.trimToEmpty(rs.getString("DOCUUID")); hs.title = StringUtils.trimToEmpty(rs.getString("TITLE")); hs.type = StringUtils.trimToEmpty(rs.getString("PROTOCOL_TYPE")).toUpperCase(); hs.host = StringUtils.trimToEmpty(rs.getString("HOST_URL")); hs.protocol = rs.getString("PROTOCOL"); hs.frequency = MigrationHarvestSite.Frequency .parse(StringUtils.trimToEmpty(rs.getString("FREQUENCY"))); sites.put(hs.docuuid, hs);//from ww w . ja v a2 s . com builder.buildSite(hs); } } }
From source file:de.jfachwert.post.Anschrift.java
private static Object[] split(String anschrift) { String[] lines = StringUtils.trimToEmpty(anschrift).split("[,\\n$]"); if (lines.length < 2) { throw new InvalidValueException(anschrift, ADDRESS); }/*from ww w. j a v a2 s. c o m*/ Object[] parts = new Object[3]; parts[0] = new Adressat(lines[0]); String adresseOrPostfach = anschrift.substring(lines[0].length() + 1).trim(); try { parts[1] = null; parts[2] = new Postfach(adresseOrPostfach); } catch (ValidationException ex) { LOG.log(Level.FINE, "'" + adresseOrPostfach + "' is not a post office box:", ex); parts[1] = new Adresse(adresseOrPostfach); parts[2] = null; } return parts; }
From source file:com.omertron.themoviedbapi.model.Person.java
public void setProfilePath(String profilePath) { this.profilePath = StringUtils.trimToEmpty(profilePath); }
From source file:com.erudika.scoold.core.Post.java
public void setTitle(String title) { if (!StringUtils.isBlank(title)) { this.title = StringUtils.trimToEmpty(title); setName(title); } }
From source file:com.neatresults.mgnltweaks.ui.action.SaveConfigAddRestClientDialogAction.java
private void setProperty(Node node, String propertyName, AbstractJcrNodeAdapter nodeAdapter) throws RepositoryException { node.setProperty(propertyName,/*from w w w. j ava 2s .c o m*/ StringUtils.trimToEmpty(((String) nodeAdapter.getItemProperty(propertyName).getValue()))); }