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

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

Introduction

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

Prototype

public static String[] splitByWholeSeparator(final String str, final String separator) 

Source Link

Document

Splits the provided text into an array, separator string specified.

The separator(s) will not be included in the returned String array.

Usage

From source file:com.eryansky.common.orm.core.MatchValue.java

/**
 * andValueSeparatororValueSeparator()// w  ww.  j av a2s. c o m
 * 
 * @param matchValue 
 * @param type 
 * @param andValueSeparator 
 * @param orValueSeparator 
 * 
 * @return {@link com.eryansky.common.orm.core.MatchValue}
 */
public static MatchValue createMatchValueModel(String matchValue, Class<?> type, String andValueSeparator,
        String orValueSeparator) {

    List<Object> values = new ArrayList<Object>();

    if (StringUtils.contains(matchValue, andValueSeparator)) {
        String[] siplit = StringUtils.splitByWholeSeparator(matchValue, andValueSeparator);
        CollectionUtils.addAll(values, (Object[]) ConvertUtils.convertToObject(siplit, type));
        return new MatchValue(false, values);
    } else if (StringUtils.contains(matchValue, orValueSeparator)) {
        String[] siplit = StringUtils.splitByWholeSeparator(matchValue, orValueSeparator);
        CollectionUtils.addAll(values, (Object[]) ConvertUtils.convertToObject(siplit, type));
        return new MatchValue(true, values);
    } else {
        values.add(ConvertUtils.convertToObject(matchValue, type));
        return new MatchValue(false, values);
    }

}

From source file:com.eryansky.common.orm.core.PropertyFilters.java

/**
 * ?//  www  . java  2 s . c o  m
 * <p>
 *    
 * </p>
 * <code>
 *    PropertyFilters.get("EQS_propertyName","maurice")
 * </code>
 * 
 * @param expression ?
 * @param matchValue 
 * 
 * @return {@link PropertyFilter}
 */
@SuppressWarnings("static-access")
public static PropertyFilter get(String expression, String matchValue) {

    Assert.hasText(expression, "??");

    String restrictionsNameAndClassType = StringUtils.substringBefore(expression, "_");

    String restrictionsName = StringUtils.substring(restrictionsNameAndClassType, 0,
            restrictionsNameAndClassType.length() - 1);
    String classType = StringUtils.substring(restrictionsNameAndClassType,
            restrictionsNameAndClassType.length() - 1, restrictionsNameAndClassType.length());

    FieldType FieldType = null;
    try {
        FieldType = FieldType.valueOf(classType);
    } catch (Exception e) {
        throw new IllegalAccessError(
                "[" + expression + "]??,?:" + classType);
    }

    String[] propertyNames = null;

    if (StringUtils.contains(expression, "_OR_")) {
        String temp = StringUtils.substringAfter(expression, restrictionsNameAndClassType + "_");
        propertyNames = StringUtils.splitByWholeSeparator(temp, "_OR_");
    } else {
        propertyNames = new String[1];
        propertyNames[0] = StringUtils.substringAfterLast(expression, "_");
    }

    return new PropertyFilter(restrictionsName, FieldType, propertyNames, matchValue);
}

From source file:com.github.dactiv.orm.core.PropertyFilters.java

/**
 * ?/*  w  ww. j av  a2s.  com*/
 * <p>
 *    
 * </p>
 * <code>
 *    PropertyFilters.build("EQS_propertyName","maurice")
 * </code>
 * 
 * @param expression ?
 * @param matchValue 
 * 
 * @return {@link PropertyFilter}
 */
@SuppressWarnings("static-access")
public static PropertyFilter build(String expression, String matchValue) {

    Assert.hasText(expression, "??");

    String restrictionsNameAndClassType = StringUtils.substringBefore(expression, "_");

    String restrictionsName = StringUtils.substring(restrictionsNameAndClassType, 0,
            restrictionsNameAndClassType.length() - 1);
    String classType = StringUtils.substring(restrictionsNameAndClassType,
            restrictionsNameAndClassType.length() - 1, restrictionsNameAndClassType.length());

    FieldType FieldType = null;
    try {
        FieldType = FieldType.valueOf(classType);
    } catch (Exception e) {
        throw new IllegalAccessError(
                "[" + expression + "]??,?:" + classType);
    }

    String[] propertyNames = null;

    if (StringUtils.contains(expression, "_OR_")) {
        String temp = StringUtils.substringAfter(expression, restrictionsNameAndClassType + "_");
        propertyNames = StringUtils.splitByWholeSeparator(temp, "_OR_");
    } else {
        propertyNames = new String[1];
        propertyNames[0] = StringUtils.substringAfterLast(expression, "_");
    }

    return new PropertyFilter(restrictionsName, FieldType, propertyNames, matchValue);
}

From source file:com.eryansky.common.orm.core.hibernate.restriction.CriterionMultipleValueSupport.java

/**
 * ?,,//from w ww .  j a  v a2 s.c o m
 *  
 * @param value 
 * @param type 
 * 
 * @return Object
 */
