/** * Unescapes all <code>&amp;</code>, that is replaces them with a <code>&</code>.<p> * * @param source the String to unescape * @return the unescaped String */ public static String unescapeLink(String source) { if (source == null) { return null; } return CmsStringUtil.substitute(source, "&", "&"); }
/** * Removes all whitespaces from the given legacy rule String.<p> * * @param legacyRules the legacy rule String to substitute * @return the legacy rule String without whitespaces */ protected String substituteLegacyRules(String legacyRules) { return CmsStringUtil.substitute(legacyRules, " ", ""); }
/** * Unescapes all <code>&amp;</code>, that is replaces them with a <code>&</code>.<p> * * @param source the String to unescape * @return the unescaped String */ public static String unescapeLink(String source) { if (source == null) { return null; } return CmsStringUtil.substitute(source, "&", "&"); }
/** * Removes all whitespaces from the given legacy rule String.<p> * * @param legacyRules the legacy rule String to substitute * @return the legacy rule String without whitespaces */ protected String substituteLegacyRules(String legacyRules) { return CmsStringUtil.substitute(legacyRules, " ", ""); }
/** * Returns the URI of a database config page (in step 3) for a specified database key.<p> * * @param key the database key (e.g. "mysql", "generic" or "oracle") * @return the URI of a database config page */ public String getDatabaseConfigPage(String key) { // don't use File.separatorChar here, result must be a valid URL with "/" path delimiters String configUri = FOLDER_DATABASE + key + "/" + "step_4_database_setup.jsp"; return CmsStringUtil.substitute(configUri, File.separator, "/"); }
/** * Replaces escaped char sequences in the input value.<p> * * @param value the value to unescape * * @return the unescaped String */ protected static String unescape(String value) { value = CmsStringUtil.substitute(value, "\\,", ","); value = CmsStringUtil.substitute(value, "\\=", "="); value = CmsStringUtil.substitute(value, "\\\\", "\\"); return value; }
/** * Rebuilds the given delimiter character from the replacement string.<p> * * @param value the string that is scanned * @param delimiter the delimiter character to rebuild * @param delimiterReplacement the replacement string for the delimiter character * @return the substituted string */ private String rebuildDelimiter(String value, char delimiter, String delimiterReplacement) { return CmsStringUtil.substitute(value, delimiterReplacement, String.valueOf(delimiter)); }
/** * Replaces the given delimiter character with the replacement string.<p> * * @param value the string that is scanned * @param delimiter the delimiter character to replace * @param delimiterReplacement the replacement string for the delimiter character * @return the substituted string */ private String replaceDelimiter(String value, char delimiter, String delimiterReplacement) { return CmsStringUtil.substitute(value, String.valueOf(delimiter), delimiterReplacement); }
/** * Rebuilds the given delimiter character from the replacement string.<p> * * @param value the string that is scanned * @param delimiter the delimiter character to rebuild * @param delimiterReplacement the replacement string for the delimiter character * @return the substituted string */ private String rebuildDelimiter(String value, char delimiter, String delimiterReplacement) { return CmsStringUtil.substitute(value, delimiterReplacement, String.valueOf(delimiter)); }
/** * Replaces the given delimiter character with the replacement string.<p> * * @param value the string that is scanned * @param delimiter the delimiter character to replace * @param delimiterReplacement the replacement string for the delimiter character * @return the substituted string */ private String replaceDelimiter(String value, char delimiter, String delimiterReplacement) { return CmsStringUtil.substitute(value, String.valueOf(delimiter), delimiterReplacement); } }
/** * Returns the name for the tab ID, generated from the start name.<p> * * @return the name for the tab ID, generated from the start name */ public String getIdName() { if (m_idName == null) { m_idName = getStartName(); // remove special characters causing problems in ID attributes m_idName = CmsStringUtil.substitute(m_idName, ".", "-"); m_idName = CmsStringUtil.substitute(m_idName, ":", "-"); m_idName = CmsStringUtil.substitute(m_idName, "_", "-"); } return m_idName; }
/** * Translates the last path segment of a path using the configured OpenCms file translations.<p> * * @param path the path for which the last segment should be translated * * @return the path with the translated last segment */ protected String translateName(String path) { return CmsStringUtil.substitute(Pattern.compile("/([^/]+)$"), path, new I_CmsRegexSubstitution() { public String substituteMatch(String text, Matcher matcher) { String name = text.substring(matcher.start(1), matcher.end(1)); return "/" + OpenCms.getResourceManager().getFileTranslator().translateResource(name); } }); }
/** * Returns the specified HTML part of the HTML property file to create the output.<p> * * @param part the name of the desired part * @param replaceString String which is inserted in the found HTML part at the location of "$replace$" * @return the HTML part or an empty String, if the part was not found */ public String getHtmlPart(String part, String replaceString) { String value = m_htmlProps.getProperty(part); if (value == null) { return ""; } else { return CmsStringUtil.substitute(value, "$replace$", replaceString); } }
/** * Encodes a String in a way that is compatible with the JavaScript escape function. * * @param source The text to be encoded * @param encoding the encoding type * * @return The JavaScript escaped string */ public static String escape(String source, String encoding) { // the blank is encoded into "+" not "%20" when using standard encode call return CmsStringUtil.substitute(encode(source, encoding), "+", "%20"); }
/** * Replaces the project search pattern in SQL queries by the pattern _ONLINE_ or _OFFLINE_ depending on the * specified project ID.<p> * * @param projectId the ID of the current project * @param query the SQL query * @return String the SQL query with the table key search pattern replaced */ protected static String replaceProjectPattern(CmsUUID projectId, String query) { // make the statement project dependent String replacePattern = ((projectId == null) || projectId.equals(CmsProject.ONLINE_PROJECT_ID)) ? "_ONLINE_" : "_OFFLINE_"; return CmsStringUtil.substitute(query, QUERY_PROJECT_SEARCH_PATTERN, replacePattern); }
/** * Replaces the project search pattern in JPQL queries by the pattern _ONLINE_ or _OFFLINE_ depending on the * specified project ID.<p> * * @param projectId the ID of the current project * @param query the JPQL query * @return String the JPQL query with the table key search pattern replaced */ private static String replaceProjectPattern(CmsUUID projectId, String query) { // make the statement project dependent String replacePattern = ((projectId == null) || projectId.equals(CmsProject.ONLINE_PROJECT_ID)) ? ONLINE_PROJECT : OFFLINE_PROJECT; return CmsStringUtil.substitute(query, QUERY_PROJECT_SEARCH_PATTERN, replacePattern); }
/** * Replaces the project search pattern in SQL queries by the pattern _ONLINE_ or _OFFLINE_ depending on the * specified project ID.<p> * * @param projectId the ID of the current project * @param query the SQL query * @return String the SQL query with the table key search pattern replaced */ protected static String replaceProjectPattern(CmsUUID projectId, String query) { // make the statement project dependent String replacePattern = ((projectId == null) || projectId.equals(CmsProject.ONLINE_PROJECT_ID)) ? "_ONLINE_" : "_OFFLINE_"; return CmsStringUtil.substitute(query, QUERY_PROJECT_SEARCH_PATTERN, replacePattern); }
/** * Decodes a string used as parameter in an uri in a way independent of other encodings/decodings applied before.<p> * * @param input the encoded parameter string * * @return the decoded parameter string * * @see #encodeParameter(String) */ public static String decodeParameter(String input) { String result = CmsStringUtil.substitute(input, ENTITY_REPLACEMENT, ENTITY_PREFIX); return CmsEncoder.decodeHtmlEntities(result, OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Decodes a string used as parameter in an uri in a way independent of other encodings/decodings applied before.<p> * * @param input the encoded parameter string * * @return the decoded parameter string * * @see #encodeParameter(String) */ public static String decodeParameter(String input) { String result = CmsStringUtil.substitute(input, ENTITY_REPLACEMENT, ENTITY_PREFIX); return CmsEncoder.decodeHtmlEntities(result, OpenCms.getSystemInfo().getDefaultEncoding()); }
/** * Sets the OpenCms workplace site.<p> * * @param newSite the OpenCms workplace site */ public void setWorkplaceSite(String newSite) { String oldSite = getWorkplaceSite(); // get the site list String siteList = getExtProperty("site.root.list"); // replace old site URL in site list with new site URL siteList = CmsStringUtil.substitute(siteList, oldSite, newSite); setExtProperty("site.root.list", siteList); setExtProperty("site.workplace", newSite); }