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:com.xpn.xwiki.doc.rcs.XWikiRCSArchive.java
/** * Used to serialize {@link XWikiDocumentArchive}. * // w w w .ja v a2s. c om * @param nodeInfos - collection of {@link XWikiRCSNodeInfo} in any order * @param context - for loading nodes content * @throws XWikiException if can't load nodes content */ public XWikiRCSArchive(Collection<XWikiRCSNodeInfo> nodeInfos, XWikiContext context) throws XWikiException { super(new Object[0], ""); this.nodes.clear(); this.head = null; if (nodeInfos.size() > 0) { for (XWikiRCSNodeInfo nodeInfo : nodeInfos) { XWikiJRCSNode node = new XWikiJRCSNode(nodeInfo.getId().getVersion(), null); node.setAuthor(nodeInfo.getAuthor()); node.setDate(nodeInfo.getDate()); node.setLog(nodeInfo.getComment()); XWikiRCSNodeContent content = nodeInfo.getContent(context); // Ensure we never set the text to NULL since this can cause errors on some DB such as Oracle. node.setText(StringUtils.defaultString(content.getPatch().getContent())); node.setDiff(nodeInfo.isDiff()); this.nodes.put(node.getVersion(), node); } XWikiJRCSNode last = null; for (Iterator it = this.nodes.keySet().iterator(); it.hasNext();) { Version ver = (Version) it.next(); XWikiJRCSNode node = (XWikiJRCSNode) this.nodes.get(ver); if (last != null) { last.setRCSNext(node); } last = node; if (this.head == null) { this.head = node; } } } }
From source file:com.linkedin.urls.Url.java
/** * Note that this includes the fragment/*w w w .j a va 2 s . c o m*/ * @return Formats the url to: [scheme]://[username]:[password]@[host]:[port]/[path]?[query]#[fragment] */ public String getFullUrl() { return getFullUrlWithoutFragment() + StringUtils.defaultString(getFragment()); }
From source file:com.redhat.jenkins.plugins.ci.messaging.JMSMessagingProvider.java
private boolean verify(DocumentContext context, MsgCheck check) { String aVal = ""; String field = StringUtils.prependIfMissing(check.getField(), "$."); try {/*from ww w . j a v a 2s.com*/ aVal = context.read(field).toString(); } catch (PathNotFoundException pnfe) { log.fine(pnfe.getMessage()); return false; } String eVal = StringUtils.defaultString(check.getExpectedValue()); return Pattern.compile(eVal).matcher(aVal).find(); }
From source file:com.netsteadfast.greenstep.util.SystemSettingConfigureUtils.java
public static String getSysFormTemplateFileRewriteValue() { SysCodeVO sysCode = getSysFormTemplateFileRewrite(); return StringUtils.defaultString(sysCode.getParam1()); }
From source file:com.sonicle.webtop.core.util.NotificationHelper.java
/** * Creates strings map (No-Reply version) for notification (custom body) template * @param locale/* w w w . j a v a 2 s.c o m*/ * @param source * @param bodyHeader * @param customBody * @return */ public static Map<String, String> createNoReplayCustomBodyTplStrings(Locale locale, String source, String bodyHeader, String customBody) { HashMap<String, String> map = new HashMap<>(); map.put("bodyHeader", StringUtils.defaultString(bodyHeader)); map.put("customBody", StringUtils.defaultString(customBody)); map.put("footerHeader", MessageFormat.format( WT.lookupResource(CoreManifest.ID, locale, CoreLocaleKey.TPL_NOTIFICATION_NOREPLY_FOOTER_HEADER), source)); map.put("footerMessage", WT.lookupResource(CoreManifest.ID, locale, CoreLocaleKey.TPL_NOTIFICATION_NOREPLY_FOOTER_MESSAGE)); return map; }
From source file:com.szmslab.quickjavamail.receive.MessageLoader.java
/** * MUA????/*from ww w . j a va2s. c om*/ * * @return MUA * @throws MessagingException */ public String getMessageUserAgent() throws MessagingException { String mua = StringUtils.join(message.getHeader("User-Agent"), ","); if (StringUtils.isBlank(mua)) { mua = StringUtils.defaultString(StringUtils.join(message.getHeader("X-Mailer"), ",")); } return mua; }
From source file:com.yqboots.dict.core.DataDictManagerImpl.java
/** * {@inheritDoc}/*from w w w . ja va2s . co m*/ */ @Override public Page<DataDict> getDataDicts(final String wildcardName, final Pageable pageable) { final String searchStr = StringUtils.trim(StringUtils.defaultString(wildcardName)); return dataDictRepository.findByNameLikeIgnoreCase(DBUtils.wildcard(searchStr), pageable); }
From source file:info.magnolia.ui.admincentral.shellapp.pulse.task.data.TaskQuery.java
@Override @SuppressWarnings("unchecked") protected void mapObjectToItem(Task task, Item item) { item.addItemProperty(TaskConstants.ID, new ObjectProperty(task.getId())); item.addItemProperty(TaskConstants.STATUS_PROPERTY_ID, new ObjectProperty(task.getStatus())); item.addItemProperty(TaskConstants.NEW_PROPERTY_ID, new ObjectProperty(task.getStatus() == Task.Status.Created, Boolean.class)); item.addItemProperty(TaskConstants.TASK_PROPERTY_ID, new ObjectProperty(getTaskTitle(task), String.class)); item.addItemProperty(TaskConstants.SENDER_PROPERTY_ID, new ObjectProperty(task.getRequestor(), String.class)); item.addItemProperty(TaskConstants.LAST_CHANGE_PROPERTY_ID, new ObjectProperty(task.getModificationDate(), Date.class)); item.addItemProperty(TaskConstants.ASSIGNED_TO_PROPERTY_ID, new ObjectProperty(StringUtils.defaultString(task.getActorId()), String.class)); String sentTo = ""; if (task.getGroupIds() != null && task.getGroupIds().size() > 0) { sentTo += StringUtils.join(task.getGroupIds(), ","); }//from w ww.j a va 2 s . c o m if (task.getActorIds() != null && task.getActorIds().size() > 0) { sentTo += StringUtils.join(task.getActorIds(), ","); } item.addItemProperty(TaskConstants.SENT_TO_PROPERTY_ID, new ObjectProperty(sentTo, String.class)); }
From source file:ca.uhn.fhir.jpa.provider.BaseJpaProvider.java
public void startRequest(HttpServletRequest theRequest) { if (theRequest == null) { return;//from w w w.j a va2s . c o m } Set<String> headerNames = new TreeSet<String>(); for (Enumeration<String> enums = theRequest.getHeaderNames(); enums.hasMoreElements();) { headerNames.add(enums.nextElement()); } ourLog.debug("Request headers: {}", headerNames); Enumeration<String> forwardedFors = theRequest.getHeaders("x-forwarded-for"); StringBuilder b = new StringBuilder(); for (Enumeration<String> enums = forwardedFors; enums != null && enums.hasMoreElements();) { if (b.length() > 0) { b.append(" / "); } b.append(enums.nextElement()); } String forwardedFor = b.toString(); String ip = theRequest.getRemoteAddr(); if (StringUtils.isBlank(forwardedFor)) { org.slf4j.MDC.put(REMOTE_ADDR, ip); ourLog.debug("Request is from address: {}", ip); } else { org.slf4j.MDC.put(REMOTE_ADDR, forwardedFor); ourLog.debug("Request is from forwarded address: {}", forwardedFor); } String userAgent = StringUtils.defaultString(theRequest.getHeader("user-agent")); org.slf4j.MDC.put(REMOTE_UA, userAgent); }
From source file:com.navercorp.pinpoint.collector.dao.hbase.HbaseMapStatisticsCalleeDao.java
@Override public void update(String calleeApplicationName, ServiceType calleeServiceType, String callerApplicationName, ServiceType callerServiceType, String callerHost, int elapsed, boolean isError) { if (callerApplicationName == null) { throw new NullPointerException("callerApplicationName must not be null"); }//from w ww. j a va 2 s . c o m if (calleeApplicationName == null) { throw new NullPointerException("calleeApplicationName must not be null"); } if (logger.isDebugEnabled()) { logger.debug("[Callee] {} ({}) <- {} ({})[{}]", calleeApplicationName, calleeServiceType, callerApplicationName, callerServiceType, callerHost); } // there may be no endpoint in case of httpclient callerHost = StringUtils.defaultString(callerHost); // make row key. rowkey is me final long acceptedTime = acceptedTimeService.getAcceptedTime(); final long rowTimeSlot = timeSlot.getTimeSlot(acceptedTime); final RowKey calleeRowKey = new CallRowKey(calleeApplicationName, calleeServiceType.getCode(), rowTimeSlot); final short callerSlotNumber = ApplicationMapStatisticsUtils.getSlotNumber(calleeServiceType, elapsed, isError); final ColumnName callerColumnName = new CallerColumnName(callerServiceType.getCode(), callerApplicationName, callerHost, callerSlotNumber); if (useBulk) { TableName mapStatisticsCallerTableName = getTableName(); bulkIncrementer.increment(mapStatisticsCallerTableName, calleeRowKey, callerColumnName); } else { final byte[] rowKey = getDistributedKey(calleeRowKey.getRowKey()); // column name is the name of caller app. byte[] columnName = callerColumnName.getColumnName(); increment(rowKey, columnName, 1L); } }