/** * Substitutes '$main_root_url' and '$main_root' macros in a given string. * * @param source * The given source string. * @param mainRootPath * The given main component root directory path. * @return The result string with all the 'main' macros substituted and all '\' characters * replaced with '/' characters. */ protected static String substituteMainRootInString(String source, String mainRootPath) { String result = source; // substitute '$main_root_url' String replacement = StringUtil.toRegExpReplacement(FileUtil.localPathToFileUrl(mainRootPath)); result = result.replaceAll(MAIN_ROOT_URL_REGEX, replacement); // substitute '$main_root' replacement = StringUtil.toRegExpReplacement(mainRootPath); result = result.replaceAll(MAIN_ROOT_REGEX, replacement); return result.trim().replace('\\', '/'); }
String regex = regexList.nextElement(); String replacement = _urlSubstitutionTable.get(regex); paramValue = paramValue.replaceAll(regex, StringUtil.toRegExpReplacement(replacement)); String regex = regexList.nextElement(); String replacement = _pathSubstitutionTable.get(regex); paramValue = paramValue.replaceAll(regex, StringUtil.toRegExpReplacement(replacement));
/** * Substitutes '$dlg_comp_id$root_url' and '$dlg_comp_id$root' macros in a given string for a * given delegate component. * * @param source * The given source string. * @param compId * The given component ID. * @param compRootPath * The given component root directory path. * @return The result string with all the 'delegate' macros substituted and all '\' characters * replaced with '/' characters. */ protected static String substituteCompIdRootInString(String source, String compId, String compRootPath) { String result = source; // substitute '$dlg_comp_id$root_url' String regExp = componentIdRootRegExp(compId, DELEGATE_ROOT_URL_SUFFIX_REGEX); String fileUrl = FileUtil.localPathToFileUrl(compRootPath); String replacement = StringUtil.toRegExpReplacement(fileUrl); result = result.replaceAll(regExp, replacement); // substitute '$dlg_comp_id$root' regExp = componentIdRootRegExp(compId, DELEGATE_ROOT_SUFFIX_REGEX); replacement = StringUtil.toRegExpReplacement(compRootPath); result = result.replaceAll(regExp, replacement); return result.trim().replace('\\', '/'); }
String replaceWith = StringUtil.toRegExpReplacement(replacement); try {
/** * Creates a string that should be added to the PATH to run the given installed component, based * on the PEAR package defaults and its installation descriptor specifications. The output string * includes absolute or relative path expressions for all relevant objects containing in the * component PEAR package, depending on the value of a given <code>boolean</code> argument. If * the component package is archived, returns <code>null</code>. * * @param relativePath * If <code>true</code>, the output string will include relative path expressions for * all relevant objects containing in the component PEAR package, otherwise it will * contain absolute path expressions for these objects. * @return The string that needs to be added to the PATH to run the given installed component. * @throws IOException * If any I/O exception occurred. */ public String buildComponentPath(boolean relativePath) throws IOException { if (!isArchived()) { InstallationDescriptor insdObject = getInstallationDescriptor(); if (insdObject != null) { String absolutePath = InstallationController.buildComponentPath(getRootDirectory() .getAbsolutePath(), insdObject); String absoluteRootDirPathExp = StringUtil.toRegExpReplacement(getRootDirectory() .getAbsolutePath().replace('\\', '/')); return relativePath ? absolutePath.replaceAll(absoluteRootDirPathExp, "\\.") : absolutePath; } } return null; }
String absoluteClassPath = InstallationController.buildComponentClassPath( getRootDirectory().getAbsolutePath(), insdObject, addLibDir); String absoluteRootDirPathExp = StringUtil.toRegExpReplacement(getRootDirectory() .getAbsolutePath().replace('\\', '/')); return relativePath ? absoluteClassPath.replaceAll(absoluteRootDirPathExp, "\\.")
PMControllerHelper.MAIN_ROOT_REGEX, StringUtil.toRegExpReplacement(aggRootDirPath));
StringUtil.toRegExpReplacement("..")); dlgImport.setLocation(dlgDescRelPath);