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

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

Introduction

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

Prototype

public static boolean isNotBlank(String str) 

Source Link

Document

Checks if a String is not empty (""), not null and not whitespace only.

Usage

From source file:com.enonic.cms.core.content.contentdata.custom.xmlbased.AbstractXmlBasedInputDataEntry.java

protected AbstractXmlBasedInputDataEntry(final DataEntryConfig config, final DataEntryType type,
        final String value) {
    super(config, type);
    if (StringUtils.isNotBlank(value)) {
        try {//  ww w . ja  va 2 s . c om
            this.value = JDOMUtil.parseDocument(value);
            this.valueAsString = JDOMUtil.prettyPrintDocument(this.value, "", true);
        } catch (final Exception e) {
            throw new InvalidContentDataException("Could not parse input: " + this.getName(), e);
        }
    }
}

From source file:com.streamreduce.util.JSONUtils.java

/**
 * Flattens JSON into a single level of key/value pairs.
 *
 * @param json the {@link JSON} object to flatten
 * @param prefix the prefix to append to each key
 *
 * @return the newly flattened {@link JSONObject}
 *//*from  w  ww .  jav a 2s  .  c  o m*/
public static JSONObject flattenJSON(JSON json, String prefix) {
    JSONObject flattenedJSON = new JSONObject();

    prefix = (StringUtils.isNotBlank(prefix) ? prefix + "." : "");

    if (json instanceof JSONArray) {
        JSONArray jsonArray = (JSONArray) json;

        for (int i = 0; i < jsonArray.size(); i++) {
            Object value = jsonArray.get(i);
            String flatKey = prefix + i;

            if (value instanceof JSONArray) {
                flattenedJSON.putAll(flattenJSON((JSONArray) value, flatKey));
            } else if (value instanceof JSONObject) {
                flattenedJSON.putAll(flattenJSON((JSONObject) value, flatKey));
            } else {
                flattenedJSON.put(flatKey, value);
            }
        }
    } else if (json instanceof JSONObject) {
        JSONObject jsonObject = (JSONObject) json;

        for (Object rawKey : jsonObject.keySet()) {
            String key = rawKey.toString();
            Object value = jsonObject.get(key);
            String flatKey = prefix + key;

            if (value instanceof JSONArray) {
                flattenedJSON.putAll(flattenJSON((JSONArray) value, flatKey));
            } else if (value instanceof JSONObject) {
                flattenedJSON.putAll(flattenJSON((JSONObject) value, flatKey));
            } else {
                flattenedJSON.put(flatKey, value);
            }
        }
    } else {
        throw new IllegalArgumentException("Unable to flatten a JSONNull.");
    }

    return flattenedJSON;
}

From source file:com.pscnlab.recruit.daos.impls.RecruitDaoImpl.java

@Override
public Page<Recruit> findPageByCondition(String position, Integer offset, Integer size) {
    FilterMap filterMap = new FilterMap();
    if (StringUtils.isNotBlank(position)) {
        filterMap.eq("position", position);
    }/*  ww w. ja  v a  2 s.c o m*/
    return super.page(filterMap, offset, size);
}

From source file:com.sfs.whichdoctor.xml.writer.helper.ProjectXmlHelper.java

/**
 * Output the project collection as an XML string.
 *
 * @param projects the projects//from w  ww.  j  a  v a  2  s  .  co m
 *
 * @return the xml string
 */
public static String getProjectsXml(final Collection<ProjectBean> projects) {

    final XmlWriter xmlwriter = new XmlWriter();

    xmlwriter.writeEntity("projects");

    for (ProjectBean project : projects) {

        xmlwriter.writeEntity("project").writeAttribute("GUID", project.getGUID()).writeAttribute("projectId",
                project.getId());

        xmlwriter.writeEntity("assessmentType").writeText(project.getAssessmentType()).endEntity();
        xmlwriter.writeEntity("projectType").writeText(project.getProjectType()).endEntity();
        xmlwriter.writeEntity("status").writeText(project.getStatus()).endEntity();
        if (StringUtils.isNotBlank(project.getTitle())) {
            xmlwriter.writeEntity("title").writeText(project.getTitle()).endEntity();
        }
        if (project.getSubmitted() != null) {
            xmlwriter.writeEntity("submitted").writeText(Formatter.convertDate(project.getSubmitted()))
                    .endEntity();
        }
        if (project.getResubmitted() != null) {
            xmlwriter.writeEntity("resubmitted").writeText(Formatter.convertDate(project.getResubmitted()))
                    .endEntity();
        }
        if (project.getYear() > 0) {
            xmlwriter.writeEntity("year").writeText(String.valueOf(project.getYear())).endEntity();
        }

        if (StringUtils.isNotBlank(project.getTrainingOrganisation())) {

            xmlwriter.writeEntity("specialty");

            xmlwriter.writeEntity("organisation").writeText(project.getTrainingOrganisation()).endEntity();

            if (StringUtils.isNotBlank(project.getTrainingProgram())) {
                xmlwriter.writeEntity("program").writeText(project.getTrainingProgram()).endEntity();
            }
            xmlwriter.endEntity();
        }

        xmlwriter.writeEntity("assessors");
        writeAssessor(project.getAssessor1(), xmlwriter);
        writeAssessor(project.getAssessor2(), xmlwriter);
        writeAssessor(project.getAssessor3(), xmlwriter);
        xmlwriter.endEntity();

        if (StringUtils.isNotBlank(project.getMemo())) {
            xmlwriter.writeEntity("memo");
            xmlwriter.writeXml(DataFilter.getSafeXml(project.getMemo()));
            xmlwriter.endEntity();
        }
        xmlwriter.endEntity();
    }
    xmlwriter.endEntity();

    return xmlwriter.getXml();
}