public Object convertMatchValue(String value, Class<?> type) {
    Assert.notNull(value, "?");
    String[] result = StringUtils.splitByWholeSeparator(value, getAndValueSeparator());

    return ConvertUtils.convertToObject(result, type);
}

From source file:ec.edu.espe.distribuidas.facturacion.socket.estrucMsj.tipoDato.TextV.java

public void agregarObjCodificado(MensajeRsCodificar mensajeCodificado) {
    String msj = validarTrama(mensajeCodificado.asTexto(limitador));
    String datos[] = StringUtils.splitByWholeSeparator(msj, limitador);
    for (String dato : datos) {
        agregarDato(dato);//from w  w  w.  j a  va2  s . c  o  m
    }
}

From source file:io.apiman.gateway.vertx.api.AuthenticatingRouteMatcher.java

private boolean authenticate(HttpServerRequest request) {
    String authString = request.headers().get(HttpHeaders.AUTHORIZATION);

    if (authString == null)
        return false;

    String[] basicAuth = StringUtils.splitByWholeSeparator(authString, "Basic "); //$NON-NLS-1$

    if (basicAuth.length == 1) {
        return basicAuth(request, basicAuth[0]);
    }/*from  www.j a va 2  s  .c o m*/

    return false;
}

From source file:com.eryansky.common.orm.core.spring.data.jpa.specification.Specifications.java

/**
 * ???/*from  w w  w  .ja  v a 2s.  c  om*/
 * 
 * @param propertyName ??
 * @param root Query roots always reference entities
 * 
 * @return {@link javax.persistence.criteria.Path}
 */
public static Path<?> getPath(String propertyName, Root<?> root) {

    Path<?> path = null;

    if (StringUtils.contains(propertyName, ".")) {
        String[] propertys = StringUtils.splitByWholeSeparator(propertyName, ".");
        path = root.get(propertys[0]);
        for (int i = 1; i < propertys.length; i++) {
            path = path.get(propertys[i]);
        }
    } else {
        path = root.get(propertyName);
    }

    return path;
}

From source file:de.jcup.egradle.codeassist.SourceCodeInsertionSupport.java

private InsertionData prepareInsertionString(String originInsertion, String textBeforeColumn,
        boolean ignoreIndentOnFirstLine) {
    InsertionData result = new InsertionData();
    if (StringUtils.isEmpty(originInsertion)) {
        return result;
    }//from   w  w  w .ja  v  a 2  s.  c  o m
    String insertion = originInsertion;
    /* first do indent if necessary */
    if (StringUtils.isNotEmpty(textBeforeColumn)) {
        /* build indent */
        String indention = transformTextBeforeToIndentString(textBeforeColumn);

        /* for each line append indent before... */
        boolean endsWithNewLine = insertion.endsWith("\n");
        StringBuilder sb = new StringBuilder();
        String[] splitted = StringUtils.splitByWholeSeparator(insertion, "\n");
        for (int i = 0; i < splitted.length; i++) {
            boolean lastLineEmpty = endsWithNewLine;
            lastLineEmpty = lastLineEmpty && i == splitted.length - 1;
            lastLineEmpty = lastLineEmpty && StringUtils.isEmpty(splitted[i]);

            boolean appendLine = !lastLineEmpty;
            if (!appendLine) {
                continue;
            }
            if (i > 0 || !ignoreIndentOnFirstLine) {
                sb.append(indention);
            }
            sb.append(splitted[i]);
            sb.append("\n");

        }
        insertion = sb.toString();

    }
    result.cursorOffset = insertion.indexOf("$cursor");
    if (result.cursorOffset != -1) {
        result.sourceCode = REPLACE_CURSOR_POS.matcher(insertion).replaceAll("");
    } else {
        result.sourceCode = insertion;
    }
    return result;

}

From source file:com.thoughtworks.go.domain.materials.perforce.P4OutputParser.java

Modification modificationFromDescription(String output, ConsoleResult result) throws P4OutputParseException {
    String[] parts = StringUtils.splitByWholeSeparator(output, SEPARATOR);
    Pattern pattern = Pattern.compile(DESCRIBE_OUTPUT_PATTERN, Pattern.MULTILINE);
    Matcher matcher = pattern.matcher(parts[0]);
    if (matcher.find()) {
        Modification modification = new Modification();
        parseFistline(modification, matcher.group(1), result);
        parseComment(matcher, modification);
        parseAffectedFiles(parts, modification);
        return modification;
    }/*  w w w. jav a2 s. c  o m*/
    throw new P4OutputParseException("Could not parse P4 description: " + output);
}

From source file:com.slothpetrochemical.bridgeprob.BridgeProblemSignature.java

@Override
public List<String> getNamesOnLeft() {
    String names = stripFlashlight(this.getLeftSegment()).toString();
    return Arrays.asList(StringUtils.splitByWholeSeparator(names, NAME_DELIMITER));
}