List of usage examples for org.apache.commons.lang3 StringUtils defaultIfBlank
public static <T extends CharSequence> T defaultIfBlank(final T str, final T defaultStr)
Returns either the passed in CharSequence, or if the CharSequence is whitespace, empty ("") or null , the value of defaultStr .
StringUtils.defaultIfBlank(null, "NULL") = "NULL" StringUtils.defaultIfBlank("", "NULL") = "NULL" StringUtils.defaultIfBlank(" ", "NULL") = "NULL" StringUtils.defaultIfBlank("bat", "NULL") = "bat" StringUtils.defaultIfBlank("", null) = null
From source file:com.sonicle.webtop.core.io.input.XlsxColumnsHandler.java
@Override public void cell(String cellReference, String formattedValue, XSSFComment comment) { if (isHeader) { String name = (headersRow == firstDataRow) ? cellReference : StringUtils.defaultIfBlank(formattedValue, cellReference); columnNames.put(name.toLowerCase(), name); final int col = new CellReference(cellReference).getCol(); columnIndexes.put(name, col);/* w w w . ja va 2 s. c om*/ /* String name = null; if(headersRow == firstDataRow) { columnNames.put(cellReference, cellReference); } else { if(!StringUtils.isBlank(cellReference)) { columnNames.put(cellReference.toLowerCase(), cellReference); } else { columnNames.put(cellReference, cellReference); } } columnNames.put(name.toLowerCase(), name); */ } }
From source file:cpcc.vvrte.services.js.JavascriptServiceImpl.java
/** * {@inheritDoc}/*ww w .ja v a2s.c o m*/ */ @Override public Object[] codeVerification(String script, int apiVersion) throws IOException { VirtualVehicle vehicle = new VirtualVehicle(); vehicle.setId(123456789); vehicle.setCode(script); vehicle.setApiVersion(apiVersion); vehicle.setUuid(UUID.randomUUID().toString()); JavascriptWorker w = new JavascriptWorker(vehicle, false, logger, serviceResources, allowedClassesRegex); String completedScript = StringUtils.defaultIfBlank(w.getScript(), ""); Context cx = Context.enter(); cx.setOptimizationLevel(-1); try { return cx.compileString(completedScript, "<check>", 1, null) != null ? ArrayUtils.EMPTY_OBJECT_ARRAY : new Object[] { 0, 0, "Can not compile script!", "" }; } catch (RhinoException e) { return new Object[] { e.columnNumber(), e.lineNumber() - w.getScriptStartLine(), e.details(), e.lineSource() }; } finally { Context.exit(); } }
From source file:com.sonicle.webtop.core.app.AbstractServlet.java
public static void fillSystemVars(Map vars, WebTopApp wta, Locale locale, boolean showSystemInfo, boolean showWebappInfo) { String osInfo = wta.getOSInfo(); String appServerInfo = wta.getAppServerInfo(); String jdk = System.getProperty("java.version"); String webappName = wta.getWebappName(); vars.put("osInfo", osInfo); vars.put("appServerInfo", appServerInfo); vars.put("jdk", jdk); vars.put("webappName", webappName); String serverInfo = ""; if (showSystemInfo) serverInfo += "Hosted on " + osInfo + " - " + appServerInfo + " - Java " + jdk; if (showWebappInfo) { if (!StringUtils.isBlank(serverInfo)) serverInfo += " - "; serverInfo += webappName;/*w ww. jav a2s . c o m*/ } vars.put("serverInfo", StringUtils.defaultIfBlank(serverInfo, null)); }
From source file:com.sonicle.webtop.core.rest.v1.Principals.java
private PrincipalInfo createPrincipal(UserProfileId profileId, String profileUsername, UserProfile.Data data, ArrayList<Boolean> evalPermRefs) { return new PrincipalInfo().profileId(profileId.toString()).profileUsername(profileUsername) .displayName(StringUtils.defaultIfBlank(data.getDisplayName(), profileId.getUserId())) .emailAddress(data.getPersonalEmailAddress()).timezoneId(data.getTimeZoneId()) .languageTag(data.getLanguageTag()).evalPermRefs(evalPermRefs); }
From source file:controllers.SiteApp.java
/** * @param pageNum page number//from ww w. j a v a2s . c o m * @return the result */ public static Result issueList(int pageNum) { String state = StringUtils.defaultIfBlank(request().getQueryString("state"), State.OPEN.name()); State currentState = State.valueOf(state.toUpperCase()); Page<Issue> page = Issue.findIssuesByState(ISSUE_COUNT_PER_PAGE, pageNum - 1, currentState); return ok(issueList.render("title.siteSetting", page, currentState)); }
From source file:ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri.java
public void setUri(String theUri) { myUri = StringUtils.defaultIfBlank(theUri, null); }
From source file:net.sf.jsignpdf.ssl.SSLInitializer.java
/** * @param options// ww w .j a va 2 s . c o m * @throws NoSuchAlgorithmException * @throws IOException * @throws CertificateException * @throws KeyStoreException * @throws KeyManagementException * @throws UnrecoverableKeyException */ public static void init(BasicSignerOptions options) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, CertificateException, IOException, UnrecoverableKeyException { KeyManager[] km = null; if (options != null && options.getTsaServerAuthn() == ServerAuthentication.CERTIFICATE) { char[] pwd = null; if (StringUtils.isNotEmpty(options.getTsaCertFilePwd())) { pwd = options.getTsaCertFilePwd().toCharArray(); } LOGGER.info(Constants.RES.get("ssl.keymanager.init", options.getTsaCertFile())); final String ksType = StringUtils.defaultIfBlank(options.getTsaCertFileType(), "PKCS12"); KeyStore keyStore = KeyStoreUtils.loadKeyStore(ksType, options.getTsaCertFile(), pwd); KeyManagerFactory keyManagerFactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, pwd); km = keyManagerFactory.getKeyManagers(); } SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(km, TRUST_MANAGERS, null); HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory()); }
From source file:ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamToken.java
public void setSystem(String theSystem) { mySystem = StringUtils.defaultIfBlank(theSystem, null); }
From source file:com.adaptris.core.services.LoggingServiceImpl.java
@Override public void prepare() throws CoreException { slf4jLogger = LoggerFactory//w w w .ja v a2 s.co m .getLogger(StringUtils.defaultIfBlank(getLogCategory(), this.getClass().getCanonicalName())); }
From source file:ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamToken.java
public void setValue(String theValue) { myValue = StringUtils.defaultIfBlank(theValue, null); }