List of usage examples for org.apache.commons.lang StringUtils defaultString
public static String defaultString(String str)
Returns either the passed in String, or if the String is null
, an empty String ("").
From source file:net.di2e.ecdr.commons.query.CDRQueryImpl.java
public CDRQueryImpl(QueryCriteria crit, String localSourceId) throws UnsupportedQueryException { queryCriteria = crit;/*from w w w. j av a 2s . co m*/ MultivaluedMap<String, String> queryParameters = queryCriteria.getParameterValues(); humanReadableQueryBuilder = new StringBuilder( StringUtils.defaultString(queryCriteria.getHumanReadableQuery())); populateStrictMode(queryParameters); appendParameter(SearchConstants.STRICTMODE_PARAMETER, isStrictMode); populateResponseFormat(queryParameters); appendParameter(SearchConstants.FORMAT_PARAMETER, responseFormat); populateStartIndex(queryParameters); appendParameter(SearchConstants.STARTINDEX_PARAMETER, startIndex); populateCount(queryParameters); appendParameter(SearchConstants.COUNT_PARAMETER, count); populateTimeoutMilliseconds(queryParameters); appendParameter(SearchConstants.TIMEOUT_PARAMETER, timeoutMilliseconds); boolean includeStatus = isIncludeStatus(queryParameters); appendParameter(SearchConstants.STATUS_PARAMETER, includeStatus); populateSourceList(queryCriteria.getParameterValues()); if (CollectionUtils.isNotEmpty(sources)) { appendParameter(SearchConstants.SOURCE_PARAMETER, StringUtils.join(sources, ", ")); } }
From source file:com.hp.autonomy.hod.sso.HodAuthenticationPrincipal.java
public HodAuthenticationPrincipal(final UUID tenantUuid, final UUID userUuid, final ResourceName application, final Resource userStoreInformation, final AuthenticationInformation applicationAuthentication, final AuthenticationInformation userAuthentication, final String name, final Map<String, Serializable> userMetadata, final String securityInfo) { this.tenantUuid = tenantUuid; this.userUuid = userUuid; this.application = application; this.userStoreInformation = userStoreInformation; this.applicationAuthentication = applicationAuthentication; this.userAuthentication = userAuthentication; this.name = StringUtils.defaultString(name); this.securityInfo = securityInfo; this.userMetadata = userMetadata == null ? new HashMap<>() : userMetadata; }
From source file:com.bibisco.bean.ProjectFromSceneMainCharacterDTO.java
public JSONObject toJSONObject() { JSONObject lJSONObject;/* w w w .j av a2 s. c om*/ try { lJSONObject = new JSONObject(); lJSONObject.put("idCharacter", idCharacter); lJSONObject.put("name", name); lJSONObject.put("position", position); lJSONObject.put("mainCharacter", mainCharacter); // character info questions if (characterInfoQuestionsDTOList != null) { for (CharacterInfoQuestionsDTO lCharacterInfoQuestionsDTO : characterInfoQuestionsDTOList) { JSONObject lJSONObjectCharacterInfoQuestion = new JSONObject(); lJSONObjectCharacterInfoQuestion.put("interviewMode", lCharacterInfoQuestionsDTO.getInterviewMode().booleanValue()); // interview mode if (!lCharacterInfoQuestionsDTO.getInterviewMode().booleanValue()) { lJSONObjectCharacterInfoQuestion.put("freeText", StringUtils.defaultString(lCharacterInfoQuestionsDTO.getFreeText())); } // questions else { int i = 0; JSONArray lJSONArrayCharacterInfoQuestionQuestionsAnswers = new JSONArray(); for (int j = 0; j < lCharacterInfoQuestionsDTO.getCharacterInfoQuestions() .getTotalQuestions(); j++) { JSONObject lJSONObjectInfoQuestion = new JSONObject(); lJSONObjectInfoQuestion.put("question", lCharacterInfoQuestionsDTO .getCharacterInfoQuestions().getQuestionList().get(j)); lJSONObjectInfoQuestion.put("answer", StringUtils.defaultString(lCharacterInfoQuestionsDTO.getAnswerList().get(j))); lJSONArrayCharacterInfoQuestionQuestionsAnswers.put(i++, lJSONObjectInfoQuestion); } lJSONObjectCharacterInfoQuestion.put("questionsAnswers", lJSONArrayCharacterInfoQuestionQuestionsAnswers); } lJSONObject.put(lCharacterInfoQuestionsDTO.getCharacterInfoQuestions().name(), lJSONObjectCharacterInfoQuestion); } } // character info without questions if (characterInfoWithoutQuestionsDTOList != null) { for (CharacterInfoWithoutQuestionsDTO lCharacterInfoWithoutQuestionsDTO : characterInfoWithoutQuestionsDTOList) { JSONObject lJSONObjectCharacterInfoWithoutQuestion = new JSONObject(); lJSONObjectCharacterInfoWithoutQuestion.put("info", StringUtils.defaultString(lCharacterInfoWithoutQuestionsDTO.getInfo())); lJSONObject.put(lCharacterInfoWithoutQuestionsDTO.getCharacterInfoWithoutQuestions().name(), lJSONObjectCharacterInfoWithoutQuestion); } } // images if (imageDTOList != null) { JSONArray lJSONArrayImages = new JSONArray(); for (ImageDTO lImageDTO : imageDTOList) { JSONObject lJsonObjectImage = new JSONObject(); lJsonObjectImage.put("idImage", lImageDTO.getIdImage()); lJsonObjectImage.put("description", lImageDTO.getDescription()); lJSONArrayImages.put(lJsonObjectImage); } lJSONObject.put("images", lJSONArrayImages); } } catch (JSONException e) { mLog.error(e); throw new BibiscoException(e, BibiscoException.FATAL); } return lJSONObject; }
From source file:me.smoe.lzy.filter.AccessLogFilter.java
private void logAccessAPI(HttpServletRequest request) { try {// ww w. j a va 2s . c om User user = (User) request.getSession().getAttribute(Constants.SESSION_USER); String userId = user != null ? user.getId() : "NOT_LOGIN"; String remoteAddr = request.getRemoteAddr(); String method = request.getMethod(); String requestURI = request.getRequestURI(); String userAgent = StringUtils.defaultString(request.getHeader("User-Agent")); String queryString = request.getQueryString(); if (queryString != null) { queryString = URLDecoder.decode(request.getQueryString(), Constants.CHARSET); } requestURI = requestURI + (StringUtils.isNotEmpty(queryString) ? ("?" + queryString) : StringUtils.EMPTY); Logger.getRestAccessLogger().info( String.format("[%s] [%s] [%s] %s [%s]", userId, remoteAddr, method, requestURI, userAgent)); } catch (Exception e) { Logger.getRestAccessLogger().warn("AccessAPI logger error: " + e.getMessage(), e); } }
From source file:com.joshlong.lazyblogger.service.BlogService.java
public void setUser(String user) { this.user = StringUtils.defaultString(user).trim(); }
From source file:com.opengamma.web.exchange.WebExchangeVersionResource.java
/** * Builds a URI for this resource./* w w w.j av a2 s . c o m*/ * @param data the data, not null * @param overrideVersionId the override version id, null uses information from data * @return the URI, not null */ public static URI uri(final WebExchangeData data, final UniqueId overrideVersionId) { String exchangeId = data.getBestExchangeUriId(null); String versionId = StringUtils .defaultString(overrideVersionId != null ? overrideVersionId.getVersion() : data.getUriVersionId()); return data.getUriInfo().getBaseUriBuilder().path(WebExchangeVersionResource.class).build(exchangeId, versionId); }
From source file:net.sourceforge.ajaxtags.tags.OptionsBuilder.java
/** * @param optionsDelimiter/* ww w. ja v a 2 s. com*/ * the optionsDelimiter to set */ public void setOptionsDelimiter(final String optionsDelimiter) { this.optionsDelimiter = StringUtils.defaultString(optionsDelimiter); }
From source file:gov.nih.nci.caarray.util.URIUserType.java
/** * {@inheritDoc}/*from w w w . jav a 2 s. co m*/ */ @Override public void nullSafeSet(PreparedStatement inPreparedStatement, Object o, int i) throws SQLException { final URI val = (URI) o; String uri = null; if (val != null) { uri = StringUtils.defaultString(val.toString()); } inPreparedStatement.setString(i, uri); }
From source file:com.mmounirou.spotirss.spotify.tracks.XTracks.java
private String cleanTrackName(String trackName) { String[] spotifyExtensions = new String[] { " - Explicit Version", " - Live", " - Radio Edit" }; String strSong = trackName;/*from www . j av a 2s . c om*/ for (String extensions : spotifyExtensions) { if (StringUtils.contains(strSong, extensions)) { strSong = "X " + StringUtils.remove(trackName, extensions); } } String[] braces = { "[]", "()" }; for (String brace : braces) { String extendedinfo = null; do { extendedinfo = StringUtils.defaultString( StringUtils.substringBetween(strSong, brace.charAt(0) + "", brace.charAt(1) + "")); if (StringUtils.isNotBlank(extendedinfo)) { if (StringUtils.startsWith(extendedinfo, "feat.")) { String strArtist = StringUtils.removeStart("feat.", extendedinfo); strSong = StringUtils.replace(strSong, String.format("%c%s%c", brace.charAt(0), extendedinfo, brace.charAt(1)), ""); m_artistsInTrackName.addAll(cleanArtist(strArtist)); } else { strSong = StringUtils.replace(strSong, String.format("%c%s%c", brace.charAt(0), extendedinfo, brace.charAt(1)), ""); strSong = "X " + strSong; } } } while (StringUtils.isNotBlank(extendedinfo)); } String[] strSongSplitted = strSong.split("featuring"); if (strSongSplitted.length > 1) { strSong = strSongSplitted[0]; m_artistsInTrackName.add(strSongSplitted[1]); } String[] strSongWithFeaturing = strSong.split("-"); if (strSongWithFeaturing.length > 1 && strSongWithFeaturing[1].contains("feat.")) { strSong = strSongWithFeaturing[0]; m_artistsInTrackName.addAll(cleanArtist(StringUtils.remove(strSongWithFeaturing[1], "feat."))); } else { strSongWithFeaturing = strSong.split("feat."); if (strSongWithFeaturing.length > 1) { strSong = strSongWithFeaturing[0]; m_artistsInTrackName.addAll(cleanArtist(strSongWithFeaturing[1])); } } return strSong.trim().toLowerCase(); }
From source file:com.opengamma.web.orgs.WebOrganizationVersionResource.java
/** * Builds a URI for this resource.//from w w w . j a v a 2s .c o m * @param data the data, not null * @param overrideVersionId the override version id, null uses information from data * @return the URI, not null */ public static URI uri(final WebOrganizationsData data, final UniqueId overrideVersionId) { String securityId = data.getBestOrganizationUriId(null); String versionId = StringUtils .defaultString(overrideVersionId != null ? overrideVersionId.getVersion() : data.getUriVersionId()); return data.getUriInfo().getBaseUriBuilder().path(WebOrganizationVersionResource.class).build(securityId, versionId); }