List of usage examples for org.apache.commons.lang StringUtils defaultIfEmpty
public static String defaultIfEmpty(String str, String defaultStr)
Returns either the passed in String, or if the String is empty or null
, the value of defaultStr
.
From source file:com.openshift.restclient.authorization.UnauthorizedException.java
@Override public String getMessage() { String scheme = details.getScheme(); if (StringUtils.isNotBlank(scheme)) { return String.format("%s You can access the server using %s authentication.", MSG_BASE, scheme); }//from ww w. ja va 2s. c om return StringUtils.defaultIfEmpty(details.getMessage(), super.getMessage()); }
From source file:com.gst.mix.domain.MixTaxonomyMapping.java
private MixTaxonomyMapping(final String identifier, final String config, final String currency) { this.identifier = StringUtils.defaultIfEmpty(identifier, null); this.config = StringUtils.defaultIfEmpty(config, null); this.currency = StringUtils.defaultIfEmpty(currency, null); }
From source file:cn.vlabs.duckling.vwb.CPSFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { int advSiteId = Integer.parseInt(StringUtils.defaultIfEmpty(request.getParameter("as"), "-1")); if (advSiteId <= 0) { chain.doFilter(request, response); return;//w w w. j av a 2 s . c o m } HttpServletResponse rep = (HttpServletResponse) response; HttpServletRequest req = (HttpServletRequest) request; request.setAttribute("cps", advSiteId); Cookie[] cookies = req.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (StringUtils.equals(CPS_ADV, cookie.getName())) { cookie.setPath(req.getContextPath()); cookie.setMaxAge(0); } } } Cookie myCookie = new Cookie(CPS_ADV, advSiteId + ""); myCookie.setMaxAge(60 * 60 * 24);// myCookie.setPath(req.getContextPath()); rep.addCookie(myCookie); chain.doFilter(request, response); }
From source file:com.echosource.ada.core.AdaDirectory.java
/** * Instantiates a new php package. * * @param key * the key */ public AdaDirectory(String key) { setKey(StringUtils.defaultIfEmpty(StringUtils.trim(key), DEFAULT_PACKAGE_NAME)); }
From source file:com.adaptris.core.stubs.ExternalResourcesHelper.java
public static boolean isExternalServerAvailable(URLString server) { log.debug("Checking {}", server.toString()); int port = server.getPort(); if (port == -1) { try {/* ww w.j ava 2 s .c o m*/ port = PortDefaults.valueOf(StringUtils.defaultIfEmpty(server.getProtocol(), "").toLowerCase()) .getPort(); } catch (Exception e) { log.trace("No default port for {}", server.toString()); } } return isExternalServerAvailable(server.getHost(), port); }
From source file:net.ageto.gyrex.impex.common.steps.impl.readers.FileReaderLineBased.java
@Override protected StatusStep process() { String filename = (String) getInputParam( FileReaderLineBasedDefinition.InputParamNames.INPUT_FILENAME.name()); if (StringUtils.isBlank(filename)) { processError("The given file name \"{0}\" is invalid.", filename); return StatusStep.ERROR; }// www. j a va2 s. c o m // charset (default is ISO-8859-1) String charset = StringUtils.defaultIfEmpty( (String) getInputParam(FileReaderLineBasedDefinition.InputParamNames.INPUT_CHARSET.name()), "ISO-8859-1"); StringBuffer output = new StringBuffer(); try { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filename), charset)); String str; while ((str = in.readLine()) != null) { output.append(str); output.append(System.getProperty("line.separator")); } in.close(); } catch (IOException e) { processError(e.getMessage()); return StatusStep.ERROR; } setOutputParam(FileReaderLineBasedDefinition.OutputParamNames.OUTPUT_FILECONTENT.name(), output); processInfo("{0} has been completed successfully.", ID); return StatusStep.OK; }
From source file:com.openshift.internal.restclient.model.template.Parameter.java
@Override public String getGeneratorName() { return StringUtils.defaultIfEmpty(asString("generate"), asString("generator")); }
From source file:de.thischwa.pmcms.model.domain.pojo.Level.java
@Override public String getDecorationString() { String deco = StringUtils.defaultIfEmpty(title, name); if (InitializationManager.isAdmin()) deco = String.format("%s#%d", deco, getId()); return deco;/*from w w w . j a v a 2 s . c o m*/ }
From source file:info.magnolia.module.workflow.commands.simple.MessageCommand.java
/** * @return Returns the message.//from w w w. j ava 2 s. c o m */ public String getMessage(Context context) { return StringUtils.defaultIfEmpty((String) context.getAttribute(Context.ATTRIBUTE_MESSAGE), this.getMessage()); }
From source file:mobile.vo.group.GroupDetailVO.java
public static GroupDetailVO create(vo.GroupVO source) { GroupDetailVO vo = new GroupDetailVO(); vo.id = source.getId();//from ww w . j a v a 2 s. co m vo.groupName = source.getGroupName(); vo.countMem = source.getCountMem(); vo.createDate = new DateTime(source.getCreateDate()).toString("yyyy-MM-dd HH:mm:ss"); vo.headUrl = source.getHeadUrl(); vo.industryId = source.getIndustryId(); vo.industryName = source.getIndustryName(); vo.groupInfo = StringUtils.defaultIfEmpty(source.getGroupInfo(), ""); vo.skillsTags = source.getTags(); Type tp = Type.getByName(source.getType()); if (null != tp) { vo.type = tp.toString(); } if (tp == Type.NORMAL) { Expert ownerExpert = Expert.getExpertByUserId(source.getOwnerId()); vo.owner = User.create(ownerExpert); } GroupPriv priv = GroupPriv.getByName(source.getGroupPriv()); if (null != priv) { vo.groupPriv = priv.toString(); } vo.maxMemberNum = source.getMaxMemberNum(); // ?? models.User user = models.User.getFromSession(Context.current().session()); if (null != user) { Map<Long, Boolean> joinGroupMap = GroupMember.checkJoinGroup(user.getId(), Arrays.asList(source.getId())); vo.setIsJoin(joinGroupMap.get(source.getId())); } if (null != user && tp == Type.NORMAL) { vo.isOwner = Objects.equals(user.getId(), source.getOwnerId()); } return vo; }