Example usage for org.apache.commons.lang StringUtils isEmpty

List of usage examples for org.apache.commons.lang StringUtils isEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils isEmpty.

Prototype

public static boolean isEmpty(String str) 

Source Link

Document

Checks if a String is empty ("") or null.

Usage

From source file:cn.loveapple.service.util.service.ServiceUtil.java

/**
 * <code>cn.loveapple.service.cool.model</code>??????
 * <code>cn.loveapple.service.cool.meta</code>????
 * //from   w  w  w  .  j  a  v a 2 s .  co m
 * 
 * @param modelName ??????
 * @return ???
 */
public static ModelMeta getModelMeta(String modelName) {
    if (StringUtils.isEmpty(modelName)) {
        throw new IllegalArgumentException("ModelMeta key is empty.");
    }
    if (metaStorage.get(modelName) == null) {
        StringBuilder metaClass = new StringBuilder(modelName.length());
        metaClass.append(modelName);
        metaClass.append("Meta");
        metaClass.replace(26, 31, "meta");

        Method getMethod = null;
        try {
            getMethod = Class.forName(metaClass.toString()).getMethod("get");
        } catch (Exception e) {
            throw new RuntimeException("create meta method class error.", e);
        }

        try {
            metaStorage.put(modelName, (ModelMeta) getMethod.invoke(null));
        } catch (Exception e) {
            throw new RuntimeException("invoke meta method class error.", e);
        }
    }

    return metaStorage.get(modelName);
}

From source file:com.germinus.easyconf.taglib.PropertyTei.java

/**
 * Return information about the scripting variables to be created.
 */// ww w .ja va2s  .co m
public VariableInfo[] getVariableInfo(TagData data) {

    String type = (String) data.getAttribute("type");
    if (StringUtils.isEmpty(type)) {
        type = "java.lang.String";
    }

    return new VariableInfo[] {
            new VariableInfo(data.getAttributeString("id"), type, true, VariableInfo.AT_END) };

}

From source file:com.pureinfo.tgirls.servlet.VoteServlet.java

@Override
protected void doPost(HttpServletRequest _req, HttpServletResponse _resp) throws ServletException, IOException {
    String picId = _req.getParameter("picId");
    String votePropertyIndex = _req.getParameter("vote");

    if (StringUtils.isEmpty(picId) || StringUtils.isEmpty(votePropertyIndex)) {
        logger.debug("picId or votePropertyIndex empty, vote failed.");
        return;/*from  ww  w. j  a v  a2s . c  om*/
    }
    try {
        IPhotoMgr mgr = (IPhotoMgr) ArkContentHelper.getContentMgrOf(Photo.class);
        mgr.votePic(Integer.parseInt(picId), votePropertyIndex);
    } catch (Exception e) {
        logger.error("error when vote[" + picId + "]", e);
    }

    logger.debug("vote pic[" + picId + "] with[" + votePropertyIndex + "]");

}

From source file:com.lingxiang2014.controller.admin.TemplateController.java

@RequestMapping(value = "/edit", method = RequestMethod.GET)
public String edit(String id, ModelMap model) {
    if (StringUtils.isEmpty(id)) {
        return ERROR_VIEW;
    }/*from w  ww  . j  a v a  2 s .  co m*/
    model.addAttribute("template", templateService.get(id));
    model.addAttribute("content", templateService.read(id));
    return "/admin/template/edit";
}

From source file:com.clican.pluto.dataprocess.spring.parser.JGroupPartitionProcessorParser.java

@SuppressWarnings("unchecked")

