List of usage examples for org.apache.commons.lang StringUtils normalizeSpace
public static String normalizeSpace(String str)
From source file:com.evolveum.midpoint.schema.TestQueryConvertor.java
private void assertXml(QueryType queryType, String expected) throws SchemaException { MapXNode mapXNode = queryType.getFilter().getFilterClauseXNode(); String realWrapped = getPrismContext().serializeXNodeToString(new RootXNode(new QName("query"), mapXNode), PrismContext.LANG_XML);/* w w w .j av a 2 s . c o m*/ // primitive but effective method int start = realWrapped.indexOf('>') + 1; int end = realWrapped.lastIndexOf('<'); String real = realWrapped.substring(start, end); String expNorm = StringUtils.normalizeSpace(expected); String realNorm = StringUtils.normalizeSpace(real); if (!expNorm.equals(realNorm)) { String m = "Serialized query is not correct. Expected:\n" + expected + "\nActual:\n" + real + "\n\nNormalized versions:\n\n" + "Expected: " + expNorm + "\nActual: " + realNorm + "\n"; LOGGER.error("{}", m); throw new AssertionError(m); } }
From source file:com.haulmont.cuba.web.gui.components.WebAbstractTable.java
@Override public String getStyleName() { String styleName = super.getStyleName(); for (String internalStyle : internalStyles) { styleName = styleName.replace(internalStyle, ""); }/*from ww w . j av a 2s .c o m*/ return StringUtils.normalizeSpace(styleName); }
From source file:com.evolveum.midpoint.repo.sql.QueryInterpreter2Test.java
License:asdf
private void assertEqualsIgnoreWhitespace(String expected, String real) { LOGGER.info("exp. query>\n{}\nreal query>\n{}", expected, real); String expNorm = StringUtils.normalizeSpace(expected); String realNorm = StringUtils.normalizeSpace(real); if (!expNorm.equals(realNorm)) { String m = "Generated query is not correct. Expected:\n" + expected + "\nActual:\n" + real + "\n\nNormalized versions:\n\n" + "Expected: " + expNorm + "\nActual: " + realNorm + "\n"; LOGGER.error("{}", m); throw new AssertionError(m); }/* w ww . j a v a 2 s. co m*/ }
From source file:ninja.text.TextImpl.java
@Override public Text normalizeSpaces() { return Text.of(StringUtils.normalizeSpace(data.toString())); }
From source file:org.xwiki.contrib.mailarchive.timeline.internal.TimeLineGenerator.java
/** * Formats a timeline bubble content, ie html presenting list of mails related to a given topic. * /* w w w.j a va 2 s . com*/ * @param topicid * @param topicsubject * @return * @throws QueryException * @throws XWikiException */ protected TreeMap<Long, TopicEventBubble> getTopicMails(String topicid, String topicsubject) throws QueryException, XWikiException { // TODO there should/could be an api to retrieve mails related to a topic somewhere else than in timeline // generator ... logger.debug("Retrieving emails linked to topic with id " + topicid); final TreeMap<Long, TopicEventBubble> bubblesInfo = new TreeMap<Long, TopicEventBubble>(); String xwql_topic = "select doc.fullName, mail.date, mail.messagesubject ,mail.from from Document doc, " + "doc.object(" + XWikiPersistence.CLASS_MAILS + ") as mail where mail.topicid='" + topicid + "' and doc.space='MailArchiveItems' order by mail.date asc"; final List<Object[]> msgs = queryManager.createQuery(xwql_topic, Query.XWQL).execute(); String previousSubject = StringUtils.normalizeSpace(topicsubject); for (Object[] msg : msgs) { final String docfullname = (String) msg[0]; final Date maildate = (Date) msg[1]; String mailmessagesubject = (String) msg[2]; final String mailfrom = (String) msg[3]; IMAUser parsedUser = mailUtils.parseUser(mailfrom, config.isMatchLdap()); String user = parsedUser.getDisplayName(); String link = this.userStatsUrl + "?user=" + mailfrom; if (StringUtils.isNotEmpty(parsedUser.getWikiProfile())) { link += "&wikiUser=" + parsedUser.getWikiProfile(); } mailmessagesubject = StringUtils.normalizeSpace(mailmessagesubject); String subject = mailmessagesubject.replace(previousSubject, "..."); previousSubject = mailmessagesubject; TopicEventBubble bubbleEvent = new TopicEventBubble(); bubbleEvent.date = maildate; bubbleEvent.url = xwiki.getDocument(docResolver.resolve(docfullname), context).getURL("view", context); bubbleEvent.subject = subject; bubbleEvent.link = link; bubbleEvent.user = user; bubblesInfo.put(maildate.getTime(), bubbleEvent); } return bubblesInfo; }
From source file:org.xwiki.contrib.mailarchive.timeline.internal.TimeLineGenerator.java
/** * Formats a timeline bubble content, ie html presenting list of mails related to a given topic. * /* www . j a v a2s. co m*/ * @param topicid * @param topicsubject * @return * @throws QueryException * @throws XWikiException */ protected String getExtract(String topicid) throws QueryException, XWikiException { String extract = ""; logger.debug("Retrieving first email linked to topic with id " + topicid); String xwql_topic = "select mail.body, mail.bodyhtml from Document doc, " + "doc.object(" + XWikiPersistence.CLASS_MAILS + ") as mail where mail.topicid='" + topicid + "' and doc.space='MailArchiveItems' order by mail.date asc"; final List<Object[]> msgs = queryManager.createQuery(xwql_topic, Query.XWQL).setLimit(1).execute(); if (CollectionUtils.isNotEmpty(msgs)) { final String body = (String) msgs.get(0)[0]; final String bodyhtml = (String) msgs.get(0)[1]; extract = body; try { DecodedMailContent decoded = mailUtils.decodeMailContent(bodyhtml, body, true); if (decoded != null) { if (decoded.isHtml() && StringUtils.isEmpty(decoded.getText())) { extract = textUtils.htmlToPlainText(bodyhtml); } else { extract = decoded.getText(); } } } catch (IOException e) { Log.warn("Could not decoded HTML content {}", e); } extract = StringUtils.normalizeSpace(extract); extract = StringUtils.abbreviate(extract, 200); } return extract; }
From source file:org.yamj.core.api.model.SqlScalars.java
/** * Get the SQL as a string * * @return */ public String getSql() { return StringUtils.normalizeSpace(sql.toString()); }
From source file:technology.tikal.string.util.StringNormalizer.java
/** * remplazar acentos//w w w . j ava 2 s .c o m * todo a minusculas * quita los espacios extras. * elimina los signos de puntuacion: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ */ public static String normalize(String input) { if (input == null) { return null; } String result = input; result = UNDESIRABLES.matcher(result).replaceAll(""); result = result.toLowerCase(); result = StringUtils.normalizeSpace(result); result = StringUtils.replaceChars(result, '\u00E1', 'a'); result = StringUtils.replaceChars(result, '\u00ED', 'i'); result = StringUtils.replaceChars(result, '\u00FA', 'u'); result = StringUtils.replaceChars(result, '\u00E9', 'e'); result = StringUtils.replaceChars(result, '\u00F3', 'o'); return result; }