List of usage examples for org.apache.commons.lang StringUtils trim
public static String trim(String str)
Removes control characters (char <= 32) from both ends of this String, handling null
by returning null
.
From source file:com.skratchdot.electribe.model.esx.presentation.EsxComposite.java
/** * This takes a list of EObjects and compares the given feature's toString() values. * If the list is empty, an empty string is returned. If the list only contains one * item, or if all the feature's toString() values match, then the toString() value is * returned. If there are differing values for toString(), then the param "multiText" * is returned. If feature is a complex object, then featureLabel can be used to return * a more appropriate label.//from w w w. j a va2 s . c o m * @param list A list of EObjects * @param feature The feature to compare * @param multiText The String to return if the given features toString() values don't match * @param featureLabel Can be null, or a "sub-feature" of feature. * @return */ protected String getMultiString(List<? extends EObject> list, EStructuralFeature feature, String multiText, EStructuralFeature featureLabel) { // Return immediately because an invalid list was passed in if (list == null || list.size() < 1) { return ""; } // Store the firstString (which we will compare all other strings to Object firstObject = list.get(0).eGet(feature); String firstString = getFeatureString(firstObject, featureLabel); // Compare firstString to all other strings Object currentObject = null; String currentString = ""; for (int i = 1; i < list.size(); i++) { currentObject = list.get(i).eGet(feature); currentString = getFeatureString(currentObject, featureLabel); if (!firstString.equals(currentString)) { return multiText; } } // If we made it this far, all strings are the same return StringUtils.trim(firstString); }
From source file:com.mycompany.tgni.analysis.lucene.StopFilter.java
/** * Make stop words set from an external file. * @param stopwordsFile the file to load from. * @return the set of stopwords to use.//from w w w . j a v a 2s . c o m * @throws IOException if thrown. */ public static Set<?> makeStopSet(Version matchVersion, File stopwordsFile) throws IOException { List<String> stopwords = new ArrayList<String>(); BufferedReader swreader = new BufferedReader(new FileReader(stopwordsFile)); String line; while ((line = swreader.readLine()) != null) { if (StringUtils.isEmpty(line) || line.startsWith("#")) { continue; } stopwords.add(StringUtils.trim(line)); } swreader.close(); return StopFilter.makeStopSet(Version.LUCENE_40, stopwords); }
From source file:com.microsoft.alm.plugin.idea.git.ui.pullrequest.CreatePullRequestModel.java
public void setTitle(final String title) { synchronized (this) { this.title = StringUtils.trim(title); }/* w ww .j a v a2 s . c o m*/ setChangedAndNotify(PROP_TITLE); }
From source file:com.da.daum.DaumCafeOneLineParser.java
public List<DaumListVo> setDaumListVoList(String listBody, Map pPageMap) { List<DaumListVo> lst = new ArrayList<DaumListVo>(); DaumListVo vo = null;/* ww w. j av a 2s . com*/ Matcher match_li = pattern_li_noclass.matcher(listBody); while (match_li.find()) { String licomment = match_li.group(1); //System.out.println("setDaumListVoList:"+licomment); if (!licomment.startsWith("<a")) { Matcher match = pattern_atag.matcher(licomment); // System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); vo = setCommentForJavascript(lst, vo, licomment, match); } if (vo == null) { Matcher match = pattern_comment_atag.matcher(licomment); while (match.find()) { String subject = ""; // System.out.println(match); String listurl = match.group(0); //System.out.println("===================listurl:"+listurl+"===================="); String listurl1 = match.group(1); String listurl2 = match.group(2); /*System.out.println("================listurl1:==="+listurl1+"===================="); System.out.println("================listurl2:==="+listurl2+"====================");*/ if (!listurl1.startsWith("#")) { if (listurl1.startsWith("/CHILIL/_memo") && !listurl1.startsWith("/CHILIL/_memo/edit") && !listurl1.startsWith("/CHILIL/_memo/new") && !listurl1.startsWith("/CHILIL/_memo/57780") && !listurl1.startsWith("/CHILIL/_memo/57718")) { listurl2 = match.group(2); String rnum = listurl1; rnum = rnum.replace("/CHILIL/_memo/", ""); rnum = rnum.substring(0, rnum.indexOf("/comments")); /*System.out.println("listurl1:"+listurl1); System.out.println("rnum:"+rnum);*/ if ("57780".equals(rnum) || "57718".equals(rnum)) { continue; } vo = new DaumListVo(); String viewUrl = listurl1; //viewUrl = viewUrl.substring(0,viewUrl.indexOf("', '")); subject = match.group(2); subject = StringUtils.trim(subject); Matcher match_num = pattern_spannum.matcher(subject); subject = subject.replace("<span class=\"point\">[]</span> ", ""); if (subject.indexOf("<span") > 0) { subject = subject.substring(0, subject.indexOf("<span") - 1); //<span class="num">(10)</span> } // System.out.println("subject:"+subject); // subject = subject.trim(); subject = subject.replaceAll("<(/)?([a-zA-Z]*)(\\s[a-zA-Z]*=[^>]*)?(\\s)*(/)?>", ""); subject = subject.replaceAll(" ", ""); subject = subject.replaceAll("\n", "\r\n"); // System.out.println("===================subject:"+subject+"===================="); // vo.setRnum(rnum); vo.setViewUrl(viewUrl); //vo.setContent(licomment); vo.setSubject(subject); if (match_num.find()) { // System.out.println("=====================2=================="); String num = match_num.group(2); //System.out.println(owner); subject = subject + num; vo.setSubject(subject); //System.out.println("subject:"+subject); } Matcher match_owner = pattern_owner.matcher(licomment); vo.setContent(licomment); if (match_owner.find()) { // System.out.println("=====================2=================="); String owner = match_owner.group(2); //System.out.println(owner); vo.setIdAlais(owner); } /*Matcher match_article = pattern_article_body .matcher(licomment); if (match_article.find()) { // System.out.println("=====================3=================="); String article = match_article.group(2); //System.out.println(article); vo.setSubject(article); }*/ Matcher match_dt = pattern_dt.matcher(licomment); if (match_dt.find()) { // System.out.println("=====================4=================="); String dt = match_dt.group(2); //System.out.println(dt); vo.setCreatYmd(dt); } lst.add(vo); } } } } } return lst; }
From source file:info.magnolia.cms.servlets.PropertyInitializer.java
/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) *///from w ww .j a va 2s.c o m public void contextInitialized(ServletContextEvent sce) { final ServletContext context = sce.getServletContext(); String propertiesLocationString = context.getInitParameter(MAGNOLIA_INITIALIZATION_FILE); if (log.isDebugEnabled()) { log.debug("{} value in web.xml is :[{}]", MAGNOLIA_INITIALIZATION_FILE, propertiesLocationString); //$NON-NLS-1$ } if (StringUtils.isEmpty(propertiesLocationString)) { propertiesLocationString = DEFAULT_INITIALIZATION_PARAMETER; } String[] propertiesLocation = StringUtils.split(propertiesLocationString, ','); String servername = null; try { servername = StringUtils.lowerCase(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { log.error(e.getMessage()); } String rootPath = StringUtils.replace(context.getRealPath(StringUtils.EMPTY), "\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$ String webapp = StringUtils.substringAfterLast(rootPath, "/"); //$NON-NLS-1$ File logs = new File(webapp + File.separator + "logs"); File tmp = new File(webapp + File.separator + "tmp"); if (!logs.exists()) { logs.mkdir(); log.debug("Creating " + logs.getAbsoluteFile() + " folder"); } if (!tmp.exists()) { tmp.mkdir(); log.debug("Creating " + tmp.getAbsoluteFile() + " folder"); } if (log.isDebugEnabled()) { log.debug("rootPath is {}, webapp is {}", rootPath, webapp); //$NON-NLS-1$ } for (int j = 0; j < propertiesLocation.length; j++) { String location = StringUtils.trim(propertiesLocation[j]); location = StringUtils.replace(location, "${servername}", servername); //$NON-NLS-1$ location = StringUtils.replace(location, "${webapp}", webapp); //$NON-NLS-1$ File initFile = new File(rootPath, location); if (!initFile.exists() || initFile.isDirectory()) { if (log.isDebugEnabled()) { log.debug("Configuration file not found with path [{}]", //$NON-NLS-1$ initFile.getAbsolutePath()); } continue; } InputStream fileStream; try { fileStream = new FileInputStream(initFile); } catch (FileNotFoundException e1) { log.debug("Configuration file not found with path [{}]", //$NON-NLS-1$ initFile.getAbsolutePath()); return; } try { envProperties.load(fileStream); log.info("Loading configuration at {}", initFile.getAbsolutePath());//$NON-NLS-1$ Log4jConfigurer.initLogging(context, envProperties); new ConfigLoader(context, envProperties); } catch (Exception e) { log.error(e.getMessage(), e); } finally { IOUtils.closeQuietly(fileStream); } return; } log.error(MessageFormat.format( "No configuration found using location list {0}. [servername] is [{1}], [webapp] is [{2}] and base path is [{3}]", //$NON-NLS-1$ new Object[] { ArrayUtils.toString(propertiesLocation), servername, webapp, rootPath })); }
From source file:com.haulmont.cuba.gui.xml.layout.loaders.WindowLoader.java
protected void loadTimer(ComponentsFactory factory, final Window component, Element element) { Timer timer = factory.createTimer(); timer.setXmlDescriptor(element);// w w w .j a v a 2 s . c om timer.setId(element.attributeValue("id")); String delay = element.attributeValue("delay"); if (StringUtils.isEmpty(delay)) { throw new GuiDevelopmentException("Timer 'delay' can't be empty", context.getCurrentFrameId(), "Timer ID", timer.getId()); } int value; try { value = Integer.parseInt(delay); } catch (NumberFormatException e) { throw new GuiDevelopmentException("Timer 'delay' must be numeric", context.getFullFrameId(), ParamsMap.of("Timer delay", delay, "Timer ID", timer.getId())); } if (value <= 0) { throw new GuiDevelopmentException("Timer 'delay' must be greater than 0", context.getFullFrameId(), "Timer ID", timer.getId()); } timer.setDelay(value); timer.setRepeating(Boolean.parseBoolean(element.attributeValue("repeating"))); String onTimer = element.attributeValue("onTimer"); if (StringUtils.isNotEmpty(onTimer)) { String timerMethodName = onTimer; if (StringUtils.startsWith(onTimer, "invoke:")) { timerMethodName = StringUtils.substring(onTimer, "invoke:".length()); } timerMethodName = StringUtils.trim(timerMethodName); addInitTimerMethodTask(timer, timerMethodName); } String autostart = element.attributeValue("autostart"); if (StringUtils.isNotEmpty(autostart) && Boolean.parseBoolean(autostart)) { addAutoStartTimerTask(timer); } timer.setFrame(context.getFrame()); component.addTimer(timer); }
From source file:com.epimorphics.lda.renderers.velocity.VelocityRendering.java
/** expandedVelocityPath returns a list of paths/URLs where Velocity may search for its templates. The path is composed of // ww w .j a v a2 s . c om <ul> <li>any components of the variable _velocityPath <li>the first component of /etc/elda/conf.d/{APP}/_error_pages if any <li>webapp/_error_pages <li>the velocity root default, currently /velocity/. </ul> This allows Elda Common to have error pages built-in that can be overridden in /etc/elda and in turn those can be over-ridden by entries in _velocityPath. @return An array of expanded file paths or other URLs where we will search for Velocity assets */ protected List<String> expandVelocityPath(Bindings b) { List<String> roots = new ArrayList<>(); String userRootPath = b.getAsString(VELOCITY_PATH_CONFIG_PARAM, null); String rootPath = (userRootPath == null ? "" : userRootPath + ",") + etcPath() + webappPath() + defaultVelocityRoot(); for (String pathEntry : StringUtils.split(rootPath, ",")) { pathEntry = StringUtils.trim(pathEntry); String pathURL = b.pathAsURL(pathEntry).toString(); roots.add(pathURL + (pathURL.endsWith("/") ? "" : "/")); } ELog.debug(log, "rootPath '%s'", rootPath); ELog.debug(log, "complete expanded path '%s'", roots); return roots; }
From source file:adalid.core.wrappers.ArtifactWrapper.java
protected String getSomeLabel() { String string = getWordyName(); Entity declaringEntity = _artifact.getDeclaringEntity(); Operation declaringOperation = _artifact.getDeclaringOperation(); Entity declaringOperationEntity = declaringOperation == null ? null : declaringOperation.getDeclaringEntity(); if (_artifact instanceof Property && declaringEntity != null) { Property property = (Property) _artifact; if (property.isNotDeclared()) { } else if (_artifact.equals(declaringEntity.getPrimaryKeyProperty())) { string = labelOf(declaringEntity, KeyProperty.PRIMARY_KEY); } else if (_artifact.equals(declaringEntity.getVersionProperty())) { string = labelOf(declaringEntity, KeyProperty.VERSION); } else if (_artifact.equals(declaringEntity.getBusinessKeyProperty())) { string = labelOf(declaringEntity, KeyProperty.BUSINESS_KEY); } else if (_artifact.equals(declaringEntity.getNumericKeyProperty())) { string = labelOf(declaringEntity, KeyProperty.NUMERIC_KEY); } else if (_artifact.equals(declaringEntity.getCharacterKeyProperty())) { string = labelOf(declaringEntity, KeyProperty.CHARACTER_KEY); } else if (_artifact.equals(declaringEntity.getNameProperty())) { string = labelOf(declaringEntity, KeyProperty.NAME); } else if (_artifact.equals(declaringEntity.getDescriptionProperty())) { string = labelOf(declaringEntity, KeyProperty.DESCRIPTION); } else if (_artifact.equals(declaringEntity.getInactiveIndicatorProperty())) { string = labelOf(declaringEntity, KeyProperty.INACTIVE_INDICATOR); } else if (_artifact.equals(declaringEntity.getUrlProperty())) { string = labelOf(declaringEntity, KeyProperty.URL); } else if (_artifact.equals(declaringEntity.getParentProperty())) { string = labelOf(declaringEntity, KeyProperty.PARENT); } else if (_artifact.equals(declaringEntity.getOwnerProperty())) { string = labelOf(declaringEntity, KeyProperty.OWNER); } else if (_artifact instanceof EntityReference) { string = StrUtils.removeWords(string, EntityReference.class); } else {/*from w w w. j a v a 2s . co m*/ string = StrUtils.removeWords(string, property.getDataType()); } } else if (_artifact instanceof Parameter && declaringOperationEntity != null) { Parameter parameter = (Parameter) _artifact; if (parameter.isNotDeclared()) { } else if (_artifact instanceof EntityReference) { string = StrUtils.removeWords(string, EntityReference.class); } else { string = StrUtils.removeWords(string, parameter.getDataType()); } } string = StringUtils.trim(StringUtils.replace(string, " ", " ")); return StringUtils.isNotBlank(string) ? string : getWordyName(); }
From source file:de.iteratec.iteraplan.model.AbstractHierarchicalEntity.java
public void setName(String name) { this.name = StringUtils.trim(StringUtil.removeIllegalXMLChars(name)); }
From source file:com.hangum.tadpole.manager.core.dialogs.api.APIServiceDialog.java
/** * initialize ui/* w w w . ja v a 2 s . c o m*/ * * @param strArgument */ private void initData(String strArgument) { try { String strReturnResult = ""; //$NON-NLS-1$ // velocity if else . String strSQLs = RESTfulAPIUtils.makeTemplateTOSQL("APIServiceDialog", strSQL, strArgument); //$NON-NLS-1$ // ? ? . for (String strTmpSQL : strSQLs.split(PublicTadpoleDefine.SQL_DELIMITER)) { if (StringUtils.trim(strTmpSQL).equals("")) continue; NamedParameterDAO dao = NamedParameterUtil.parseParameterUtils(userDB, strTmpSQL, strArgument); if (QueryUtils.RESULT_TYPE.JSON.name().equalsIgnoreCase(comboResultType.getText())) { strReturnResult += getSelect(userDB, dao.getStrSQL(), dao.getListParam()) + ","; //$NON-NLS-1$ } else { strReturnResult += getSelect(userDB, dao.getStrSQL(), dao.getListParam()); } } if (QueryUtils.RESULT_TYPE.JSON.name().equalsIgnoreCase(comboResultType.getText())) { strReturnResult = "[" + StringUtils.removeEnd(strReturnResult, ",") + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } textResult.setText(strReturnResult); } catch (Exception e) { logger.error("api exception", e); //$NON-NLS-1$ MessageDialog.openError(getShell(), Messages.get().Error, Messages.get().APIServiceDialog_11 + "\n" + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ } }