List of usage examples for org.apache.commons.lang StringUtils trimToEmpty
public static String trimToEmpty(String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null
.
From source file:gov.nih.nci.firebird.web.action.sponsor.protocol.AbstractModifyProtocolAction.java
/** * @return parse agentList into individual agent Names. *///from w w w.ja v a 2s. c o m Set<String> getAgentNameSet() { Set<String> agentNameSet = new HashSet<String>(); agentList = StringUtils.trimToEmpty(agentList); for (String agentName : Splitter.on(',').omitEmptyStrings().trimResults().split(agentList)) { if (agentName.length() <= ProtocolAgent.MAX_AGENT_LENGTH) { agentNameSet.add(agentName); } else { addFieldError("agentList", getText("sponsor.protocol.agents.error", agentName)); } } return agentNameSet; }
From source file:com.npower.dm.util.TestNumberGenerator.java
public void testStringUtils() throws Exception { String a = null;// ww w . j a v a 2 s . c o m String result = StringUtils.trimToEmpty(a); assertEquals("", result); a = " aaa "; result = StringUtils.trimToEmpty(a); assertEquals("aaa", result); a = ""; result = StringUtils.trimToEmpty(a); assertEquals("", result); }
From source file:com.edgenius.wiki.gwt.server.PageUtil.java
public static void copyModelToPage(PageModel value, AbstractPage page, RenderService renderService) { // requireNotified // public String creator; // public String modifier; // public Date modifiedDate; page.setPageUuid(value.pageUuid);/*from w w w . j a v a 2 s .c o m*/ Space space = new Space(); space.setUnixName(value.spaceUname); page.setSpace(space); page.setTitle(StringUtils.trimToEmpty(value.title)); // page.setUnixName(WikiUtil.getPageUnixname(value.title)); page.setVersion(value.pageVersion); if (value.linkedBlogs != null && value.linkedBlogs.size() > 0 && (page instanceof Draft || page instanceof Page)) { PageProgress progress; if (page instanceof Draft) { progress = ((Draft) page).getPageProgress(); if (progress == null) { progress = new PageProgress(); ((Draft) page).setPageProgress(progress); } } else { progress = ((Page) page).getPageProgress(); if (progress == null) { progress = new PageProgress(); ((Page) page).setPageProgress(progress); } } List<BlogPostMeta> postList = progress.getLinkExtInfoObject(); if (postList == null) { postList = new ArrayList<BlogPostMeta>(); } for (BlogMeta blog : value.linkedBlogs) { if (blog.getPostValue() != null) postList.add(blog.getPostValue()); } //must reset as it not simple set method - it will convert object to XML stream progress.setLinkExtInfoObject(postList); } //so far, only create/createHome will bring back ParentPageTitle. Otherwise it is null. if (value.parentPageUuid != null) { Page parent = new Page(); parent.setPageUuid(value.parentPageUuid); parent.setSpace(space); page.setParent(parent); } // page.setType(value.type); page.setAttribute(value.attribute); page.setVisibleAttachmentNodeList(value.visibleAttachments); if (page instanceof Page) { PageContent pageContent = new PageContent(); if (value.isRichContent) { pageContent.setContent(renderService.renderHTMLtoMarkup(value.spaceUname, value.content)); } else { pageContent.setContent(value.content); } ((Page) page).setContent(pageContent); ((Page) page).setTagString(value.tagString); ((Page) page).setNewPageType(value.newPageType); } else { DraftContent pageContent = new DraftContent(); if (value.isRichContent) { pageContent.setContent(renderService.renderHTMLtoMarkup(value.spaceUname, value.content)); } else { pageContent.setContent(value.content); } ((Draft) page).setContent(pageContent); //does not set tag for draft } //page attachment if (value.attachmentList != null) { List<FileNode> attachments = new ArrayList<FileNode>(); for (Iterator<String> iter = value.attachmentList.iterator(); iter.hasNext();) { String nodeUuid = iter.next(); FileNode node = new FileNode(); node.setNodeUuid(nodeUuid); attachments.add(node); } page.setAttachments(attachments); } }
From source file:com.bluexml.side.form.clazz.utils.ClassDiagramUtils.java
/** * Return Association Name//w ww. j av a 2s . c om * * @param ass * @param useSource * @return */ public static String getAssociationName(Association ass, AssociationEnd target) { String id = ass.getName(); id += StringUtils.trimToEmpty(target.getName()); return id; }
From source file:com.sinosoft.one.mvc.scanner.ModuleResourceProviderImpl.java
protected void checkModuleResourceCandidate(Local local, FileObject root, FileObject topModuleFile, FileObject candidate) throws IOException { String relative = topModuleFile.getName().getRelativeName(candidate.getName()); String mappingPath = null;/* w w w . j ava2 s . co m*/ String[] interceptedAllow = null; String[] interceptedDeny = null; ModuleResource parentModule = local.moduleResourceMap.get(candidate.getParent()); // mvc.propertiescontrollersmodule.path? FileObject mvcPropertiesFile = candidate.getChild("mvc.properties"); if (mvcPropertiesFile != null && mvcPropertiesFile.exists()) { Properties p = new Properties(); InputStream in = mvcPropertiesFile.getContent().getInputStream(); p.load(in); in.close(); // controllers=ignored... String ignored = p.getProperty(CONF_MODULE_IGNORED, "false").trim(); if ("true".equalsIgnoreCase(ignored) || "1".equalsIgnoreCase(ignored)) { if (logger.isInfoEnabled()) { logger.info("Ignored module(include submodules) by mvc.properties[ignored=" + ignored + "]: " + candidate); } return; } mappingPath = p.getProperty(CONF_MODULE_PATH); if (logger.isDebugEnabled()) { logger.debug("[moduleResource] get path form property:" + mappingPath); } if (mappingPath != null) { mappingPath = mappingPath.trim(); String parentModulePlaceHolder = "${" + CONF_PARENT_MODULE_PATH + "}"; //?parent.model.path if (mappingPath.indexOf(parentModulePlaceHolder) != -1) { String parentModulePath = ""; if (candidate.getParent() != null) { parentModulePath = (parentModule == null) ? "" : parentModule.getMappingPath(); } mappingPath = mappingPath.replace(parentModulePlaceHolder, parentModulePath); } if (mappingPath.length() != 0 && !mappingPath.startsWith("/")) { if (parentModule != null) { mappingPath = parentModule.getMappingPath() + "/" + mappingPath; } else if (StringUtils.isNotEmpty(relative)) { mappingPath = relative + "/" + mappingPath; } else { mappingPath = "/" + mappingPath; } } mappingPath = MvcStringUtil.mappingPath(mappingPath); if (logger.isDebugEnabled()) { logger.debug("[modelResourceProvide]mappingPath:" + mappingPath); } } //interceptedAllow?interceptedDeny String interceptedAllowStrings = p.getProperty(CONF_INTERCEPTED_ALLOW); interceptedAllowStrings = StringUtils.trimToEmpty(interceptedAllowStrings); if (interceptedAllowStrings.length() > 0) { interceptedAllow = StringUtils.split(interceptedAllowStrings, ","); } String interceptedDenyStrings = p.getProperty(CONF_INTERCEPTED_DENY); interceptedDenyStrings = StringUtils.trimToEmpty(interceptedDenyStrings); if (interceptedDenyStrings.length() > 0) { interceptedDeny = StringUtils.split(interceptedDenyStrings, ","); } } // if (mappingPath == null) { if (parentModule != null) { mappingPath = parentModule.getMappingPath() + "/" + candidate.getName().getBaseName(); } else { mappingPath = ""; } } ModuleResource moduleResource = new ModuleResource(); moduleResource.setMappingPath(mappingPath); moduleResource.setModuleUrl(candidate.getURL()); moduleResource.setRelativePath(MvcStringUtil.relativePathToModulePath(relative)); moduleResource.setParent(parentModule); if (interceptedAllow != null) { moduleResource.setInterceptedAllow(interceptedAllow); } if (interceptedDeny != null) { moduleResource.setInterceptedDeny(interceptedDeny); } local.moduleResourceMap.put(candidate, moduleResource); local.moduleResourceList.add(moduleResource); if (logger.isDebugEnabled()) { logger.debug("found module '" + mappingPath + "' in " + candidate.getURL()); } FileObject[] children = candidate.getChildren(); for (FileObject child : children) { if (child.getType().hasContent() && !child.getType().hasChildren()) { handlerModuleResource(local, root, candidate, child); } } for (FileObject child : children) { if (child.getType().hasChildren()) { checkModuleResourceCandidate(local, root, topModuleFile, child); } } }
From source file:com.prowidesoftware.swift.model.field.Field50H.java
/** * Get the Name And Address as a concatenation of component2 to component5. * @return the Name And Address from components */// ww w .j av a2s . c om public String getNameAndAddress() { StringBuilder result = new StringBuilder(); for (int i = 2; i < 6; i++) { if (StringUtils.isNotBlank(getComponent(i))) { if (result.length() > 0) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); } result.append(StringUtils.trimToEmpty(getComponent(i))); } } return result.toString(); }
From source file:com.prowidesoftware.swift.model.field.Field70D.java
/** * Get the Narrative as a concatenation of component2 to component7. * @return the Narrative from components *///from w w w . j a va2 s . c om public String getNarrative() { StringBuilder result = new StringBuilder(); for (int i = 2; i < 8; i++) { if (StringUtils.isNotBlank(getComponent(i))) { if (result.length() > 0) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); } result.append(StringUtils.trimToEmpty(getComponent(i))); } } return result.toString(); }
From source file:com.egt.ejb.toolkit.ToolKitUtils.java
private static Comparator<Pagina> applicationPagesComparator() { return new Comparator<Pagina>() { @Override/* w w w .j a va2 s.c om*/ public int compare(Pagina x, Pagina y) { String nx = StringUtils.trimToEmpty(x.getNombrePagina()); String ny = StringUtils.trimToEmpty(y.getNombrePagina()); int c = nx.compareToIgnoreCase(ny); return c == 0 ? x.compareTo(y) : c; } }; }
From source file:com.bluexml.side.clazz.edit.ui.actions.initializer.PortalModelInitializer.java
private PortletInternal createPortletInternal(Portal portal, int eobjectIndex, String initializerIndex, InternalPortletType type, String subType) throws Exception { PortletInternal portletInternal = PortalFactory.eINSTANCE.createPortletInternal(); portletInternal.setType(type);/*w ww . j a v a2 s.c o m*/ portal.getInternalPortletSet().add(portletInternal); // get initialized View if (type.equals(InternalPortletType.FORM)) { if (StringUtils.trimToEmpty(subType).equals("search")) { setSearchForm(eobjectIndex, initializerIndex, portletInternal); } else { setForm(eobjectIndex, initializerIndex, portletInternal); } } else if (type.equals(InternalPortletType.VIEW)) { setView(eobjectIndex, initializerIndex, portletInternal); } return portletInternal; }
From source file:com.hangum.tadpole.mongodb.core.editors.dbInfos.comosites.InstanceInformationComposite.java
/** * Show Mongodb System Information//from w w w . j a va 2s. com * * @param commandResult */ public void initMongoDBInfoData(CommandResult commandResult) { String strHost = StringUtils.trimToEmpty(commandResult.getString("host")); String version = StringUtils.trimToEmpty(commandResult.getString("version")); String process = StringUtils.trimToEmpty(commandResult.getString("process")); String pid = StringUtils.trimToEmpty(commandResult.getString("pid")); String uptime = StringUtils.trimToEmpty(commandResult.getString("uptime")); String uptimeMillis = StringUtils.trimToEmpty( TimeUtils.getHoureMinSecString(ENumberUtils.toInt(commandResult.getString("uptimeMillis")))); String uptimeEstimate = StringUtils.trimToEmpty(commandResult.getString("uptimeEstimate")); String localTime = StringUtils.trimToEmpty(commandResult.getString("localTime")); textHost.setText(strHost); textVersion.setText(version); textProcess.setText(process); textPID.setText(pid); textUptime.setText(uptime); textUptimeMillis.setText(uptimeMillis); textUpTimeEstimate.setText(uptimeEstimate); textLocalTime.setText(localTime); }