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

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

Introduction

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

Prototype

public static String[] split(final String str) 

Source Link

Document

Splits the provided text into an array, using whitespace as the separator.

Usage

From source file:com.ufukuzun.myth.dialect.util.ExpressionUtils.java

public static List<String> splitIdFragments(String value) {
    List<String> idFragments = new ArrayList<String>();

    if (StringUtils.isNotBlank(value)) {
        value = StringUtils.remove(value, "${}");
        Matcher matcher = DOLLAR_EXPRESSION_PATTERN.matcher(value);
        while (matcher.find()) {
            idFragments.add(matcher.group());
            value = StringUtils.remove(value, matcher.group());
        }//  ww  w .j  a v a 2  s.c o m

        idFragments.addAll(Arrays.asList(StringUtils.split(value)));
    }

    return idFragments;
}

From source file:architecture.ee.web.site.WebSiteDomainMapper.java

/**
 * @param domain/*from   ww w.  j  ava2 s .  c  om*/
 * @param webSiteId
 */
public WebSiteDomainMapper(long webSiteId, String domain) {
    this.domains = StringUtils.split(domain);
    this.webSiteId = webSiteId;
}

From source file:com.goodhuddle.huddle.repository.MemberSpecification.java

public static Specification<Member> search(final Huddle huddle, final SearchMembersRequest request) {
    return new Specification<Member>() {
        @Override//from w ww  .  jav a  2s.c  o m
        public Predicate toPredicate(Root<Member> member, CriteriaQuery<?> query, CriteriaBuilder builder) {

            Predicate conjunction = builder.conjunction();

            // huddle
            conjunction.getExpressions().add(builder.equal(member.get("huddle"), huddle));

            // keywords

            if (StringUtils.isNotBlank(request.getKeywords())) {
                String[] terms = StringUtils.split(request.getKeywords());
                for (String keyword : terms) {
                    if (keyword != null && keyword.length() > 0) {

                        String matchTerm = "%" + keyword.toLowerCase() + "%";
                        conjunction.getExpressions().add(builder.or(
                                builder.like(builder.lower(member.<String>get("username")), matchTerm),
                                builder.like(builder.lower(member.<String>get("email")), matchTerm),
                                builder.like(builder.lower(member.<String>get("firstName")), matchTerm),
                                builder.like(builder.lower(member.<String>get("lastName")), matchTerm)));
                    }
                }
            }

            // security groups

            if (CollectionUtils.isNotEmpty(request.getSecurityGroupIds())) {

                Join<Object, Object> securityGroup = member.join("securityGroup",
                        request.isIncludeNoAccess() ? JoinType.LEFT : JoinType.INNER);

                Predicate disjunction = builder.disjunction();
                for (Long id : request.getSecurityGroupIds()) {
                    disjunction.getExpressions().add(builder.equal(securityGroup.get("id"), id));
                }
                if (request.isIncludeNoAccess()) {
                    disjunction.getExpressions().add(builder.isNull(securityGroup.get("id")));
                }
                conjunction.getExpressions().add(disjunction);

            } else if (request.isIncludeNoAccess()) {

                conjunction.getExpressions().add(builder.isNull(member.get("securityGroup")));

            }

            // tags

            MemberTagFilter tagFilter = request.getTags();
            if (tagFilter != null) {

                if (tagFilter.getIncluded() != null) {

                    if (CollectionUtils.isNotEmpty(tagFilter.getIncluded().getTagIds())) {

                        MemberTagFilter.TagSet included = request.getTags().getIncluded();
                        MatchType matchType = included.getMatchType();
                        Predicate tagPredicate = matchType.equals(MatchType.all) ? builder.conjunction()
                                : builder.disjunction();

                        for (Long tagId : included.getTagIds()) {
                            Subquery<Member> sq = query.subquery(Member.class);
                            Root<Member> subMember = sq.from(Member.class);
                            Join<Member, Tag> tag = subMember.join("tags");
                            sq.select(subMember).where(builder.equal(tag.get("id"), tagId));
                            tagPredicate.getExpressions().add(builder.in(member).value(sq));
                        }

                        conjunction.getExpressions().add(tagPredicate);
                    }
                }

                if (tagFilter.getExcluded() != null) {

                    if (CollectionUtils.isNotEmpty(tagFilter.getExcluded().getTagIds())) {

                        MemberTagFilter.TagSet excluded = request.getTags().getExcluded();
                        MatchType matchType = excluded.getMatchType();
                        Predicate tagPredicate = matchType.equals(MatchType.all) ? builder.disjunction()
                                : builder.conjunction();

                        for (Long tagId : excluded.getTagIds()) {
                            Subquery<Member> sq = query.subquery(Member.class);
                            Root<Member> subMember = sq.from(Member.class);
                            Join<Member, Tag> tag = subMember.join("tags");
                            sq.select(subMember).where(builder.equal(tag.get("id"), tagId));
                            tagPredicate.getExpressions().add(builder.in(member).value(sq).not());
                        }

                        conjunction.getExpressions().add(tagPredicate);
                    }
                }

            }

            return conjunction;
        }
    };
}

