Example usage for org.apache.commons.lang3 StringUtils isNotEmpty

List of usage examples for org.apache.commons.lang3 StringUtils isNotEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isNotEmpty.

Prototype

public static boolean isNotEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is not empty ("") and not null.

 StringUtils.isNotEmpty(null)      = false StringUtils.isNotEmpty("")        = false StringUtils.isNotEmpty(" ")       = true StringUtils.isNotEmpty("bob")     = true StringUtils.isNotEmpty("  bob  ") = true 

Usage

From source file:net.ostis.scpdev.builder.scg.SCgIdentity.java

public boolean hasIdtf() {
    return StringUtils.isNotEmpty(idtf);
}

From source file:com.twosigma.beakerx.chart.serializer.GraphicsSerializer.java

@Override
public void serialize(T graphics, JsonGenerator jgen, SerializerProvider sp)
        throws IOException, JsonProcessingException {
    jgen.writeObjectField(TYPE, SerializerUtil.getTypeName(graphics));
    jgen.writeObjectField("uid", graphics.getUid());
    jgen.writeObjectField("visible", graphics.getVisible());
    jgen.writeObjectField("yAxis", graphics.getYAxis());
    jgen.writeObjectField("hasClickAction", graphics.hasClickAction());
    if (StringUtils.isNotEmpty(graphics.getClickTag())) {
        jgen.writeObjectField("clickTag", graphics.getClickTag());
    }/*w  w w .  j  a va2s. co  m*/
    Map<String, String> keyTags = graphics.getKeyTags();
    if (keyTags != null && !keyTags.isEmpty()) {
        jgen.writeObjectField("keyTags", keyTags);
    }
    Object[] keys = graphics.getKeys();
    if (ArrayUtils.isNotEmpty(keys)) {
        jgen.writeObjectField("keys", keys);
    }
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for getting the number corresponding to Calendar year
 * //from w  w w.ja va 2  s  . c o  m
 * @param year
 * @return
 */
public static String getYear(String year) {

    int yr = 0;
    if (StringUtils.isNotEmpty(year)) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(Long.valueOf(year));
        yr = calendar.get(Calendar.YEAR);
    }
    return String.valueOf(yr);
}

From source file:net.ili.base.util.RedirectNavigationHandler.java

@Override
public void handleNavigation(FacesContext context, String from, String outcome) {
    if (StringUtils.isNotEmpty(outcome) && !outcome.endsWith("?faces-redirect=true")) {
        outcome += "?faces-redirect=true";
    }/*  w  w  w .ja  v  a2  s. com*/
    parent.handleNavigation(context, from, outcome);
}

From source file:com.tyro.oss.pact.spring4.pact.provider.JsonResponseBodyMatcher.java

@Override
public void assertContent(ResultActions expectations, Pact.InteractionResponse response) throws Exception {
    if (StringUtils.isNotEmpty(response.getSchema())) {
        expectations.andExpect(new JsonSchemaResultMatcher(response.getSchema()));
    } else {//from  w w w.  j  ava2 s .  c  om
        expectations.andExpect(new JsonResultMatcher(response.getBody()));
    }
}

From source file:com.inkubator.hrm.web.recruitment.RecruitMppPeriodFormController.java

@PostConstruct
@Override/*from  www.ja va  2 s.c o m*/
public void initialization() {
    super.initialization();
    try {
        String recruitMppId = FacesUtil.getRequestParameter("recruitMppId");
        model = new RecruitMppPeriodModel();
        isUpdate = Boolean.FALSE;
        if (StringUtils.isNotEmpty(recruitMppId)) {
            RecruitMppPeriod recruitMppPeriod = recruitMppPeriodService
                    .getEntiyByPK(Long.parseLong(recruitMppId));
            if (recruitMppPeriod != null) {
                model = getModelFromEntity(recruitMppPeriod);
                isUpdate = Boolean.TRUE;
            }
        }

    } catch (Exception e) {
        LOGGER.error("Error", e);
    }
}

From source file:com.tethrnet.manage.db.SystemDB.java

/**
 * method to do order by based on the sorted set object for systems for user
 *
 * @param sortedSet sorted set object/*from ww  w  .jav  a2 s .  com*/
 * @param userId    user id
 * @return sortedSet with list of host systems
 */