public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) {
    ((RootBeanDefinition) beanDef).setInitMethodName("init");
    String partition = element.getAttribute("partition");
    if (StringUtils.isEmpty(partition)) {
        partition = "partition";
    }//from w w w  . j a v  a  2 s.co m
    String partitionListName = element.getAttribute("partitionListName");
    if (StringUtils.isNotEmpty(element.getAttribute("inputVarName"))) {
        String[] inputVarName = element.getAttribute("inputVarName").split(",");
        beanDef.getPropertyValues().addPropertyValue("inputVarName", inputVarName);
    }
    if (StringUtils.isNotEmpty(element.getAttribute("outputVarName"))) {
        String[] outputVarName = element.getAttribute("outputVarName").split(",");
        beanDef.getPropertyValues().addPropertyValue("outputVarName", outputVarName);
    }
    String serviceName = element.getAttribute("serviceName");
    beanDef.getPropertyValues().addPropertyValue("partitionListName", partitionListName);
    beanDef.getPropertyValues().addPropertyValue("serviceName", serviceName);
    try {
        beanDef.getPropertyValues().addPropertyValue("partition", new RuntimeBeanReference(partition));
    } catch (Throwable e) {

    }
    String[] partitionProcessors = element.getAttribute("partitionProcessors").split(",");
    List partitionProcessorList = new ManagedList();
    for (String partitionProcessor : partitionProcessors) {
        partitionProcessorList.add(new RuntimeBeanReference(partitionProcessor.trim()));
    }
    beanDef.getPropertyValues().addPropertyValue("partitionProcessors", partitionProcessorList);
}

From source file:com.intuit.tank.vm.settings.SearchConfig.java

private void initConfig() {
    if (config != null) {
        HierarchicalConfiguration searchLocationConfig = config.configurationAt(KEY_SEARCH_LOCATION);
        searchLocation = searchLocationConfig.getString("");
    }/*w  w  w  .jav  a 2 s.c  o m*/
    if (StringUtils.isEmpty(searchLocation)) {
        searchLocation = "./searchDirectory";
    }
    File file = new File(searchLocation);
    if (!file.exists()) {
        file.mkdir();
    }
}

From source file:acromusashi.stream.bean.FieldExtractor.java

/**
 * Extract field /*  w w w.ja  va  2  s  . co  m*/
 * 
 * @param target is used to get object data.
 * @param key is used to get key value.
 * @param delimeter key delimeter
 * @return is used to return object data.
 */
public static Object extract(Object target, String key, String delimeter) {
    if (target == null) {
        return target;
    }

    String keyHead = extractKeyHead(key, delimeter); // the return value of keyHead 
    String keyTail = extractKeyTail(key, delimeter); // the return value of keyTail 

    Object innerObject = null;

    // checking if the "Object: target" is Map or not
    if (target instanceof Map) {
        Map<?, ?> targetMap = (Map<?, ?>) target;
        innerObject = targetMap.get(keyHead); // get the object inside "keyHead"
    } else {
        BeanWrapperImpl baseWapper = new BeanWrapperImpl(target); // this is the reflection for getting the field value.
        innerObject = baseWapper.getPropertyValue(keyHead); // get the value from the field if the "keyHead" is not Map
    }

    if (innerObject == null) {
        return innerObject;
    }

    if (StringUtils.isEmpty(keyTail) == true) {
        return innerObject;
    } else {
        return extract(innerObject, keyTail, delimeter); // recursive method for calling self function again.
    }
}

From source file:com.healthcit.analytics.businessdelegates.ModuleMetadataManager.java

/**
 * Loads module metadata/*from   ww w. j  a v  a 2  s  .c  om*/
 */
public String loadModuleMetaData() throws Exception {
    String moduleMetadata = couchDb.getAttachment(PropertyUtils.getProperty("couchDBModuleMetadataDoc"));

    if (StringUtils.isEmpty(moduleMetadata))
        throw new Exception("ERROR: Could not load the module metadata");

    else
        return moduleMetadata;
}

From source file:com.bstek.dorado.core.store.H2BaseStore.java

@Override
protected String getConnectionUrl() throws Exception {
    String storeDir = Configure.getString("core.storeDir");
    if (StringUtils.isEmpty(storeDir)) {
        throw new IllegalArgumentException("\"core.storeDir\" undefined. ");
    }//from  w  w w  .  ja  v a  2  s.  c  om
    return "jdbc:h2:file:" + PathUtils.concatPath(storeDir, "db", namespace);
}

From source file:com.netscape.certsrv.request.RequestStatusAdapter.java

public RequestStatus unmarshal(String value) throws Exception {
    return StringUtils.isEmpty(value) ? null : RequestStatus.valueOf(value);
}