private String createCellIconColWidth(ITableRow row, String icon) { if (StringUtility.hasText(icon)) { return "32"; } else { //If there is no icon set a small width as left padding for the text. return "6"; } }
protected String urlDecode(final String s) { if (StringUtility.hasText(s)) { try { return URLDecoder.decode(s, StandardCharsets.UTF_8.name()); } catch (final UnsupportedEncodingException e) { LOG.warn("Unsupported encoding", e); } } return s; }
protected String parseWarPath(String value) throws ServletException { if (value != null && value.endsWith("/")) { return value.substring(0, value.length() - 1); } if (!StringUtility.hasText(value)) { throw new ServletException("Missing init parameters. Set 'war-path' parameter."); } return value; }
/** * @param redirectUrl * optional, URL where to redirect the UI. If <code>null</code>, session is informed about session * termination, but no redirection happens. * @return {@link JSONObject} to indicate that the session was terminated. */ public JSONObject createSessionTerminatedResponse(final String redirectUrl) { final JSONObject json = new JSONObject(); json.put("sessionTerminated", Boolean.TRUE); if (StringUtility.hasText(redirectUrl)) { json.put("redirectUrl", redirectUrl); } return json; }
protected String parseFolderParam(String value) { if (!StringUtility.hasText(value)) { return ""; } value = value.replaceAll("\\\\", "/"); //$NON-NLS-1$ while (value.startsWith("/")) { value = value.substring(1); } while (value.endsWith("/")) { value = value.substring(0, value.lastIndexOf('/')); } return '/' + value; }
public static Pair<String, Long> extractFilenameWithFingerprint(String filenameWithFingerprint) { Matcher m = REGEX_FINGERPRINT_PATTERN.matcher(filenameWithFingerprint); m.find(); String fingerprintString = m.group(1); String filename = m.group(2); Long fingerprint = 0L; if (StringUtility.hasText(fingerprintString)) { fingerprint = Long.valueOf(fingerprintString); } return new ImmutablePair<>(filename, fingerprint); }
public void tableHeaderCell(String content) { m_out.print("<th>"); if (!StringUtility.hasText(content)) { m_out.print(" "); } else { print(content); } m_out.print("</th>"); }
@Override protected BinaryResource parseValueInternal(String text) { // Don't allow to edit the value - except to completely delete it! if (StringUtility.hasText(text)) { return getValue(); } return null; }
public int[] getPropertyIntArray(String propName) { if (m_prefs == null) { return null; } String strVal = m_prefs.get(propName, null); if (!StringUtility.hasText(strVal)) { return null; } String[] split = strVal.split(";"); int[] val = new int[split.length]; for (int i = 0; i < split.length; i++) { val[i] = Integer.parseInt(split[i]); } return val; }
/** * Parses a request {@link String} into an optional {@link ScriptRequest} instance. * * @return An empty {@link Optional} if the {@link String} specified is no valid script request. Otherwise the * {@link Optional} contains a parsed {@link ScriptRequest} instance. */ public static Optional<ScriptRequest> tryParse(String scriptRequestPath) { if (!StringUtility.hasText(scriptRequestPath)) { return Optional.empty(); } Matcher matcher = SCRIPT_URL_PATTERN.matcher(scriptRequestPath); if (!matcher.matches()) { return Optional.empty(); } return Optional.of(new ScriptRequest(matcher)); }
public static String getObjectType(String objectType, Object model) { if (model.getClass().isAnnotationPresent(ModelVariant.class)) { ModelVariant modelVariant = model.getClass().getAnnotation(ModelVariant.class); if (StringUtility.hasText(modelVariant.value())) { return objectType + ModelVariant.SEPARATOR + modelVariant.value(); } } return objectType; }
@Override protected String formatValueInternal(BinaryResource validValue) { if (validValue == null) { return null; } String filename = validValue.getFilename(); if (StringUtility.hasText(filename)) { if (!isShowFileExtension() && filename.indexOf('.') >= 0) { return filename.substring(0, filename.lastIndexOf('.')); } return filename; } return null; }
public BrowserHistoryEntry createBrowserHistoryEntry() { if (m_path == null) { throw new IllegalStateException("Cannot create BrowserHistoryEntry without deep-link path"); } IDesktop desktop = ClientSessionProvider.currentSession().getDesktop(); StringBuilder title = new StringBuilder(desktop.getTitle()); if (StringUtility.hasText(m_info)) { title.append(" - ").append(m_info); } return new BrowserHistoryEntry(m_builder.createURI(), title.toString(), m_path); }
public DeepLinkUriBuilder parameterInfo(String info) { if (StringUtility.hasText(info)) { m_info = info; m_builder.parameter(DeepLinkUrlParameter.INFO, DeepLinkUtility.toSlug(info)); } return this; }
public void tableCell(String content, int rows, int cols, String color) { startTableCell(rows, cols, color); if (!StringUtility.hasText(content)) { m_out.print(" "); } else { print(content); } endTableCell(); }
private static String autoCreateSelectClause(String whereClause) { if (whereClause == null) { return null; } String tmp = whereClause; tmp = StringUtility.removeTag(tmp, "fromPart"); tmp = StringUtility.removeTag(tmp, "wherePart"); tmp = StringUtility.removeTag(tmp, "havingPart"); if (!StringUtility.hasText(tmp)) { return null; } if ((" " + tmp).matches(".*[^a-zA-Z_$]SELECT[^a-zA-Z_$].*")) { return null; } return whereClause; }
protected void extractParameters(final URI uri) { m_parameters = new HashMap<>(); for (final String param : StringUtility.split(uri.getRawQuery(), "&")) { if (!StringUtility.hasText(param)) { continue; } final String[] kv = StringUtility.split(param, "=", 2); if (kv.length != 2) { continue; } final String k = StringUtility.emptyIfNull(urlDecode(kv[0])); final String v = StringUtility.emptyIfNull(urlDecode(kv[1])); m_parameters.put(k, v); } }
protected IHtmlElement createTitleHtml() { String title = StringUtility.join(" ", getProductName(), getProductVersion()); if (StringUtility.hasText(title)) { // Set as form title instead of including in the info HTML setTitle(title); } return null; }
protected void handleUiGeolocationDetermined(JsonEvent event) { String errorCode = event.getData().optString("errorCode"); String errorMessage = event.getData().optString("errorMessage"); if (StringUtility.hasText(errorCode)) { getModel().getUIFacade().fireGeolocationFailed(errorCode, errorMessage); return; } String latitude = event.getData().getString("latitude"); String longitude = event.getData().getString("longitude"); getModel().getUIFacade().fireGeolocationDetermined(latitude, longitude); }