public static SortedSet getUserSystemSet(SortedSet sortedSet, Long userId) {
    List<HostSystem> hostSystemList = new ArrayList<HostSystem>();

    String orderBy = "";
    if (sortedSet.getOrderByField() != null && !sortedSet.getOrderByField().trim().equals("")) {
        orderBy = "order by " + sortedSet.getOrderByField() + " " + sortedSet.getOrderByDirection();
    }
    String sql = "select * from system where id in (select distinct system_id from  system_map m, user_map um where m.profile_id=um.profile_id and um.user_id=? ";
    //if profile id exists add to statement
    sql += StringUtils.isNotEmpty(sortedSet.getFilterMap().get(FILTER_BY_PROFILE_ID)) ? " and um.profile_id=? "
            : "";
    sql += ") " + orderBy;

    //get user for auth token
    Connection con = null;
    try {
        con = DBUtils.getConn();
        PreparedStatement stmt = con.prepareStatement(sql);
        stmt.setLong(1, userId);
        //filter by profile id if exists
        if (StringUtils.isNotEmpty(sortedSet.getFilterMap().get(FILTER_BY_PROFILE_ID))) {
            stmt.setLong(2, Long.valueOf(sortedSet.getFilterMap().get(FILTER_BY_PROFILE_ID)));
        }

        ResultSet rs = stmt.executeQuery();

        while (rs.next()) {
            HostSystem hostSystem = new HostSystem();
            hostSystem.setId(rs.getLong("id"));
            hostSystem.setDisplayNm(rs.getString("display_nm"));
            hostSystem.setUser(rs.getString("user"));
            hostSystem.setHost(rs.getString("host"));
            hostSystem.setPort(rs.getInt("port"));
            hostSystem.setAuthorizedKeys(rs.getString("authorized_keys"));
            hostSystem.setStatusCd(rs.getString("status_cd"));
            hostSystemList.add(hostSystem);
        }
        DBUtils.closeRs(rs);
        DBUtils.closeStmt(stmt);

    } catch (Exception e) {
        log.error(e.toString(), e);
    }
    DBUtils.closeConn(con);

    sortedSet.setItemList(hostSystemList);
    return sortedSet;

}

From source file:com.nridge.connector.fs.con_fs.core.Constants.java

public static int getCfgSleepValue(AppMgr anAppMgr, String aCfgName, int aDefaultValue) {
    int sleepInSeconds = aDefaultValue;

    String timeString = anAppMgr.getString(aCfgName);
    if (StringUtils.isNotEmpty(timeString)) {
        if (StringUtils.endsWithIgnoreCase(timeString, "m")) {
            String minuteString = StringUtils.stripEnd(timeString, "m");
            if ((StringUtils.isNotEmpty(minuteString)) && (StringUtils.isNumeric(minuteString))) {
                int minuteAmount = Integer.parseInt(minuteString);
                sleepInSeconds = minuteAmount * 60;
            }//from   w  w w .  j  av a  2 s  .  com
        } else if (StringUtils.endsWithIgnoreCase(timeString, "h")) {
            String hourString = StringUtils.stripEnd(timeString, "h");
            if ((StringUtils.isNotEmpty(hourString)) && (StringUtils.isNumeric(hourString))) {
                int hourAmount = Integer.parseInt(hourString);
                sleepInSeconds = hourAmount * 60 * 60;
            }
        } else if (StringUtils.endsWithIgnoreCase(timeString, "d")) {
            String dayString = StringUtils.stripEnd(timeString, "d");
            if ((StringUtils.isNotEmpty(dayString)) && (StringUtils.isNumeric(dayString))) {
                int dayAmount = Integer.parseInt(dayString);
                sleepInSeconds = dayAmount * 60 * 60 * 24;
            }
        } else // we assume seconds
        {
            String secondString = StringUtils.stripEnd(timeString, "s");
            if ((StringUtils.isNotEmpty(secondString)) && (StringUtils.isNumeric(secondString))) {
                sleepInSeconds = Integer.parseInt(secondString);
            }
        }
    }

    return sleepInSeconds;
}

From source file:net.ili.base.services.authority.MyFilterChainDefinition.java

/**
 *
 * @return @throws Exception/* w  w w . ja va 2  s  . co  m*/
 */
@Override
public Ini.Section getObject() throws Exception {
    Ini defaultIni = new Ini();
    Ini ini = new Ini();

    //url
    if (StringUtils.isNotEmpty(filterChainDefinitions)) {
        defaultIni.load(filterChainDefinitions);
    }
    ini.addSection(Ini.DEFAULT_SECTION_NAME);
    Ini.Section section = ini.getSection(Ini.DEFAULT_SECTION_NAME);

    //?Resource
    List<Resource> list = dao.findAll();
    for (Resource resource : list) {
        //?section
        if (StringUtils.isNotEmpty(resource.getUrl()) && StringUtils.isNotEmpty(resource.getPermission())) {
            section.put(resource.getUrl(), MessageFormat.format(PREMISSIONEXP, resource.getPermission()));
        }
    }
    return section;
}

From source file:com.liveneo.plat.web.action.JobmsgAction.java

public String editJobmsg() {
    try {//from   w  w  w .  ja  va  2 s. c o  m
        jobmsgForm = new JobmsgForm();
        BdJobmsg bdJobmsg = new BdJobmsg();
        if (StringUtils.isNotEmpty(jobmsgKey)) {
        } else {
            if (StringUtils.isNotEmpty((String) this.getSession().getAttribute("jobmsgKey")))
                jobmsgKey = (String) this.getSession().getAttribute("jobmsgKey");
            else
                return AbstractActionSupport.EDIT;
        } // list
        bdJobmsg = this.jobmsgService.getBdJobmsg(IntegerUtil.converStrToInteger(jobmsgKey));
        WebappUtil.copyProperties(jobmsgForm, bdJobmsg);
        this.getSession().setAttribute("jobmsgForm", jobmsgForm);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } finally {
    }
    return AbstractActionSupport.EDIT;
}