List of usage examples for org.apache.commons.lang3 StringUtils defaultString
public static String defaultString(final String str)
Returns either the passed in String, or if the String is null , an empty String ("").
StringUtils.defaultString(null) = "" StringUtils.defaultString("") = "" StringUtils.defaultString("bat") = "bat"
From source file:ca.uhn.fhir.model.base.composite.BaseIdentifierDt.java
/** * {@inheritDoc}// ww w. java2 s .c om */ @Override public String getValueAsQueryToken(FhirContext theContext) { UriDt system = (UriDt) getSystemElement(); StringDt value = (StringDt) getValueElement(); if (system.getValueAsString() != null) { return ParameterUtil.escape(StringUtils.defaultString(system.getValueAsString())) + '|' + ParameterUtil.escape(value.getValueAsString()); } else { return ParameterUtil.escape(value.getValueAsString()); } }
From source file:de.micromata.genome.gwiki.page.impl.GWikiChangeCommentEditorArtefakt.java
@Override public void onSave(GWikiContext ctx) { String text = ctx.getRequestParameter(partName + ".wikiText"); String oldText = textPage.getStorageData(); String ntext;//from ww w . j av a2s .c o m String uname = ctx.getWikiWeb().getAuthorization().getCurrentUserName(ctx); int prevVersion = elementToEdit.getElementInfo().getProps().getIntValue(GWikiPropKeys.VERSION, 0); if (StringUtils.isNotBlank(text) == true) { Date now = new Date(); ntext = "{changecomment:modifiedBy=" + uname + "|modifiedAt=" + GWikiProps.date2string(now) + "|version=" + (prevVersion + 1) + "}\n" + text + "\n{changecomment}\n" + StringUtils.defaultString(oldText); } else { ntext = oldText; } ntext = StringUtils.trimToNull(ntext); textPage.setStorageData(ntext); }
From source file:com.netsteadfast.greenstep.util.SystemSettingConfigureUtils.java
public static String getMailDefaultFromValue() { SysCodeVO sysCode = getMailDefaultFrom(); return StringUtils.defaultString(sysCode.getParam1()); }
From source file:it.reexon.lib.gpx.runtastic.parser.GpxRuntasticParser.java
private void analyzesNode(Node node) throws DOMException, URISyntaxException { if (node == null) return;/*from www . j a v a2s. com*/ String nodeName = node.getNodeName(); if (StringUtils.defaultString(nodeName).equalsIgnoreCase("metadata")) { analyzesMetadataNode(node); } else if (StringUtils.defaultString(nodeName).equalsIgnoreCase("trk")) { analyzesTrkNode(node); } }
From source file:it.reexon.lib.gpx.parser.GpxParser.java
private Serializable analyzesNode(Node node) throws DOMException, URISyntaxException { if (node == null) return null; String nodeName = node.getNodeName(); if (StringUtils.defaultString(nodeName).equalsIgnoreCase("metadata")) { analyzesMetadataNode(node);// w w w . ja va 2 s . com } else if (StringUtils.defaultString(nodeName).equalsIgnoreCase("trk")) { analyzesTrkNode(node); } return null; }
From source file:de.micromata.genome.gwiki.page.impl.wiki.macros.GWikiOrphanLinksMacro.java
@Override public boolean renderImpl(final GWikiContext wikiContext, MacroAttributes attrs) { String se = StringUtils.defaultString(searchExpression); Iterable<GWikiElementInfo> webInfos = wikiContext.getWikiWeb().getElementInfos(); if (StringUtils.isNotEmpty(se) == true) { List<SearchResult> sr = new ArrayList<SearchResult>(wikiContext.getWikiWeb().getElementInfoCount()); for (GWikiElementInfo wi : webInfos) { sr.add(new SearchResult(wi)); }//from www . jav a 2 s. c o m SearchQuery query = new SearchQuery(se, true, sr); query.setSearchOffset(0); query.setMaxCount(10000); QueryResult qr = wikiContext.getWikiWeb().getContentSearcher().search(wikiContext, query); List<GWikiElementInfo> res = new ArrayList<GWikiElementInfo>(qr.getFoundItems()); for (SearchResult sres : qr.getResults()) { res.add(sres.getElementInfo()); } webInfos = res; } final Map<String, Set<String>> missingLinks = new TreeMap<String, Set<String>>(); for (GWikiElementInfo ei : webInfos) { GWikiElement el = wikiContext.getWikiWeb().getElement(ei); Map<String, GWikiArtefakt<?>> m = new HashMap<String, GWikiArtefakt<?>>(); final Set<String> mll = new TreeSet<String>(); if (StringUtils.isNotEmpty(ei.getParentId()) == true) { if (wikiContext.getWikiWeb().findElementInfo(ei.getParentId()) == null) { mll.add(ei.getParentId()); } } el.collectParts(m); for (GWikiArtefakt<?> a : m.values()) { if (a instanceof GWikiWikiPageArtefakt) { GWikiWikiPageArtefakt w = (GWikiWikiPageArtefakt) a; if (w.compileFragements(wikiContext) == false) { continue; } if (w.getCompiledObject() == null) { continue; } w.getCompiledObject().iterate(new GWikiSimpleFragmentVisitor() { @Override public void begin(GWikiFragment fragment) { if (fragment instanceof GWikiFragmentLink) { GWikiFragmentLink lnk = (GWikiFragmentLink) fragment; String t = lnk.getTargetPageId(); if (t == null) { return; } if (wikiContext.getWikiWeb().findElementInfo(t) == null) { mll.add(t); } } } }, null); } if (mll.isEmpty() == false) { missingLinks.put(ei.getId(), mll); } } } for (Map.Entry<String, Set<String>> me : missingLinks.entrySet()) { wikiContext.append(wikiContext.renderLocalUrl(me.getKey())); wikiContext.append(" <a href=\"" + wikiContext.localUrl("edit/EditPage") + "?pageId=" + me.getKey() + "\">(" + wikiContext.getTranslated("gwiki.macro.orphan.edit") + ")</a>"); wikiContext.append(": "); boolean first = true; for (String tl : me.getValue()) { if (first == false) { wikiContext.append(", "); } first = false; wikiContext.append(tl); } wikiContext.append("<br/>\n"); } return true; }
From source file:de.micromata.genome.gwiki.page.impl.wiki.macros.GWikiHtmlBodyMacro.java
@Override public Collection<GWikiFragment> getFragments(GWikiMacroFragment macroFrag, GWikiWikiTokens tks, GWikiWikiParserContext ctx) {//from w ww .j av a 2 s.com Collection<GWikiFragment> frags = new ArrayList<GWikiFragment>(); macroFrag .addChild(new GWikiFragmentUnsecureHtml(StringUtils.defaultString(macroFrag.getAttrs().getBody()))); frags.add(macroFrag); return frags; }
From source file:io.github.robwin.swagger2markup.utils.ParameterUtils.java
public static String getDefaultValue(Parameter parameter) { Validate.notNull(parameter, "property must not be null!"); String defaultValue = ""; if (parameter instanceof AbstractSerializableParameter) { AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter) parameter; defaultValue = serializableParameter.getDefaultValue(); }//from w w w . j a v a 2 s.co m return StringUtils.defaultString(defaultValue); }
From source file:de.blizzy.documentr.web.filter.AuthenticationCreationTimeFilter.java
private int getHashCode(Authentication authentication) { int result = StringUtils.defaultString(authentication.getName()).hashCode(); for (GrantedAuthority authority : authentication.getAuthorities()) { result ^= authority.hashCode();/*w ww. jav a 2s. co m*/ } return result; }
From source file:AIR.Common.Threading.BoundedThreadPool.java
public BoundedThreadPool(int threadCount, String threadPoolName, int highWaterMark, int lowWaterMark, IThreadPoolStatsRecorder statsRecorder) { if (threadCount <= 0) { threadCount = Math.max(_numberOfProcessors, 2); }/*from w w w . j a va 2 s.c o m*/ _name = StringUtils.defaultString(threadPoolName); _taskQHighWaterMark = highWaterMark <= 0 ? Integer.MAX_VALUE : highWaterMark; _taskQLowWaterMark = lowWaterMark <= 0 ? highWaterMark : lowWaterMark; if (lowWaterMark > highWaterMark) { throw new IllegalArgumentException("The low watermark cannot be larger than the high watermark"); } if (statsRecorder != null) { statsRecorder.setThreadPool(this); } _statsRecorder = statsRecorder; _taskQueue = new ArrayBlockingQueue<>(_taskQHighWaterMark, true); ThreadFactory threadFactory = new NamedThreadFactory(); _workerThreadPool = new ThreadPoolExecutor(threadCount, threadCount, 0, TimeUnit.NANOSECONDS, _taskQueue, threadFactory); synchronized (_statusLock) { _workerThreadPool.prestartAllCoreThreads(); _status = ThreadPoolStatus.Active; } }