From source file:de.vandermeer.asciitable.v2.render.WidthUtilities.java

/**
 * Returns an array with the width of the longest word per column calculated from the given table.
 * Default padding will be added per column.
 * Padding for individual columns will be added if defined.
 * @param table to use for calculation//from w  ww.j a va2s  . c  o m
 * @return array with width of longest word for each column, null if input table was null
 */
public static int[] longestWord(V2_AsciiTable table) {
    if (table == null) {
        return null;
    }

    if (table.getTable().size() == 0) {
        return new int[0];
    }

    int[] ret = new int[table.getColumnCount()];

    for (V2_Row row : table.getTable()) {
        if (row instanceof ContentRow) {
            ContentRow crow = (ContentRow) row;
            for (int i = 0; i < crow.getColumns().length; i++) {
                if (crow.getColumns()[i] != null) {
                    String[] ar = StringUtils.split(crow.getColumns()[i].toString());
                    for (int k = 0; k < ar.length; k++) {
                        int count = ar[k].length() + crow.getPadding()[i] + crow.getPadding()[i];
                        if (count > ret[i]) {
                            ret[i] = count;
                        }
                    }
                }
            }
        }
    }

    return ret;
}

From source file:kenh.expl.functions.Split.java

public String[] process(String str) {
    return StringUtils.split(str);
}

From source file:de.vandermeer.asciitable.CWC_LongestWord.java

/**
 * Returns an array with the width of the longest word per column calculated from the given table.
 * Default padding will be added per column.
 * Padding for individual columns will be added if defined.
 * @param rows the table rows for calculations
 * @param colNumbers number of columns in the table
 * @return array with width of longest word for each column, null if input table was null
 *//*  w  ww. j ava2s  .  c o  m*/
public static int[] longestWord(LinkedList<AT_Row> rows, int colNumbers) {
    if (rows == null) {
        return null;
    }

    if (rows.size() == 0) {
        return new int[0];
    }

    int[] ret = new int[colNumbers];

    for (AT_Row row : rows) {
        if (row.getType() == TableRowType.CONTENT) {
            LinkedList<AT_Cell> cells = row.getCells();

            for (int i = 0; i < cells.size(); i++) {
                if (cells.get(i).getContent() != null) {
                    String[] ar = StringUtils
                            .split(Object_To_StrBuilder.convert(cells.get(i).getContent()).toString());
                    for (int k = 0; k < ar.length; k++) {
                        int count = ar[k].length() + cells.get(i).getContext().getPaddingLeft()
                                + cells.get(i).getContext().getPaddingRight();
                        if (count > ret[i]) {
                            ret[i] = count;
                        }
                    }
                }
            }
        }
    }

    return ret;
}

From source file:com.google.dart.engine.internal.element.angular.AngularHasClassSelectorElementImpl.java

@Override
public boolean apply(XmlTagNode node) {
    XmlAttributeNode attribute = node.getAttribute("class");
    if (attribute != null) {
        String text = attribute.getText();
        if (text != null) {
            String name = getName();
            for (String className : StringUtils.split(text)) {
                if (className.equals(name)) {
                    return true;
                }//from w w w.j  av  a2 s .  co m
            }
        }
    }
    return false;
}

From source file:net.douglasthrift.bigscreenbot.Settings.java

public List<String> getListProperty(String key) {
    String value = getProperty(key);

    if (value != null)
        return Arrays.asList(StringUtils.split(value));
    else//from www .  j  a va 2  s .c o  m
        return null;
}

From source file:eu.popgen.canephora.parsers.plink.FAMReader.java

FAMRecord readRecord() throws IOException {
    String line = this.in.readLine();
    if (line == null) {
        return null;
    }//from   www .  j a  v a2s .  co  m
    String[] toks = StringUtils.split(line);
    FAMRecord rec = new FAMRecord(toks[0], toks[1], toks[2], toks[3], Integer.parseInt(toks[4]),
            Integer.parseInt(toks[5]));
    return rec;
}

From source file:de.vandermeer.skb.mvn.pm.model.Ctxt_BuildVersion.java

/**
 * Creates a new Build Version object for the context.
 * @param id the identifier of the artifact
 * @param value the value (group, artifact, version information)
 * @throws NullPointerException if any argument was null or resulted in null strings
 * @throws IllegalArgumentException if any argument was blank, resulted in blank strings, or was otherwise problematic
 *//*w  ww  .j a v  a2 s . c o m*/
public Ctxt_BuildVersion(String id, String value) {
    Validate.notBlank(id);
    Validate.notBlank(value);

    this.id = id;

    String[] _val = StringUtils.split(value);
    if (_val.length != 3) {
        throw new IllegalArgumentException(
                "dependency definition has not all required elements: <" + id + "=" + value + ">");
    }

    this.groupId = _val[0];
    this.artifactId = _val[1];
    this.version = _val[2];

    Validate.notBlank(this.groupId);
    Validate.notBlank(this.artifactId);
    Validate.notBlank(this.version);
}