List of usage examples for org.apache.commons.lang StringUtils chomp
public static String chomp(String str)
Removes one newline from end of a String if it's there, otherwise leave it alone.
From source file:io.bitgrillr.gocddockerexecplugin.SystemHelper.java
static String getSystemUid() throws IOException, InterruptedException { Process id = Runtime.getRuntime().exec(new String[] { "bash", "-c", "echo \"$(id -u):$(id -g)\"" }); id.waitFor();/* w w w. ja v a 2 s.c om*/ return StringUtils.chomp(IOUtils.toString(id.getInputStream(), StandardCharsets.UTF_8)); }
From source file:cc.kune.core.server.utils.FilenameUtils.java
/** * Chomp the filename using {@link StringUtils.chomp} * /*from w ww . j ava 2s .c o m*/ * @param filename * the filename * @return the filename chomped */ public static String chomp(final String filename) { return StringUtils.chomp(filename); }
From source file:hudson.plugins.clearcase.history.HistoryEntry.java
public String getComment() { return StringUtils.chomp(commentBuilder.toString()); }
From source file:ch.cyberduck.core.threading.BackgroundException.java
public BackgroundException(Host host, Path path, String message, Throwable cause) { super(cause); this.host = host; this.path = path; if (null == message) { this.message = Locale.localizedString("Unknown"); } else if (null == path) { this.message = StringUtils.chomp(message); } else {/*from w ww . jav a2s .c o m*/ try { this.message = MessageFormat.format(StringUtils.chomp(message), path.getName()); } catch (IllegalArgumentException e) { log.warn(String.format("Error parsing message with format %s", e.getMessage())); this.message = StringUtils.chomp(message); } } }
From source file:at.general.solutions.android.ical.parser.ICalParserThread.java
@Override public void run() { super.sendInitMessage(R.string.parsingIcalFile); String[] lines = toParse.split("\n"); super.sendMaximumMessage(lines.length); ICalEvent event = null;/* w ww. ja v a 2s .c om*/ int i = 0; boolean inDescription = false; String description = ""; for (String line : lines) { line = StringUtils.chomp(line); if (event == null) { if (line.contains(ICalTag.EVENT_START)) { event = new ICalEvent(userTimeZone); } inDescription = false; } else if (line.contains(ICalTag.EVENT_END)) { event.setDescription(cleanText(description)); if (event != null && event.getStart() != null) { super.sendProgressMessage(i, event); } event = null; description = ""; inDescription = false; } else { if (line.contains(ICalTag.EVENT_SUMMARY)) { event.setSummary(cleanText(line.substring(ICalTag.EVENT_SUMMARY.length()))); } else if (line.contains(ICalTag.EVENT_DATE_START)) { String dateLine = line.substring(ICalTag.EVENT_DATE_START.length()); event.setStart(parseIcalDate(dateLine)); } else if (line.contains(ICalTag.EVENT_DATE_END)) { String dateLine = line.substring(ICalTag.EVENT_DATE_END.length()); event.setEnd(parseIcalDate(dateLine)); } if (inDescription) { if (line.charAt(0) == ' ') { description += line.substring(1); } } else if (line.contains(ICalTag.EVENT_DESCRIPTION)) { description = line.substring(ICalTag.EVENT_DESCRIPTION.length()); inDescription = true; } else { inDescription = false; } } i++; } super.sendFinishedMessage(); }
From source file:biz.netcentric.cq.tools.actool.configuration.CqActionsMapping.java
public static String getCqActions(final Privilege[] jcrPrivileges, AccessControlManager aclManager) throws AccessControlException, RepositoryException { StringBuilder sb = new StringBuilder(); for (Privilege p : jcrPrivileges) { sb.append(p.getName()).append(","); }//from w w w . j av a 2s . c o m return getCqActions(StringUtils.chomp(sb.toString()), aclManager); }
From source file:com.gs.obevo.db.impl.core.util.MultiLineStringSplitter.java
@Override public MutableList<String> valueOf(String inputString) { inputString += "\n"; // add sentinel to facilitate line split MutableList<SqlToken> sqlTokens = this.tokenParser.parseTokens(inputString); sqlTokens = this.collapseWhiteSpaceAndTokens(sqlTokens); MutableList<String> finalSplitStrings = Lists.mutable.empty(); String currentSql = ""; for (SqlToken sqlToken : sqlTokens) { if (sqlToken.getTokenType() == SqlTokenType.COMMENT || sqlToken.getTokenType() == SqlTokenType.STRING) { currentSql += sqlToken.getText(); } else {//w w w . j a va 2s. co m String pattern = splitOnWholeLine ? "(?i)^" + this.splitToken + "$" : this.splitToken; MutableList<String> splitStrings = Lists.mutable .with(Pattern.compile(pattern, Pattern.MULTILINE).split(sqlToken.getText())); if (splitStrings.isEmpty()) { // means that we exactly match finalSplitStrings.add(currentSql); currentSql = ""; } else if (splitStrings.size() == 1) { currentSql += sqlToken.getText(); } else { splitStrings.set(0, currentSql + splitStrings.get(0)); if (splitOnWholeLine) { if (splitStrings.size() > 1) { splitStrings.set(0, StringUtils.chomp(splitStrings.get(0))); for (int i = 1; i < splitStrings.size(); i++) { String newSql = splitStrings.get(i); if (newSql.startsWith("\n")) { newSql = newSql.replaceFirst("^\n", ""); } else if (newSql.startsWith("\r\n")) { newSql = newSql.replaceFirst("^\r\n", ""); } // Chomping the end of each sql due to the split of the GO statement if (i < splitStrings.size() - 1) { newSql = StringUtils.chomp(newSql); } splitStrings.set(i, newSql); } } } finalSplitStrings.addAll(splitStrings.subList(0, splitStrings.size() - 1)); currentSql = splitStrings.getLast(); } } } if (!currentSql.isEmpty()) { finalSplitStrings.add(currentSql); } // accounting for the sentinel if (finalSplitStrings.getLast().isEmpty()) { finalSplitStrings.remove(finalSplitStrings.size() - 1); } else { finalSplitStrings.set(finalSplitStrings.size() - 1, StringUtils.chomp(finalSplitStrings.getLast())); } return finalSplitStrings; }
From source file:biz.netcentric.cq.tools.actool.configuration.CqActionsMapping.java
public static String getCqActions(final String[] jcrPrivileges, AccessControlManager aclManager) throws AccessControlException, RepositoryException { StringBuilder sb = new StringBuilder(); for (String s : jcrPrivileges) { sb.append(s).append(","); }/*from w ww .j a va 2 s. c o m*/ return getCqActions(StringUtils.chomp(sb.toString()), aclManager); }
From source file:com.htmlhifive.tools.wizard.library.LibraryList.java
/** * ??.//ww w . j av a2 s.c o m */ public void init() { // Default???. for (Category category : libraries.getSiteLibraries().getCategory()) { // License?. if (category.getLicense() != null) { category.setLicense(StringUtils.chomp(category.getLicense())); } // Info. for (Info info : category.getInfo()) { info.setTitle(H5StringUtils.trim(info.getTitle())); info.setDescription(H5StringUtils.trim(info.getDescription())); } // Library?. for (Library library : category.getLibrary()) { // ?LibraryData ??. for (LibraryRef libraryRef : libraries.getDefaultLibraries().getLibraryRef()) { if (libraryRef.getOrg().equals(category.getOrg()) && libraryRef.getName().equals(category.getName()) && libraryRef.getVersion().equals(library.getVersion())) { libraryRefMap.put(libraryRef, library); } } } } // . for (BaseProject baseProject : libraries.getBaseProjects().getBaseProject()) { Info targetInfo = null; Info defaultInfo = null; for (Info info : baseProject.getInfo()) { if (info.getLang() == null || defaultInfo == null) { defaultInfo = info; } if (Locale.getDefault().getLanguage().equals(info.getLang())) { targetInfo = info; } } if (targetInfo == null) { targetInfo = defaultInfo; } if (targetInfo != null) { infoMap.put(targetInfo.getTitle(), targetInfo); infoBaseProjectMap.put(targetInfo.getTitle(), baseProject); } } }
From source file:com.htmlhifive.tools.rhino.comment.js.JSDocCommentNodeParser.java
private JSDocRoot resolveJsDoc() { // ?????(@~~) JSTag currentTag = JSTag.ROOT;//from www. j a v a 2 s . c o m // ??Token? TokenType previousTokenType = TokenType.START; JSDocRoot root = new JSDocRoot(docType); // ?.?????. JSTagNode tempNode = root; int currentLineNum = 0; // ??StringBuilder StringBuilder currentDesc = new StringBuilder(); // JsDoc?. String desc = null; for (Token token : tokenList) { if (currentDesc.length() != 0 && !TokenUtil.isSymbolType(token.getType())) { if (token.getLineNum() != currentLineNum) { // ?????? currentDesc.append(Constants.LINE_SEPARATOR); currentLineNum = token.getLineNum(); } else { // ?????Token?. currentDesc.append(" "); } } switch (token.getType()) { case STRING_LITERAL: resolveStringLiteral(token, currentTag, previousTokenType, tempNode, currentDesc); break; case ANNOTATION: if (tempNode instanceof JSDocRoot) { // ??????desc?JSDoc????desc?? desc = currentDesc.toString(); } else if (tempNode instanceof JSSinglePartTagNode) { // ?????. ((JSSinglePartTagNode) tempNode).setValue(StringUtils.chomp(currentDesc.toString())); } if (tempNode != root) { root.addTagNode(tempNode); } currentDesc = new StringBuilder(); // ?????. JSTag temp = TokenUtil.resolveTagType(token); if (temp != null) { currentTag = temp; } // ?????. tempNode = resolveTagNode(currentTag); break; case TYPE: if (currentTag == null) { // ???????? currentDesc.append(token.getValue()); } if (tempNode instanceof JSTypePartNode) { // Type??????node? ((JSTypePartNode) tempNode).setType(StringUtils.strip(token.getValue(), "{}")); } break; case END: if (tempNode instanceof JSSinglePartTagNode) { // ?????. ((JSSinglePartTagNode) tempNode).setValue(currentDesc.toString()); } root.addTagNode(tempNode); break; case START: case SYMBOL: default: break; } previousTokenType = token.getType(); } // ?. root.setDescription(desc); return root; }