List of usage examples for org.apache.commons.lang StringUtils remove
public static String remove(String str, char remove)
Removes all occurrences of a character from within the source string.
From source file:org.easycloud.las.agent.LogClearThread.java
private boolean shouldDelete(String rootPath, DateFormat df, Date lastPushedTime, File logDir) { String absDirPath = logDir.getAbsolutePath(); String relDirPath = StringUtils.remove(absDirPath, rootPath); // TODO hard code "/" here, maybe the windows can't be supported if (StringUtils.startsWith(relDirPath, "/")) { relDirPath = relDirPath.substring(1); }// ww w .j a v a 2 s . com if (StringUtils.endsWith(relDirPath, "/")) { relDirPath = relDirPath.substring(0, relDirPath.length() - 1); } Date loggingTime = parseDate(relDirPath, df); if (loggingTime == null) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("LogPushThread: Parsing the log directory [" + logDir.getPath() + "] failed, and it's skipped."); } return false; } else { return TimeUtil.isBeforeNow(loggingTime, agentConfiguration.getInt(LOG_CLEAR_BEFORE, DEFAULT_BEFORE_DAYS), Calendar.DATE) && TimeUtil.isBefore(loggingTime, lastPushedTime); } }
From source file:org.easycloud.las.agent.LogPushThread.java
private String parseLoggingTime(String rootPath, String postfix, File logFile) { String absLogPath = logFile.getAbsolutePath(); String relLogPath = StringUtils.remove(absLogPath, rootPath); if (StringUtils.startsWith(relLogPath, "/")) { relLogPath = relLogPath.substring(1); }/*from ww w .j av a 2s . c o m*/ return StringUtils.remove(relLogPath, postfix); }
From source file:org.eclipse.mylyn.internal.gerrit.ui.GerritUrlHandler.java
/** * Returns the patch set number as encoded in a Gerrit URL. For example, * "http://review.mylyn.org/#/c/4698/5/foo/bar", "4698" -> 5. Returns -1 if the patch set number isn't specified or * is not an integer.// www. j a v a2 s .com */ int getPatchSetNumber(TaskRepository repository, String url, String taskId) { String taskUrl = TasksUi.getRepositoryConnector(GerritConnector.CONNECTOR_KIND) .getTaskUrl(repository.getUrl(), taskId); String urlQualifiers = StringUtils.remove(url, taskUrl); String[] fragments = StringUtils.split(urlQualifiers, "/"); //$NON-NLS-1$ if (fragments.length > 0) { String patchSetFragment = fragments[0]; try { return Integer.valueOf(patchSetFragment); } catch (NumberFormatException e) { //ignore, the patch fragment simply can't be parsed } } return -1; }
From source file:org.eclipse.mylyn.reviews.core.spi.remote.AbstractDataLocator.java
public IPath getObjectPathFromFilePath(IPath path) { if (getModelPath().isPrefixOf(path)) { String fragment = parseScalingFragment(path); path = path.makeRelativeTo(getModelPath()); path = path.removeFileExtension(); String cleanPath = StringUtils.remove(path.toPortableString(), fragment); return new Path(cleanPath).makeAbsolute(); }// w ww .j a v a 2 s.c o m return path; }
From source file:org.eclipse.smarthome.binding.homematic.internal.communicator.parser.DisplayOptionsParser.java
@Override public Void parse(Object value) throws IOException { String optionsString = StringUtils.remove(toString(value), ' '); if (optionsString != null) { int idxFirstSep = optionsString.indexOf(","); if (idxFirstSep == -1) { text = optionsString;// ww w. j a va 2 s.com optionsString = ""; } else { text = optionsString.substring(0, idxFirstSep); optionsString = optionsString.substring(idxFirstSep + 1); } String[] options = StringUtils.split(optionsString, ","); String[] availableSymbols = getAvailableSymbols(channel); String[] availableBeepOptions = getAvailableOptions(channel, DATAPOINT_NAME_BEEP); String[] availableBacklightOptions = getAvailableOptions(channel, DATAPOINT_NAME_BACKLIGHT); String[] availableUnitOptions = getAvailableOptions(channel, DATAPOINT_NAME_UNIT); String deviceAddress = channel.getDevice().getAddress(); if (logger.isDebugEnabled()) { logger.debug("Remote control '{}' supports these beep options: {}", deviceAddress, availableBeepOptions); logger.debug("Remote control '{}' supports these backlight options: {}", deviceAddress, availableBacklightOptions); logger.debug("Remote control '{}' supports these unit options: {}", deviceAddress, availableUnitOptions); logger.debug("Remote control '{}' supports these symbols: {}", deviceAddress, symbols); } if (options != null) { for (String parameter : options) { logger.debug("Parsing remote control option '{}'", parameter); beep = getIntParameter(availableBeepOptions, beep, parameter, DATAPOINT_NAME_BEEP, deviceAddress); backlight = getIntParameter(availableBacklightOptions, backlight, parameter, DATAPOINT_NAME_BACKLIGHT, deviceAddress); unit = getIntParameter(availableUnitOptions, unit, parameter, DATAPOINT_NAME_UNIT, deviceAddress); if (ArrayUtils.contains(availableSymbols, parameter)) { logger.debug("Symbol '{}' found for remote control '{}'", parameter, deviceAddress); symbols.add(parameter); } } } } return null; }
From source file:org.eclipse.smarthome.binding.homematic.internal.type.generator.CcuMetadataExtractor.java
/** * Loads all description keys./*w ww . ja v a 2 s. co m*/ */ private Map<String, String> loadDeviceKeys() throws IOException { final Map<String, String> deviceKeys = new TreeMap<String, String>(); new UrlLoader(CCU_URL + DEVICE_KEYS) { @Override public void line(String line) { if (line.startsWith("elvST['")) { line = StringUtils.remove(line, "elvST['"); line = StringUtils.replace(line, "'] = '", "="); line = StringUtils.remove(line, "';"); line = StringUtils.remove(line, "$"); line = StringUtils.remove(line, "{"); line = StringUtils.remove(line, "}"); int count = StringUtils.countMatches(line, "="); if (count > 1) { line = StringUtils.replace(line, "=", "|", 1); } String[] split = StringUtils.split(line, "=", 2); deviceKeys.put(StringUtils.trim(split[0]), StringUtils.trim(split[1])); } } }; return deviceKeys; }
From source file:org.eclipse.smarthome.binding.homematic.internal.type.generator.CcuMetadataExtractor.java
/** * Splits a JSON JavaScript entry./* w w w . j av a 2 s. c o m*/ */ private String[] handleStringTable(String line) { line = StringUtils.remove(line, " \""); line = StringUtils.remove(line, "\","); line = StringUtils.remove(line, "\""); String[] splitted = StringUtils.split(line, ":", 2); return splitted.length != 2 ? null : splitted; }
From source file:org.eclipse.smarthome.binding.homematic.internal.type.generator.CcuMetadataExtractor.java
/** * Transforms a string for a Java property file. *///from ww w.j a va2 s .com private String unescape(String str) { str = StringUtils.replace(str, "%FC", ""); str = StringUtils.replace(str, "%DC", ""); str = StringUtils.replace(str, "%E4", ""); str = StringUtils.replace(str, "%C4", ""); str = StringUtils.replace(str, "%F6", ""); str = StringUtils.replace(str, "%D6", ""); str = StringUtils.replace(str, "%DF", ""); str = StringUtils.remove(str, " "); str = StringUtils.replace(str, "<br/>", " "); str = StringEscapeUtils.unescapeHtml(str); return str; }
From source file:org.eclipse.smarthome.binding.homematic.internal.type.MetadataUtils.java
/** * Returns the device name for the given device type. */// ww w .j a v a2s . com public static String getDeviceName(HmDevice device) { if (device.isGatewayExtras()) { return getDescription(HmDevice.TYPE_GATEWAY_EXTRAS); } String deviceDescription = null; boolean isTeam = device.getType().endsWith("-Team"); String type = isTeam ? StringUtils.remove(device.getType(), "-Team") : device.getType(); deviceDescription = getDescription(type); if (deviceDescription != null && isTeam) { deviceDescription += " Team"; } return deviceDescription == null ? "No Description" : deviceDescription; }
From source file:org.eclipse.wb.core.gef.MatchingEditPartFactory.java
/** * @param model/*w ww. j a v a 2s . c om*/ * the model to get {@link EditPart}. * @param modelClass * the current {@link Class} of model, of its super-class. * * @return the {@link EditPart} corresponding to <code>modelClass</code>, may be <code>null</code> * , if no match found. */ private EditPart createEditPart(Object model, Class<?> modelClass) { // "Info" suffix { EditPart editPart = createEditPart(model, modelClass, "Info"); if (editPart != null) { return editPart; } } // no suffix { EditPart editPart = createEditPart(model, modelClass, ""); if (editPart != null) { return editPart; } } // special support for inner classes { String modelClassName = modelClass.getName(); if (modelClassName.contains("$")) { modelClassName = StringUtils.remove(modelClassName, "Info"); modelClassName = StringUtils.remove(modelClassName, "$"); EditPart editPart = createEditPart(model, modelClass, modelClassName, ""); if (editPart != null) { return editPart; } } } // not found return null; }