From source file:net.kamhon.ieagle.aop.SchemaChangeB4Advice.java

public void before(Method m, Object[] args, Object target) throws Throwable {
    if (StringUtils.isNotBlank(fromSchema) && StringUtils.isNotBlank(toSchema))
        if (args.length > 0) {
            if ((args[0] instanceof String) && isSql((String) args[0])) {
                String sql = (String) args[0];
                sql = StringUtils.replace(sql, fromSchema, toSchema);
            }//w ww .ja v a 2  s. c  o  m
        }

}

From source file:com.edm.app.auth.Auth.java

public static void robot(String robotPath) {
    BufferedReader reader = null;
    try {//  www  . ja  v a  2  s. com
        reader = new BufferedReader(new InputStreamReader(new FileInputStream(robotPath), "UTF-8"));
        String line = null;

        while ((line = reader.readLine()) != null) {
            if (StringUtils.isBlank(line)) {
                continue;
            }
            String key = StringUtils.substringBefore(line, "=");
            String val = StringUtils.substringAfter(line, "=");
            boolean r = StringUtils.equals(md5.encode(StringUtils.upperCase(key)),
                    "cebb21b542877339c40e7e8ecc96796e");
            if (StringUtils.isNotBlank(key) && r) {
                if (StringUtils.isNotBlank(val)) {
                    ROBOT = StringUtils.lowerCase(val);
                    break;
                }
            }
        }
    } catch (Exception e) {
        logger.error("(Auth:robot) error: ", e);
    } finally {
        try {
            if (reader != null) {
                reader.close();
            }
        } catch (IOException e) {
        }
    }
}

From source file:gr.seab.r2rml.beans.util.LogicalTableMappingComparator.java

public int compare(LogicalTableMapping logicalTableMapping0, LogicalTableMapping logicalTableMapping1) {

    for (PredicateObjectMap p : logicalTableMapping0.getPredicateObjectMaps()) {
        try {/* w w  w  .ja  v a 2s .c om*/
            if (StringUtils.isNotBlank(p.getRefObjectMap().getParentTriplesMapUri()))
                return 1;
        } catch (Exception e) {
        }
    }

    for (PredicateObjectMap p : logicalTableMapping1.getPredicateObjectMaps()) {
        try {
            if (StringUtils.isNotBlank(p.getRefObjectMap().getParentTriplesMapUri()))
                return -1;
        } catch (Exception e) {
        }
    }

    return 0;
}

From source file:com.etrip.service.Impl.GroupServiceImpl.java

@Override
public ResultMap search(String name, Integer page, Integer rows) {
    Assert.notNull(rows, "rows is null");
    Assert.notNull(page, "page is null");
    ResultMap resultMap = new ResultMap();
    FilterMap filterMap = FilterMap.init();
    filterMap.eq("deleted", 0);
    if (StringUtils.isNotBlank(name)) {
        filterMap.like("name", "%" + name + "%");
    }// ww w  . ja  v  a 2s .c  o m
    OrderMap orderMap = new OrderMap();
    orderMap.desc("id");
    Page queryPage = pGroupRepository.queryPage(filterMap, orderMap, page, rows);
    int count = Integer.parseInt(queryPage.getPageInfo().get("pageCount").toString());
    int totalCount = Integer.parseInt(queryPage.getPageInfo().get("totalCount").toString());
    if (totalCount % count != 0) {
        queryPage.getPageInfo().put("totalPage", totalCount / count + 1);
    }
    resultMap.success();
    resultMap.put(queryPage);
    return resultMap;
}

From source file:io.sidecar.query.ReadingKeyWithMetrics.java

public ReadingKeyWithMetrics(String readingKey, ImmutableMap<String, Double> metrics) {
    checkArgument(StringUtils.isNotBlank(readingKey));
    this.readingKey = readingKey;

    checkNotNull(metrics);//  ww  w . ja  va2s .c  o  m
    this.metrics = metrics;
}

From source file:com.baidu.terminator.manager.common.validation.IPValidator.java

@Override
public boolean isValid(String ip, ConstraintValidatorContext arg1) {
    Pattern pattern = Pattern.compile(
            "\\b((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\b");
    if (StringUtils.isNotBlank(ip)) {
        Matcher matcher = pattern.matcher(ip);
        return matcher.matches();
    }//www .  jav  a2 s  . c  om
    return false;
}