List of usage examples for org.apache.commons.lang3 StringUtils strip
public static String strip(final String str)
Strips whitespace from the start and end of a String.
This is similar to #trim(String) but removes whitespace.
From source file:ch.cyberduck.core.ftp.FTPStatListService.java
protected List<String> parse(final int response, final String[] reply) { final List<String> result = new ArrayList<String>(reply.length); for (final String line : reply) { // Some servers include the status code for every line. if (line.startsWith(String.valueOf(response))) { try { String stripped = line; stripped = StringUtils.strip( StringUtils.removeStart(stripped, String.valueOf(String.format("%d-", response)))); stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(response))); result.add(stripped);//from w ww .j a v a 2 s .c om } catch (IndexOutOfBoundsException e) { log.error(String.format("Failed parsing line %s", line), e); } } else { result.add(StringUtils.strip(line)); } } return result; }
From source file:aiai.ai.launchpad.beans.Experiment.java
public void strip() { name = StringUtils.strip(name); description = StringUtils.strip(description); code = StringUtils.strip(code); }
From source file:io.cloudslang.content.utils.OtherUtilities.java
/** * Given an ip string, it checks if it's a valid ip with a regex (see ipPattern attribute) * * @param ipStr the string to check if it's a valid ip * @return true if it's a valid ip, false otherwise *///from ww w. ja v a 2 s . com public static boolean isValidIp(@NotNull final String ipStr) { return ipPattern.matcher(StringUtils.strip(ipStr)).matches(); }
From source file:englishlearning.util.handler.ArticlesListHandler.java
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (qName.equalsIgnoreCase("item")) { try {// w w w .java 2s . c o m articles.add(__articleBuilder.build()); } finally { __articleBuilder = null; } } else if (__articleBuilder != null) { if (qName.equalsIgnoreCase("title")) { __articleBuilder.title(__buffer.toString()); } else if (qName.equalsIgnoreCase("description")) { String data = unescapeHtml3(StringUtils.strip(__buffer.toString()).replaceAll("\\[.*?\\]", "") .replace(String.valueOf((char) 160), "").trim()).replaceAll("(?m)^[ \\t]*\\r?\\n", ""); __articleBuilder.description(StringUtils.join(data.split(" ", 101), " ", 0, 99) + "..."); __articleBuilder.content(data); } else if (qName.equalsIgnoreCase("link")) { __articleBuilder.link(__buffer.toString()); } else if (qName.equalsIgnoreCase("guid")) { __articleBuilder.guid(__buffer.toString()); } else if (qName.equalsIgnoreCase("category")) { __articleBuilder.tags(__buffer.toString()); } } __field = Field.NIL; }
From source file:ca.phon.app.session.editor.view.tier_management.actions.NewTierAction.java
@Override public void hookableActionPerformed(ActionEvent e) { TierEditorDialog newTierDialog = new TierEditorDialog(false); TierInfoEditor tierEditor = newTierDialog.getTierEditor(); newTierDialog.add(tierEditor);//from www . j a v a 2 s . c om newTierDialog.setTitle("New Tier"); newTierDialog.setModal(true); newTierDialog.pack(); if (newTierDialog.showDialog()) { final SessionEditor editor = getEditor(); final Session session = editor.getSession(); // get tier info String tierName = tierEditor.getTierName(); tierName = StringUtils.strip(tierName); if (tierName.length() == 0) { return; } boolean tierExists = false; if (SystemTierType.isSystemTier(tierName)) { tierExists = true; } else { for (TierDescription td : session.getUserTiers()) { if (td.getName().equals(tierName)) { tierExists = true; break; } } } if (tierExists) { final Toast toast = ToastFactory .makeToast("A tier with name " + tierEditor.getTierName() + " already exists."); toast.start(tierEditor); return; } // create tier final TierDescription tierDescription = tierEditor.createTierDescription(); final TierViewItem tierViewItem = tierEditor.createTierViewItem(); final AddTierEdit edit = new AddTierEdit(editor, tierDescription, tierViewItem); editor.getUndoSupport().postEdit(edit); } }
From source file:ca.phon.util.resources.ClassLoaderHandler.java
/** * Load resource list from the give resource file. * /* w w w. ja v a2s .c o m*/ * @param file */ public void loadResourceFile(String resFile) { try { final Enumeration<URL> resURLS = getClassLoader().getResources(resFile); while (resURLS.hasMoreElements()) { final URL resURL = resURLS.nextElement(); // open file and read in one url at a time final BufferedReader in = new BufferedReader(new InputStreamReader(resURL.openStream())); String line = null; while ((line = in.readLine()) != null) { final String resVal = StringUtils.strip(line); if (resVal.length() > 0) { addResource(resVal); } } in.close(); } } catch (IOException e) { LOGGER.severe(e.getMessage()); } }
From source file:com.wxine.android.model.Community.java
public Set<String> getScopes() { try {//from w w w .ja va 2s . c o m String[] array = scope.split(","); for (String a : array) { if (StringUtils.isNotBlank(a)) { scopes.add(StringUtils.trim(StringUtils.strip(a))); } } } catch (Exception e) { } return scopes; }
From source file:ca.phon.app.query.report.ReportTreeCellRenderer.java
@Override public Component getTreeCellRendererComponent(JTree arg0, Object arg1, boolean arg2, boolean arg3, boolean arg4, int arg5, boolean arg6) { JLabel lbl = (JLabel) super.getTreeCellRendererComponent(arg0, arg1, arg2, arg3, arg4, arg5, arg6); Section section = (Section) arg1;//from w ww . j a v a2 s. c o m if (arg1 == arg0.getModel().getRoot()) { lbl.setIcon(rptIcon); } else { lbl.setIcon(icons.get(section.getClass())); } String lblText = StringUtils.strip(section.getName()); if (lblText == null || lblText.length() == 0) { lblText = "<html><i>Untitled</i></html>"; } lbl.setText(lblText); // if(arg1 instanceof ReportDesign) { // ReportDesign report = (ReportDesign)arg1; // lbl.setText(report.getName()); // lbl.setIcon(rptIcon); // } else { // Section section = (Section)arg1; // lbl.setIcon(icons.get(section.getClass())); // // // lbl.setText(section.getName()); //// if(section instanceof Group) { //// lbl.setText("Group : " + section.getName()); //// } else { //// lbl.setText("Section : " + section.getName()); //// } // } return lbl; }
From source file:com.google.mr4c.config.execution.DirectoryConfig.java
private static String loadValue(Properties props, String name, String defaultValue) { String data = props.getProperty(name); if (data == null) { if (defaultValue == null) { throw new IllegalArgumentException("Missing " + name); } else {/*from w ww . j a v a 2 s .c o m*/ data = defaultValue; } } return StringUtils.strip(data); }
From source file:fr.noop.subtitle.stl.StlParser.java
private String readString(DataInputStream dis, int length, String charset) throws IOException { byte[] bytes = new byte[length]; dis.readFully(bytes, 0, length);/*from w w w.j a v a 2 s . c o m*/ // Remove spaces at start and end of the string return StringUtils.strip(new String(bytes, charset)); }